| View previous topic :: View next topic |
| Author |
Message |
daspamer Grandmaster Cheater Supreme
Reputation: 54
Joined: 13 Sep 2011 Posts: 1588
|
Posted: Wed Jun 11, 2014 5:24 am Post subject: Transparent background when drawing with canvas. |
|
|
Hey,
How can I set transparent on object that I draw on with the Canvas class.
For example this script.
| Code: | local form = createForm();
form.Color = 0xff -- red
local image = createImage(form);
image.width = form.width - 50;
image.left = 25;
image.height = form.height - 50;
image.top = 25;
image.Canvas.Brush.Color=0xff0000; -- blue
image.Canvas.fillRect(25, 25, image.width-25, image.height-25); |
There will be 3 colors: red, black, blue.
When drawing with canvas, areas that are not filled by the user, become black?
How can I force it to be transparent instead (to be red, the color of the parent object (form)).
| Code: | | image.Transparent = true |
Isn't applying any effect.
_________________
I'm rusty and getting older, help me re-learn lua. |
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25832 Location: The netherlands
|
Posted: Wed Jun 11, 2014 10:55 am Post subject: |
|
|
Welcome to the LCL image/picture weirdness
try something like this:
| Code: |
form = createForm();
form.Color = 0xff -- red
image = createImage(form);
image.width = form.width - 50;
image.left = 25;
image.height = form.height - 50;
image.top = 25;
bm=image.picture.Bitmap
bm.Width=image.Width
bm.Height=image.Height
bm.Canvas.Brush.Color=0xff0000; -- blue
bm.Canvas.fillRect(25, 25, image.width-25, image.height-25);
bm.TransparentColor=clBlack
image.Transparent=true
|
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
daspamer Grandmaster Cheater Supreme
Reputation: 54
Joined: 13 Sep 2011 Posts: 1588
|
Posted: Wed Jun 11, 2014 11:26 am Post subject: |
|
|
Thanks for the example.
Also, RGB is reversed (BGR..?).
This cyan color (0x169EAB)
http://www.w3schools.com/tags/ref_colorpicker.asp?colorhex=%23169eab
In C.E looks like mustard
| Code: | form = createForm();
form.Color = 0x169EAB |
If we reverse it to 0xAB9E16, it'll produce the cyan color.
| Code: | form = createForm();
form.Color = 0xAB9E16 |
So I'm guessing this is a bug.
(Not that it's an issue, I'm parsing colors to rgb, just thought to let you know.)
Thanks again mate!.
_________________
I'm rusty and getting older, help me re-learn lua. |
|
| Back to top |
|
 |
mgr.inz.Player I post too much
Reputation: 222
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Wed Jun 11, 2014 3:52 pm Post subject: |
|
|
| DaSpamer wrote: | | Also, RGB is reversed (BGR..?). |
hex values:
0xBBGGRR
or
0xABBGGRR
or
0xAABBGGRR
A is alpha
And no, this is not a bug. Open Form Designer, set Form color to R=1 G=2 B=3, look at object inspector, you will see this:
_________________
|
|
| Back to top |
|
 |
daspamer Grandmaster Cheater Supreme
Reputation: 54
Joined: 13 Sep 2011 Posts: 1588
|
Posted: Wed Jun 11, 2014 8:18 pm Post subject: |
|
|
Thank you.
Never knew theres RGBA (ABGR).
Great stuff!.
_________________
I'm rusty and getting older, help me re-learn lua. |
|
| Back to top |
|
 |
|