Draw
Functions for drawing shapes and primitives on a canvas.
Point
point(point: Vec2, color: Color) → NoneDraws a point at the specified coordinates with the given color.
Parameters
point: The coordinates of the point to be drawn.color: The color of the point.
Points
points(points: Sequence[Vec2], color: Color) → NoneBatch draws multiple points at the specified coordinates with the given color.
Parameters
points: A sequence of coordinates where points will be drawn.color: The color of the points.
Points From NDArray
points_from_ndarray(points: numpy.ndarray, color: Color) → NoneBatch draws multiple points from a NumPy ndarray of coordinates with the given color.
Parameters
points: An ndarray of shape (N, 2) containing point coordinates.color: The color of the points.
Circle
circle(circle: Circle, color: Color, thickness: int = 0) → NoneDraws a circle at the specified center with the given radius, color, and optional outline thickness.
Parameters
circle: The circle to be drawn, including center and radius.color: The color of the circle.thickness: The thickness of the circle's outline. Defaults to 0 (filled).
Line
line(line: Line, color: Color, thickness: int = 1) → NoneDraws a line segment between two points with the given color and optional thickness.
Parameters
line: The line segment to be drawn, including start and end points.color: The color of the line.thickness: The thickness of the line. Defaults to 1.
Ellipse
ellipse(bounds: Rect, color: Color, filled: bool = false) → NoneDraws an ellipse within the specified bounding rectangle with the given color and optional fill.
Parameters
bounds: The bounding rectangle for the ellipse.color: The color of the ellipse.filled: Whether to fill the ellipse. Defaults to false (outline only).
Rect
rect(rect: Rect, color: Color, thickness: int = 0) → NoneDraws a rectangle at the specified position with the given size, color, and optional outline thickness.
Parameters
rect: The rectangle to be drawn, including position and size.color: The color of the rectangle.thickness: The thickness of the rectangle's outline. Defaults to 0 (filled).
Rects
rects(rects: Sequence[Rect], color: Color, thickness: int = 0) → NoneBatch draws multiple rectangles at the specified positions with the given sizes, color, and optional outline thickness.
Parameters
rects: A sequence of rectangles to be drawn, each including position and size.color: The color of the rectangles.thickness: The thickness of the rectangles' outlines. Defaults to 0 (filled).
Polygon
polygon(polygon: Polygon, color: Color, filled: bool = false) → NoneDraws a polygon defined by a sequence of points with the given color and optional fill.
Parameters
polygon: The polygon to be drawn, defined by its vertices.color: The color of the polygon.filled: Whether to fill the polygon. Defaults to false (outline only).