Python API

Drawing operations

Object-oriented and module-level shape, text, polygon, and blit operations.

Source snapshot: df47b3926b7c52e7f62eddbbf9dc618d6bbd6b6a.

Object-oriented and module-level shape, text, polygon, and blit operations.

Every entry below is generated from a public binding table or header declaration and links to its immutable source line.

graphics.Draw

class Draw(canvas)

Drawing facade that adds a bounded clip stack to any compatible canvas.

View the pinned source declaration

graphics.Draw.fill

Draw.fill(color)

Fill the target canvas with one color and return the affected Area.

View the pinned source declaration

graphics.Draw.fill_rect

Draw.fill_rect(x, y, width, height, color)

Fill a rectangular region and return the clipped affected Area.

View the pinned source declaration

graphics.Draw.pixel

Draw.pixel(x, y, color=None)

Read or write one pixel, depending on whether a color is supplied.

View the pinned source declaration

graphics.Draw.hline

Draw.hline(x, y, width, color)

Draw a horizontal line.

View the pinned source declaration

graphics.Draw.vline

Draw.vline(x, y, height, color)

Draw a vertical line.

View the pinned source declaration

graphics.Draw.line

Draw.line(x1, y1, x2, y2, color)

Draw a line between two points.

View the pinned source declaration

graphics.Draw.rect

Draw.rect(x, y, width, height, color, fill=False)

Draw an outlined or filled rectangle.

View the pinned source declaration

graphics.Draw.round_rect

Draw.round_rect(x, y, width, height, radius, color, fill=False)

Draw an outlined or filled rounded rectangle.

View the pinned source declaration

graphics.Draw.circle

Draw.circle(x, y, radius, color, fill=False)

Draw an outlined or filled circle.

View the pinned source declaration

graphics.Draw.ellipse

Draw.ellipse(x, y, x_radius, y_radius, color, fill=False, mask=0x0F)

Draw selected quadrants of an outlined or filled ellipse.

View the pinned source declaration

graphics.Draw.arc

Draw.arc(x, y, radius, start_angle, end_angle, color)

Draw a circular arc between two angles.

View the pinned source declaration

graphics.Draw.triangle

Draw.triangle(x0, y0, x1, y1, x2, y2, color, fill=False)

Draw an outlined or filled triangle.

View the pinned source declaration

graphics.Draw.gradient_rect

Draw.gradient_rect(x, y, width, height, color1, color2=None, vertical=True)

Fill a rectangle with a horizontal or vertical color gradient.

View the pinned source declaration

graphics.Draw.poly

Draw.poly(x, y, coordinates, color, fill=False)

Draw a polygon from a packed coordinate buffer.

View the pinned source declaration

graphics.Draw.polygon

Draw.polygon(points, x, y, color, angle=0, center_x=0, center_y=0)

Draw a translated and optionally rotated sequence of points.

View the pinned source declaration

graphics.Draw.blit

Draw.blit(source, x, y, key=-1, palette=None)

Copy another framebuffer onto the target with optional keying and palette lookup.

View the pinned source declaration

graphics.Draw.blit_rect

Draw.blit_rect(buffer, x, y, width, height)

Copy a packed RGB565 rectangle onto the target.

View the pinned source declaration

graphics.Draw.blit_transparent

Draw.blit_transparent(buffer, x, y, width, height, key)

Copy a packed RGB565 rectangle while skipping the transparent key.

View the pinned source declaration

graphics.Draw.text

Draw.text(text, x, y, color=1, scale=1, inverted=False, font_data=None, height=8)

Render bitmap text with selectable height, scale, and inversion.

View the pinned source declaration

graphics.Draw.text8

Draw.text8(text, x, y, color=1, scale=1, inverted=False, font_data=None)

Render text with the built-in 8-pixel-high font path.

View the pinned source declaration

graphics.Draw.text14

Draw.text14(text, x, y, color=1, scale=1, inverted=False, font_data=None)

Render text with the built-in 14-pixel-high font path.

View the pinned source declaration

graphics.Draw.text16

