SA-MP Forums Archive
[Tutorial] Using LD_SPAC:white to create selectable, pixel perfect rectangles. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] Using LD_SPAC:white to create selectable, pixel perfect rectangles. (/showthread.php?tid=600045)



Using LD_SPAC:white to create selectable, pixel perfect rectangles. - Alcatrik - 02.02.2016

Hi all,

I've been a lurker for a fair few years now, but I think it's time I contributed a little myself.

I've noticed a couple of others have found this trick, but couldn't find any formal explanation of why it works so I thought I'd be the first to document it.

I'll try to keep this as concise as people.


What is LD_SPAC:white and why is it useful?
LD_SPAC:white is a plain, square, white texture. These four attributes have the following implications:
Another useful implication of this is that because textures use the forecolor to paint themselves, and because the hovercolor in SelectTextDraw also uses forecolor, this means that the entire box will be highlighted in hovercolor rather than just the text (assuming anything in the foreground is not selectable).



Notice the highlighted grey box in the centre: although you can't see it in this screenshot, it being hovered over with the mouse.


Code example
Draws a red rectangle 50% the size of the screen starting at (25%, 25%). When player 0 hovers over with the mouse, the entire box will turn green.
Code:
TextDraw:td = TextDrawCreate(640.0 * 0.25, 480.0 * 0.25, "_");
TextDrawTextSize(td, 640.0 * 0.5, 480 * 0.5);
TextDrawColor(td, 0xFF0000FF);
TextDrawFont(td, 4);
TextDrawSetSelectable(td, true);
SelectTextdraw(0, 0x00FF00FF);
** SA-MP uses a 640x480 canvas for textdraws irrespective of screen resolution, so when I say pixel I mean 1 pixel respective to the canvas.


Re: Using LD_SPAC:white to create selectable, pixel perfect rectangles. - TwinkiDaBoss - 02.02.2016

Damn this is dope as fuck. Thanks for the tutorial!
+rep


Re: Using LD_SPAC:white to create selectable, pixel perfect rectangles. - Rufio - 02.02.2016

Great tutorial! +Rep.


Re: Using LD_SPAC:white to create selectable, pixel perfect rectangles. - Gammix - 03.02.2016

Its much better to use LD_PLAN:tvbase than this, because tvbase also support transparency. Plus the texture on it makes it look more cooler.


Re: Using LD_SPAC:white to create selectable, pixel perfect rectangles. - Pottus - 03.02.2016

Quote:
Originally Posted by Gammix
View Post
Its much better to use LD_PLAN:tvbase than this, because tvbase also support transparency. Plus the texture on it makes it look more cooler.
"More cooler" that is some horrible English


Re: Using LD_SPAC:white to create selectable, pixel perfect rectangles. - Gammix - 03.02.2016

Quote:
Originally Posted by Pottus
View Post
"More cooler" that is some horrible English
Thanks Pottus. REP+


Re: Using LD_SPAC:white to create selectable, pixel perfect rectangles. - Alcatrik - 03.02.2016

Quote:
Originally Posted by Gammix
View Post
Its much better to use LD_PLAN:tvbase than this, because tvbase also support transparency. Plus the texture on it makes it look more cooler.
Hi Gammix,

Thanks for the suggestion.

LD_SPAC:white can have alpha/transparency as well!:



Additionally - and please do correct me if I'm wrong as I haven't played around this in months and months now - but given that tvbase is black (I think?), doesn't that mean it can't be properly colourised, ie. 0xFF0000FF would set it to a dark red at best?


Respuesta: Using LD_SPAC:white to create selectable, pixel perfect rectangles. - Whyd - 03.02.2016

Nice tutorial!


Re: Using LD_SPAC:white to create selectable, pixel perfect rectangles. - Gammix - 03.02.2016

Quote:
Originally Posted by Alcatrik
View Post
Hi Gammix,

Thanks for the suggestion.

LD_SPAC:white can have alpha/transparency as well!:



Additionally - and please do correct me if I'm wrong as I haven't played around this in months and months now - but given that tvbase is black (I think?), doesn't that mean it can't be properly colourised, ie. 0xFF0000FF would set it to a dark red at best?
Hi there. I noticed the issue with one of the LD_SPAC where you can only have transparency of their original color (so black can have a range of alpha only).

No i used tvbase here and was able to set good color combinations, i guess you can have most color but they would be a little dark. I don't recommend it but i find the tvbase texture a bit better than a plain sprite; as you mostly use them as background bars.


Re: Using LD_SPAC:white to create selectable, pixel perfect rectangles. - Alcatrik - 03.02.2016

That's a pretty cool fact to know - and that's a good looking gamemode that you've got there!