draw_text_colour

Draw a string at a given position with a colour gradient.

Syntax:

GML Code Example

draw_text_colour(x, y, string, c1, c2, c3, c4, alpha);


Argument Description
x The x coordinate of the drawn string.
y The y coordinate of the drawn string.
string The string to draw.
c1 The colour for the top left of the drawn text.
c2 The colour for the top right of the drawn text.
c3 The colour for the bottom right of the drawn text.
c4 The colour for the bottom left of the drawn text.
alpha The alpha for the text.


Returns: N/A


Description

This function will draw text in a similar way to draw_text only now you can choose the colours to use for colouring the text as well as the alpha value, and these new values will be used instead of the base drawing colour and alpha.

NOTE: Gradient blending is not available for the HTML5 target unless WebGL is enabled, although you can still set the blending colours and it will blend the font with the first given colour. However all blending in this way creates a duplicate font which is then stored in the cache and used when required, which is far from optimal and if you use multiple colour changes it will slow down your games performance. You can set the font cache size to try and limit this should it be necessary using the function font_set_cache_size.


Example:

GML Code Example

draw_set_colour(c_white);
 draw_text(100, 100, "Health");
 draw_text_colour(100, 200, string(health), c_lime, c_lime, c_green, c_green, 1);
 

The above code will draw two sections of text on the same line, with the first text being drawn white (as that is the base drawing colour) and the second text being drawn with a lime green to normal green gradient.





No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here