Drawing > Styles


Color and Font

Create Color (from RGB)

red green blue as color

Creates a Color value from red, green, blue channels. Numbers must be between [0-255] inclusive.

Utils.getColorRGB([INT], [INT], [INT])

Set Color

set fill color to color

Sets the color used for filling shapes (does not apply to fonts). You can select the color using the color picker, drag in a color attribute or drag in any block that returns a color.

g.fillColor = Utils.convertColor([COLOR]);

Set Font

set current font to font

Sets the font used in drawing text. You can pick the font directly or drag in a font attribute block.

g.setFont([FONT]);

Set Spacing

set spacing to number for font

Sets the spacing between characters of the font.

[FONT].setLetterSpacing([NUMBER]);

Opacity

Set Opacity

set opacity to number %

Sets the opacity (alpha) used in drawing to the specified percentage. Number must be between [0-100] inclusive.

g.alpha = ([NUMBER]/100);

Stroke

Set Stroke Color

set stroke color to color

Sets the stroke color used when drawing shapes (does not apply to fonts). You can select the color using the color picker, drag in a color attribute or drag in any block that returns a color.

g.strokeColor = [COLOR];

Set Stroke Thickness

set stroke thickness to int

Sets the stroke thickness (width) used when drawing shapes. Set to 0 to disable.

g.strokeSize = [INT];

Font Width

Get Width of Text for Current Font

get width for text using current font

Returns the width of the specified text using the current font. Useful for calculating text drawing positions. May only be used in a when drawing event.

g.font.font.getTextWidth([TEXT], g.font.letterSpacing)/Engine.SCALE

Get Width of Text for Specific Font

get width for text using font

Returns the width of the specified text using the given font. Useful for calculating text drawing positions.

[FONT].font.getTextWidth([TEXT], [FONT].letterSpacing)/Engine.SCALE

Font Height

Get Height for Current Font

get height using current font

Returns the height of text using the current font. Useful for calculating text drawing positions. May only be used in a when drawing event.

g.font.getHeight()/Engine.SCALE

Get Height for Specific Font

get height using font

Returns the height of text using the given font. Useful for calculating text drawing positions.

[FONT].getHeight()/Engine.SCALE