Draw
Functions for drawing shape objects
Circle
circle(
circle: Circle,
color: Color,
thickness: SupportsFloat = 0,
num_segments: SupportsInt = 36
) → NoneDraw a circle to the renderer.
Args
circle: The circle to draw.color: The color of the circle.thickness: The line thickness. If <= 0 or >= radius, draws filled circle. Defaults to 0 (filled).num_segments: Number of segments to approximate the circle. Higher values yield smoother circles. Defaults to 36.
Circles
circles(
circles: Sequence[Circle],
color: Color,
thickness: SupportsFloat = 0,
num_segments: SupportsInt = 36
) → NoneDraw an array of circles in bulk to the renderer.
Args
circles: The circles to draw in bulk.color: The color of the circles.thickness: The line thickness. If <= 0 or >= radius, draws filled circle. Defaults to 0 (filled).num_segments: Number of segments to approximate each circle. Higher values yield smoother circles. Defaults to 36.
Ellipse
Draw an ellipse to the renderer.
Args
bounds: The bounding box of the ellipse.color: The color of the ellipse.filled: Whether to draw a filled ellipse or just the outline. Defaults to False (outline).
Geometry
Draw arbitrary geometry using vertices and optional indices.
Args
texture: The texture to apply to the geometry. Can be None.vertices: A list of Vertex objects.indices: A list of indices defining the primitives. If None or empty, vertices are drawn sequentially.
Line
Draw a line to the renderer.
Args
line: The line to draw.color: The color of the line.thickness: The line thickness in pixels. Defaults to 1.
Point
point(point: Vec2, color: Color) → NoneDraw a single point to the renderer.
Args
point: The position of the point.color: The color of the point.
Raises
RuntimeError: If point rendering fails.
Points
points(points: Sequence[Vec2], color: Color) → NoneBatch draw an array of points to the renderer.
Args
points: The points to batch draw.color: The color of the points.
Raises
RuntimeError: If point rendering fails.
Points From Ndarray
points_from_ndarray(
points: Annotated[numpy.ArrayLike, numpy.float64],
color: Color
) → NoneBatch draw points from a NumPy array.
This fast path accepts a contiguous NumPy array of shape (N,2) (dtype float64) and reads coordinates directly with minimal overhead. Use this to measure the best-case zero-copy/buffer-backed path.
Args
points: Array with shape (N,2) containing x,y coordinates.color: The color of the points.
Raises
ValueError: If the array shape is not (N,2).RuntimeError: If point rendering fails.
Polygon
Draw a polygon to the renderer.
Args
polygon: The polygon to draw.color: The color of the polygon.filled: Whether to draw a filled polygon or just the outline. Defaults to False (outline). Works with both convex and concave polygons.
Polygons
Draw an array of polygons in bulk to the renderer.
Args
polygons: The polygons to draw in bulk.color: The color of the polygons.filled: Whether to draw filled polygons or just the outlines. Defaults to True (filled). Works with both convex and concave polygons.
Rect
Draw a rectangle to the renderer.
Args
rect: The rectangle to draw.color: The color of the rectangle.thickness: The border thickness. If 0 or >= half width/height, draws filled rectangle. Defaults to 0 (filled).
Rects
Batch draw an array of rectangles to the renderer.
Args
rects: The rectangles to batch draw.color: The color of the rectangles.thickness: The border thickness of the rectangles. If 0 or >= half width/height, draws filled rectangles. Defaults to 0 (filled).