draw2d
A collection of 2D drawing functions that operate in screen space. Provides primitives for lines, rectangles, text, sprite drawing, etc.
point(pos, size, color) function
pos: A 2D position ([x, y]) where the point should be drawn.
size: The size of the point (not currently affecting rendering).
color: The color of the point, defaults to Color.blue.
Returns: None
line(points, color, thickness, pipeline) function
points: An array of 2D positions representing the line vertices.
color: The color of the line, default Color.white.
thickness: The line thickness, default 1.
pipeline: (Optional) A pipeline or rendering state object.
Returns: None
cross(pos, size, color, thickness, pipe) function
pos: The center of the cross as a 2D position ([x, y]).
size: Half the size of each cross arm.
color: The color of the cross, default Color.red.
thickness: The thickness of each line, default 1.
pipe: (Optional) A pipeline or rendering state object.
Returns: None
arrow(start, end, color, wingspan, wingangle, pipe) function
start: The start position of the arrow ([x, y]).
end: The end (tip) position of the arrow ([x, y]).
color: The color, default Color.red.
wingspan: The length of each arrowhead 'wing', default 4.
wingangle: Wing rotation in degrees, default 10.
pipe: (Optional) A pipeline or rendering state object.
Returns: None
rectangle(rect, color, pipeline) function
rect: A rectangle object with {x, y, width, height}.
color: The fill color, default Color.white.
pipeline: (Optional) A pipeline or rendering state object.
Returns: None
tile(image, rect, color, tile, pipeline) function
:raises Error: If no image is provided.
image: An image object or string path to a texture.
rect: A rectangle specifying draw location/size ({x, y, width, height}).
color: The color tint, default Color.white.
tile: A tiling definition ({repeat_x, repeat_y}), default tile_def.
pipeline: (Optional) A pipeline or rendering state object.
Returns: None
slice9(image, rect, slice, color, info, pipeline) function
:raises Error: If no image is provided.
image: An image object or string path to a texture.
rect: A rectangle specifying draw location/size, default [0, 0].
slice: The pixel inset or spacing for the 9-slice (number or object).
color: The color tint, default Color.white.
info: A slice9 info object controlling tiling of edges/corners.
pipeline: (Optional) A pipeline or rendering state object.
Returns: None
image(image, rect, rotation, color, pipeline) function
:raises Error: If no image is provided.
image: An image object or string path to a texture.
rect: A rectangle specifying draw location/size, default [0,0]; width/height default to image size.
rotation: Rotation in degrees (not currently used).
color: The color tint, default none.
pipeline: (Optional) A pipeline or rendering state object.
Returns: A sprite object that was created for this draw call.
images(image, rects, config) function
:raises Error: If no image is provided.
image: An image object or string path to a texture.
rects: An array of rectangle objects ({x, y, width, height}) to draw.
config: (Unused) Additional config data if needed.
Returns: An array of sprite objects created and queued for rendering.
sprites(sprites, sort, pipeline) function
sprites: An array of sprite objects to draw.
sort: Sorting mode or order, default 0.
pipeline: (Optional) A pipeline or rendering state object.
Returns: None
circle(pos, radius, color, inner_radius, pipeline) function
pos: Center of the circle ([x, y]).
radius: The circle radius.
color: The fill color of the circle, default none.
inner_radius: (Unused) Possibly ring thickness, default 1.
pipeline: (Optional) A pipeline or rendering state object.
Returns: None
text(text, rect, font, size, color, wrap, pipeline) function
text: The string to draw.
rect: A rectangle specifying draw position (and possibly wrapping area).
font: A font object or string path, default sysfont.
size: (Unused) Possibly intended for scaling the font size.
color: The text color, default Color.white.
wrap: Pixel width for text wrapping, default 0 (no wrap).
pipeline: (Optional) A pipeline or rendering state object.
Returns: None