✏️Layer
A layer is a type that is used to store render commands, as well as vertex and index data. This is the only way to push shapes and control rendering state.
g
FieldRead only
Type: command
The next render command to be pushed to the queue. This is the object you want to change to, for example, set a texture, or change rendering modes.
font
Field
Type: font_base
Font to use with add_text. If nothing has been set, no text will get rendered.
tex_sz
Field
Type: vec2?
Texture dimensions. This value is only required if you are trying to render rounded shapes with a texture, so the rendering system will correctly map your UV coordinates to whatever shape you are rendering.
skip_dpi
Field
Type: bool
If set to true, will skip global DPI scale. Defaults to true.
add_triangle_filled
Method
Adds a filled triangle with a single color.
Arguments
Returns
Nothing.
Example
layer:add_triangle_filled(
draw.vec2(50, 50), draw.vec2(25, 75),
draw.vec2(75, 75), draw.color(255, 255, 255));add_quad_filled
Method
Adds a filled quad with a single color.
Arguments
Returns
Nothing.
Example
layer:add_quad_filled(
draw.vec2(50, 50), draw.vec2(100, 60),
draw.vec2(100, 100), draw.vec2(30, 70),
draw.color(255, 255, 255));add_rect_filled
Method
Adds a filled rectangle with a single color.
Arguments
Returns
Nothing.
Example
layer:add_rect_filled(draw.rect(50, 50, 150, 150), draw.color(255, 255, 255));add_circle_filled
Method
Adds a filled circle with a single color.
Arguments
Returns
Nothing.
Example
layer:add_circle_filled(draw.vec2(50, 50), 10, draw.color(255, 255, 255));add_triangle_filled_multicolor
Method
Adds a filled, multicolor triangle.
Arguments
Returns
Nothing.
Example
layer:add_triangle_filled_multicolor(
draw.vec2(50, 50), draw.vec2(25, 75),
draw.vec2(75, 75), {
draw.color(255, 0, 0),
draw.color(0, 255, 0),
draw.color(0, 0, 255)
});add_rect_filled_multicolor
Method
Adds a filled, multicolor rectangle.
Arguments
Name
Type
Description
cols
table[color, color, color, color]
Colors for each corner of the rectangle, in clockwise order starting from top-left.
Returns
Nothing.
Example
layer:add_rect_filled_multicolor(
draw.rect(50, 50, 150, 150), {
draw.color(255, 0, 0),
draw.color(0, 255, 0),
draw.color(0, 0, 255),
draw.color(255, 255, 0)
});add_circle_filled_multicolor
Method
Adds a filled, multicolor circle.
Arguments
Name
Type
Description
radius
float
Circle radius.
cols
table[color, color]
Colors for the gradient, starting with the inner and ending with the outer color.
segments
int
The number of segments to approximate the circle. Defaults to 36.
fill
float
The portion of the circle to fill, where 1.0 is a full circle. Defaults to 1.0.
Returns
Nothing.
Example
layer:add_circle_filled_multicolor(
draw.vec2(100, 100), 50, {
draw.color(255, 0, 0),
draw.color(0, 0, 255)
}, 36, 1.0);add_quad_filled_multicolor
Method
Adds a filled, multicolor quad.
Arguments
Returns
Nothing.
Example
layer:add_quad_filled_multicolor(
draw.vec2(50, 50), draw.vec2(150, 50),
draw.vec2(150, 150), draw.vec2(50, 150), {
draw.color(255, 0, 0),
draw.color(0, 0, 255)
});add_pill_multicolor
Method
Adds a multicolor pill shape.
Arguments
Name
Type
Description
radius_min
float
The minimum radius of the pill's rounded edges.
radius_max
float
The maximum radius of the pill's rounded edges.
cols
table[color, color]
Colors for the gradient, applied from bottom to top.
segments
int
The number of segments for approximating rounded edges. Defaults to 16.
Returns
Nothing.
Example
layer:add_pill_multicolor(
draw.vec2(50, 50), draw.vec2(150, 100),
10, 20, {
draw.color(255, 0, 0),
draw.color(0, 0, 255)
}, 16);add_shadow_line
Method
Adds a shadow line.
Arguments
Name
Type
Description
a
float
Max opacity. Defaults to 0.25.
Returns
Nothing.
Example
layer:add_shadow_line(
draw.rect(50, 50, 150, 150), draw.shadow_dir.down, 0.25);add_shadow_rect
Method
Adds a shadowed rectangle.
Arguments
Name
Type
Description
radius
float
Shadow distance, in pixels, outwards.
bg
bool
Whether to draw a background for the rectangle. Defaults to true.
a
float
Max opacity of the shadow. Defaults to 0.25.
Returns
Nothing.
Example
layer:add_shadow_rect(
draw.rect(50, 50, 150, 150), 15, true, 0.25);add_glow
Method
Adds a glow box.
Arguments
Name
Type
Description
radius
float
Glow distance, in pixels, outwards.
Returns
Nothing.
Example
layer:add_glow(draw.rect(50, 50, 150, 150), 15, draw.color(255, 0, 0));add_rect_filled_rounded
Method
Adds a filled, rounded rectangle.
Arguments
Returns
Nothing.
Example
layer:add_rect_filled_rounded(
draw.rect(50, 50, 150, 150),
draw.color(255, 0, 0),
10,
draw.rounding.all
);add_rect_filled_rounded_multicolor
Method
Adds a filled, multicolor rounded rectangle.
Arguments
Returns
Nothing.
Example
layer:add_rect_filled_rounded_multicolor(
draw.rect(50, 50, 150, 150), {
draw.color(255, 0, 0),
draw.color(0, 255, 0),
draw.color(0, 0, 255),
draw.color(255, 255, 0)
},
10,
draw.rounding.all
);add_triangle
Method
Adds a stroked triangle.
Arguments
Name
Type
Description
thickness
float
Line thickness. Defaults to 1.0.
Returns
Nothing.
Example
layer:add_triangle(
draw.vec2(50, 50),
draw.vec2(25, 75),
draw.vec2(75, 75),
draw.color(255, 0, 0),
1.0,
draw.outline_mode.inset
);add_quad
Method
Adds a stroked quad.
Arguments
Returns
Nothing.
Example
layer:add_quad(
draw.vec2(50, 50),
draw.vec2(150, 50),
draw.vec2(150, 150),
draw.vec2(50, 150),
draw.color(255, 0, 0),
1.0,
draw.outline_mode.inset
);add_rect
Method
Adds a stroked rectangle.
Arguments
Name
Type
Description
thickness
float
Line thickness. Defaults to 1.0.
Returns
Nothing.
Example
layer:add_rect(
draw.rect(50, 50, 150, 150),
draw.color(255, 0, 0),
1.0,
draw.outline_mode.inset
);add_circle
Method
Adds a stroked circle.
Arguments
Name
Type
Description
radius
float
Circle radius.
segments
int
Circle segments. Defaults to 36.
fill
float
Fill amount. Defaults to 1.0.
thickness
float
Line thickness. Defaults to 1.0.
Returns
Nothing.
Example
layer:add_circle(
draw.vec2(100, 100),
50,
draw.color(255, 0, 0),
36,
1.0,
1.0,
draw.outline_mode.inset
);add_line
Method
Adds a line.
Arguments
Returns
Nothing.
Example
layer:add_line(
draw.vec2(50, 50),
draw.vec2(150, 150),
draw.color(255, 0, 0)
);add_line_multicolor
Method
Adds a multicolor line.
Arguments
Returns
Nothing.
Example
layer:add_line_multicolor(
draw.vec2(50, 50),
draw.vec2(150, 150),
draw.color(255, 0, 0),
draw.color(0, 0, 255),
2.0
);add_rect_rounded
Method
Adds a rounded, filled rectangle.
Arguments
Name
Type
Description
amount
float
Rounding amount.
thickness
float
Line thickness. Defaults to 1.0.
Returns
Nothing.
Example
layer:add_rect_rounded(draw.rect(50, 50, 150, 150),
draw.color(255, 255, 255), 14);add_text
Method
Adds text.
Arguments
Name
Type
Description
text
string
Text.
Returns
Nothing.
Example
layer:add_text(draw.vec2(50, 50), 'Hello world!', draw.color(255, 255, 255));override_clip_rect
Method
Overrides clip rectangle with support of intersection.
Arguments
Name
Type
Description
intersect
bool
Whether this function should intersect previous rect with the new one. Defaults to true.
Returns
Nothing.
Example
layer:override_clip_rect(draw.rect(50, 50, 150, 150));Last updated