Draw.text16(text, x, y, color=1, scale=1, inverted=False, font_data=None)

Render text with the built-in 16-pixel-high font path.

View the pinned source declaration

graphics.Draw.clip

Draw.clip(area_or_x, y=None, width=None, height=None)

Return the intersection with another Area.

View the pinned source declaration

graphics.fill

graphics.fill(canvas, color)

Fill the target canvas with one color and return the affected Area.

View the pinned source declaration

graphics.fill_rect

graphics.fill_rect(canvas, x, y, width, height, color)

Fill a rectangular region and return the clipped affected Area.

View the pinned source declaration

graphics.pixel

graphics.pixel(canvas, x, y, color=None)

Read or write one pixel, depending on whether a color is supplied.

View the pinned source declaration

graphics.hline

graphics.hline(canvas, x, y, width, color)

Draw a horizontal line.

View the pinned source declaration

graphics.vline

graphics.vline(canvas, x, y, height, color)

Draw a vertical line.

View the pinned source declaration

graphics.line

graphics.line(canvas, x1, y1, x2, y2, color)

Draw a line between two points.

View the pinned source declaration

graphics.rect

graphics.rect(canvas, x, y, width, height, color, fill=False)

Draw an outlined or filled rectangle.

View the pinned source declaration

graphics.round_rect

graphics.round_rect(canvas, x, y, width, height, radius, color, fill=False)

Draw an outlined or filled rounded rectangle.

View the pinned source declaration

graphics.circle

graphics.circle(canvas, x, y, radius, color, fill=False)

Draw an outlined or filled circle.

View the pinned source declaration

graphics.ellipse

graphics.ellipse(canvas, x, y, x_radius, y_radius, color, fill=False, mask=0x0F)

Draw selected quadrants of an outlined or filled ellipse.

View the pinned source declaration

graphics.arc

graphics.arc(canvas, x, y, radius, start_angle, end_angle, color)

Draw a circular arc between two angles.

View the pinned source declaration

graphics.triangle

graphics.triangle(canvas, x0, y0, x1, y1, x2, y2, color, fill=False)

Draw an outlined or filled triangle.

View the pinned source declaration

graphics.gradient_rect

graphics.gradient_rect(canvas, x, y, width, height, color1, color2=None, vertical=True)

Fill a rectangle with a horizontal or vertical color gradient.

View the pinned source declaration

graphics.poly

graphics.poly(canvas, x, y, coordinates, color, fill=False)

Draw a polygon from a packed coordinate buffer.

View the pinned source declaration

graphics.blit

graphics.blit(canvas, source, x, y, key=-1, palette=None)

Copy another framebuffer onto the target with optional keying and palette lookup.

View the pinned source declaration

graphics.blit_rect

graphics.blit_rect(canvas, buffer, x, y, width, height)

Copy a packed RGB565 rectangle onto the target.

View the pinned source declaration

graphics.blit_transparent

graphics.blit_transparent(canvas, buffer, x, y, width, height, key)

Copy a packed RGB565 rectangle while skipping the transparent key.

View the pinned source declaration

graphics.polygon

graphics.polygon(canvas, points, x, y, color, angle=0, center_x=0, center_y=0)

Draw a translated and optionally rotated sequence of points.

View the pinned source declaration

graphics.text

graphics.text(canvas, text, x, y, color=1, scale=1, inverted=False, font_data=None, height=8)

Render bitmap text with selectable height, scale, and inversion.

View the pinned source declaration

graphics.text8

graphics.text8(canvas, text, x, y, color=1, scale=1, inverted=False, font_data=None)

Render text with the built-in 8-pixel-high font path.

View the pinned source declaration

graphics.text14

graphics.text14(canvas, text, x, y, color=1, scale=1, inverted=False, font_data=None)

Render text with the built-in 14-pixel-high font path.

View the pinned source declaration

graphics.text16

graphics.text16(canvas, text, x, y, color=1, scale=1, inverted=False, font_data=None)

Render text with the built-in 16-pixel-high font path.

View the pinned source declaration