Gradient Textdraw?
#1

How can I make gradient textdraw like this?

Reply
#2

Those are lots of small textdraws next to each other (best use Sprites for precise squares).

The gradient can easily be calculated by taking Color 1 RGB values and Color 2 RBG values (ignore transparency) and then fade them from COLOR_1 to COLOR_2.

Код:
#define FADE_COLOR_1 0xFFFF00FF // Colors to fade
#define FADE_COLOR_2 0xFF00FFFF

#define MAX_FADE_DRAWS 10 // Number of TextDraws

// When creating:

new r1, g1, b1, r2, g2, b2;

r1 = (FADE_COLOR_1 >> 24) & 255; // Get R,G,B from COLOR_1
g1 = (FADE_COLOR_1 >> 16) & 255;
b1 = (FADE_COLOR_1 >> 8) & 255;

r2 = (FADE_COLOR_2 >> 24) & 255; // Get R,G,B from COLOR_2
g2 = (FADE_COLOR_2 >> 16) & 255;
b2 = (FADE_COLOR_2 >> 8) & 255;

new delta_r = (r2 - r1) / MAX_FADE_DRAWS, // Delta R,G,B (for every step, this is the color that we add to COLOR_1)
	delta_g = (g2 - g1) / MAX_FADE_DRAWS,
	delta_b = (b2 - b1) / MAX_FADE_DRAWS;

for(new i = 0; i < MAX_FADE_DRAWS; i ++)
{
	new rgba = 0x000000FF + ((r1 + delta_r*i) * 256 * 256 * 256) + ((g1 + delta_g*i) * 256 * 256) + ((b1 + delta_b*i) * 256); // Calculate HEX Color (including Alpha!)

	new Text:FadeText = TextDrawCreate(640.0 / MAX_FADE_DRAWS * i, 400.0, "..."); // Make this a TextDraw Sprite and save the IDs in an Array to be able to show them later
	TextDrawColor(FadeText, rgba);
}
If you change the TextDraw to be a Sprite (LD_BUM:blkdot is nice for this) it should work.
Reply
#3

Quote:
Originally Posted by NaS
Посмотреть сообщение
Those are lots of small textdraws next to each other (best use Sprites for precise squares).

The gradient can easily be calculated by taking Color 1 RGB values and Color 2 RBG values (ignore transparency) and then fade them from COLOR_1 to COLOR_2.

Код:
#define FADE_COLOR_1 0xFFFF00FF // Colors to fade
#define FADE_COLOR_2 0xFF00FFFF

#define MAX_FADE_DRAWS 10 // Number of TextDraws

// When creating:

new r1, g1, b1, r2, g2, b2;

r1 = (FADE_COLOR_1 >> 24) & 255; // Get R,G,B from COLOR_1
g1 = (FADE_COLOR_1 >> 16) & 255;
b1 = (FADE_COLOR_1 >> 8) & 255;

r2 = (FADE_COLOR_2 >> 24) & 255; // Get R,G,B from COLOR_2
g2 = (FADE_COLOR_2 >> 16) & 255;
b2 = (FADE_COLOR_2 >> 8) & 255;

new delta_r = (r2 - r1) / MAX_FADE_DRAWS, // Delta R,G,B (for every step, this is the color that we add to COLOR_1)
	delta_g = (g2 - g1) / MAX_FADE_DRAWS,
	delta_b = (b2 - b1) / MAX_FADE_DRAWS;

for(new i = 0; i < MAX_FADE_DRAWS; i ++)
{
	new rgba = 0x000000FF + ((r1 + delta_r*i) * 256 * 256 * 256) + ((g1 + delta_g*i) * 256 * 256) + ((b1 + delta_b*i) * 256); // Calculate HEX Color (including Alpha!)

	new Text:FadeText = TextDrawCreate(640.0 / MAX_FADE_DRAWS * i, 400.0, "..."); // Make this a TextDraw Sprite and save the IDs in an Array to be able to show them later
	TextDrawColor(FadeText, rgba);
}
If you change the TextDraw to be a Sprite (LD_BUM:blkdot is nice for this) it should work.
Thanks. I will try and say it's work or not.
Reply
#4

Quote:
Originally Posted by NaS
Посмотреть сообщение
Those are lots of small textdraws next to each other (best use Sprites for precise squares).

The gradient can easily be calculated by taking Color 1 RGB values and Color 2 RBG values (ignore transparency) and then fade them from COLOR_1 to COLOR_2.

Код:
#define FADE_COLOR_1 0xFFFF00FF // Colors to fade
#define FADE_COLOR_2 0xFF00FFFF

#define MAX_FADE_DRAWS 10 // Number of TextDraws

// When creating:

new r1, g1, b1, r2, g2, b2;

r1 = (FADE_COLOR_1 >> 24) & 255; // Get R,G,B from COLOR_1
g1 = (FADE_COLOR_1 >> 16) & 255;
b1 = (FADE_COLOR_1 >> 8) & 255;

r2 = (FADE_COLOR_2 >> 24) & 255; // Get R,G,B from COLOR_2
g2 = (FADE_COLOR_2 >> 16) & 255;
b2 = (FADE_COLOR_2 >> 8) & 255;

new delta_r = (r2 - r1) / MAX_FADE_DRAWS, // Delta R,G,B (for every step, this is the color that we add to COLOR_1)
	delta_g = (g2 - g1) / MAX_FADE_DRAWS,
	delta_b = (b2 - b1) / MAX_FADE_DRAWS;

for(new i = 0; i < MAX_FADE_DRAWS; i ++)
{
	new rgba = 0x000000FF + ((r1 + delta_r*i) * 256 * 256 * 256) + ((g1 + delta_g*i) * 256 * 256) + ((b1 + delta_b*i) * 256); // Calculate HEX Color (including Alpha!)

	new Text:FadeText = TextDrawCreate(640.0 / MAX_FADE_DRAWS * i, 400.0, "..."); // Make this a TextDraw Sprite and save the IDs in an Array to be able to show them later
	TextDrawColor(FadeText, rgba);
}
If you change the TextDraw to be a Sprite (LD_BUM:blkdot is nice for this) it should work.
Thats not like I want or I couldn't do?
Reply
#5

Quote:
Originally Posted by srvr07
Посмотреть сообщение
Thats not like I want or I couldn't do?
Try more steps so that the transition becomes smooth (about 200 will make each TextDraw about 3 pixels (of 640), which is still a visible transition). It also helps to choose colors that aren't too far away from each other (on the RGB Scale).

But except the colors, position and size of it, it's pretty much the same as in the picture, or am I missing something?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)