Gradual fading alpha

Monkey Forums/Monkey Programming/Gradual fading alpha

ENAY(Posted 2011) [#1]
I'm not sure what this is called but I am having problems trying to replicate it in Monkey.

Let's say for example I have a simply square box and I want it to gradually fade out as the pixels go towards the right.

The far left pixels have an alpha of 1.0 and then the far right pixels have an alpha of 0.0, with the pixels from left to right having a gradient that slowly go from 1.0 to 0.0.

Is this possible in Monkey? It was certainly possibly in Blitzmax.

Maybe I need to modify the .png image or something.


therevills(Posted 2011) [#2]
There are currently no read/write pixels commands in Monkey, you will need to do it with you png image - gimp can do this.


Hima(Posted 2011) [#3]
Maybe masking is what you need? Still, I don't know how can you do that in Monkey yet. Currently, your best bet would be doing it by writing a native code and write a wrapper module in Monkey, since I suppose that images in each target is handled differently.

This is certainly possible in Flash target, since it supports masking and is very easy to do as well.


ENAY(Posted 2011) [#4]
I've sorted it now. Monkey does support this feature.
There was something wrong with the way I was saving the file out it seems.

In the end I just simply copy and pasted a file over from a previous project that worked in both Blitz3D and BMax and ping! realised that everything is sorted :)

Thanks for the posts guys.


therevills(Posted 2011) [#5]
Can you show us how?


Raz(Posted 2011) [#6]
Ahh, so you just wanted a png that faded from alpha 1 to alpha 0 from left to right? You didn't actually need Monkey to do any clever stuff?


Loofadawg(Posted 2011) [#7]
Yes, do show.


ENAY(Posted 2011) [#8]
Show you how? Well it's all in the .png file. There isn't anything to show.
All I do is load it and draw it on the screen like every other image. Monkey/Blitz3D/Blitzmax etc automatically draws the alpha in each pixel.

When I first tried loading the image, all the pixels just came out black like there wasn't any alpha at all, still not sure what happened earlier. Naturally loading these png files in B+ for example the alpha just comes out all white or all black and I thought at first Monkey was the same.


Loofadawg(Posted 2011) [#9]
Okay, I see. I thought you were doing some kind of effect on that allowed you to change the alpha levels on the fly gradually across the image within in Monkey. :^O