Page 1 of 2

Canvas Light (WIP)

PostPosted: Thu Feb 19, 2015 1:29 am
by Hblade
So, I was bored and decided to try and make canvas light =D

So far... looks interesting.
light.png

Re: Canvas Light (WIP)

PostPosted: Thu Feb 19, 2015 8:53 pm
by schnellboot
i need the code :twisted:

Re: Canvas Light (WIP)

PostPosted: Thu Feb 19, 2015 8:57 pm
by bat78
If you are more bored you can also add smooth lightness and a blink.
and then it will be a decent lighting.

If you want to make it perfect.. you have to know that the light has a color. It doesn't just "take-off the darkness" xDD
You have to erase a specific color with specific transparancy.
When my project is done, you will be able to do color mapping in real time.. so you can obtain a specific color for each pixel in the background.

Note that this might happen in bitfox v2.
I will have to program a 3rd party program similar to animget that makes screenshots each frame.
On that way, you can have color of each pixel in your game.

Re: Canvas Light (WIP)

PostPosted: Thu Feb 19, 2015 9:24 pm
by Hblade
already added it =D using putpixel too. is nice.

Re: Canvas Light (WIP)

PostPosted: Thu Feb 19, 2015 9:28 pm
by bat78
Good job!
At least you can do and release something that fast.. I still have to work on that.

Re: Canvas Light (WIP)

PostPosted: Thu Feb 19, 2015 11:57 pm
by Hblade
Here ya go, man :D
soft_light.png


Code: Select all
void soft_light_inverted(int X, int Y, int R, int G, int B, double A, double rad, int smooth)
{
    double i, i2;
    moveto(X, Y);
    setpen(R, G, B, A, 5+smooth);
    for(i=0;i<pi*2;i+=pi/rad/(pi/5))
    {
        for(i2=0;i2<rad;i2+=4)
        {
            setpen(R, G-(i2/rad), B-(i2/rad), 1-min((A+(i2/rad)), .8), 4);
            putpixel(X+cos(i)*i2, Y+sin(i)*i2);
        }
    }
}


To use:
soft_light_inverted(player.xscreen, player.yscreen, 0, 0, 0, 0, 150, 0);

Re: Canvas Light (WIP)

PostPosted: Fri Feb 20, 2015 12:11 am
by bat78
Okay now it looks regal. In a response of this, I created a jumping mechanism.
Tomorrow we'll make an entire game as it seems haha.

Re: Canvas Light (WIP)

PostPosted: Fri Feb 20, 2015 12:20 am
by Hblade
seen it nice job dude =D hehe

Re: Canvas Light (WIP)

PostPosted: Fri Feb 20, 2015 12:31 am
by bat78
Hblade wrote:seen it nice job dude =D hehe

haha thanks =D It is nothing much. But I was out of ideas and time so..

Can I use your light in my project. I can immediately make it compatible with bmps.

Re: Canvas Light (WIP)

PostPosted: Fri Feb 20, 2015 12:33 am
by Hblade
Sure you can =D I'd like to see the results lol O:

Re: Canvas Light (WIP)

PostPosted: Fri Feb 20, 2015 1:57 am
by bat78
Hblade wrote:Sure you can =D I'd like to see the results lol O:

I don't know why I am doing this.. but I will make a demo.

A quick question:
Why is there moveto?

Re: Canvas Light (WIP)

PostPosted: Fri Feb 20, 2015 2:19 am
by bat78
Done, but it looks wrong, unlikely because of the overloaded functions of my project but ..I guess it is that I have defined precision as:
#define pi 3.14159265

Put one x24 bit bmp named "lightme" in the local directory, open the application and press the button. It will put your light centered of the image.
lightme.exe
(1.71 MiB) Downloaded 149 times


Oups, I didn't notice that I -1ed translarancy twise. That because bitfox's setpen's transparancy of 0 means max transparancy.
i.e it is 0 instead of 1 ..the opposite way. Check the picture bellow for how should it looks like.

Re: Canvas Light (WIP)

PostPosted: Fri Feb 20, 2015 2:30 am
by bat78
I mean it looks like the size of the pixel is being incorrect:
Image

Re: Canvas Light (WIP)

PostPosted: Fri Feb 20, 2015 1:58 pm
by digiot
Hblade wrote:So, I was bored and decided to try and make canvas light =D

That looks great now, with the smoothing, well done !

But what I ask me, is using a png instead really too expensive on ressources ?


Cheers !

Re: Canvas Light (WIP)

PostPosted: Fri Feb 20, 2015 3:54 pm
by Hblade
Hi, and no not really, this was mostly just me trying to see if it can be done using no images lol O:

IN fact, not using PNG's is probably more resource hungry haha :D

Upsides:
Unlimited sizing without pixelation, you can have any light size without there being a down grade in visual quality =D

Downsides:
Might take up loads of processing if using larger lights.