How toset transparency on a Rect ?!
Blitz3D Forums/Blitz3D Beginners Area/How toset transparency on a Rect ?!
| ||
H! A very simple thing but I need it.. How to set the transparency on this: Rect 0,0,200,200,1 I hope blitz make this in the new update Rect 0,0,200,200,1,[0-100]< transp. |
| ||
I don't think you can unless you can draw this to a buffer, and then read it as an image or load the image in. I agree this could be nice as a feature request - not just for Rectangles, but for all the shapes and maybe even text too. |
| ||
oke I draw it to a buffer and read it as an image , but how can I set the image transperancy then ? Please a small example how to do that. Thank you very much |
| ||
Good Day Try 'MaskImage' command perhaps... |
| ||
Ah... I see, now. I was only considering Masks. Are you working in 2D or 3D - with 3D you can create a sprite and set the Alpha (transparency) level. Otherwise, sorry I'm not able to help. |
| ||
its 2D // so you can't help :( |
| ||
There is no built in command in 2d for transparency. So the idea is to make it by yourself: for each destination pixel of the rectangle, you read the previous one in the buffer, make the mix with your image depending on your alpha value (final=(1-alpha)*previous_color+alpha*new_color) and write it back. For big rectangles it will probably be pretty slow. You can speed it up a little bit by locking the buffer and using ReadWritePixelFast. It's very likely there's some routine for that in the code archive. |
| ||
i did some code for that and so did a couple of other ppl. My code reads al the images is beforehand to an array and the area the image overlays to an array. it isn't as easy as it sounds splitting the readpixel color into RGB color tho. But the code in the archives is good, avoid mine tho, cause it's more meant for fading images. sorry for the ramble :^) |