Draw

Functions for drawing shapes and primitives on a canvas.


Point

point(point: Vec2, color: Color) None

Draws 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) None

Batch 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) None

Batch 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) None

Draws 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) None

Draws 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.

Rect

rect(rect: Rect, color: Color, thickness: int = 0) None

Draws 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) None

Batch 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) None

Draws 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).