Arcade Game Development Library
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Comprehensive 2D drawing functions for creating visual elements in games and applications. Arcade provides both immediate-mode drawing for simple graphics and batch rendering for performance-critical applications.
Functions for drawing solid, filled geometric shapes with specified colors and positions.
def draw_circle_filled(center_x: float, center_y: float, radius: float, color: arcade.types.Color, num_segments: int = -1) -> None:
"""
Draw a filled circle.
Args:
center_x: X coordinate of circle center
center_y: Y coordinate of circle center
radius: Radius of the circle
color: Color as RGB or RGBA tuple (0-255)
num_segments: Number of segments to use for drawing (default auto-calculated)
"""
def draw_ellipse_filled(center_x: float, center_y: float, width: float, height: float, color: arcade.types.Color, tilt_angle: float = 0, num_segments: int = -1) -> None:
"""
Draw a filled ellipse.
Args:
center_x: X coordinate of ellipse center
center_y: Y coordinate of ellipse center
width: Width of the ellipse
height: Height of the ellipse
color: Color as RGB or RGBA tuple (0-255)
tilt_angle: Rotation angle in degrees
num_segments: Number of segments to use for drawing (default auto-calculated)
"""
def draw_arc_filled(center_x: float, center_y: float, width: float, height: float, color: arcade.types.Color, start_angle: float, end_angle: float, tilt_angle: float = 0, num_segments: int = 128) -> None:
"""
Draw a filled arc (pie slice).
Args:
center_x: X coordinate of arc center
center_y: Y coordinate of arc center
width: Width of the arc
height: Height of the arc
color: Color as RGB or RGBA tuple (0-255)
start_angle: Start angle in degrees
end_angle: End angle in degrees
tilt_angle: Rotation angle of the entire arc in degrees
num_segments: Number of segments to use for drawing
"""
def draw_parabola_filled(start_x: float, start_y: float, end_x: float, height: float, color: arcade.types.Color, tilt_angle: float = 0) -> None:
"""
Draw a filled parabola.
Args:
start_x: X coordinate of parabola start
start_y: Y coordinate of parabola start
end_x: X coordinate of parabola end
height: Height of the parabola
color: Color as RGB or RGBA tuple (0-255)
tilt_angle: Rotation angle in degrees
"""
def draw_triangle_filled(x1: float, y1: float, x2: float, y2: float, x3: float, y3: float, color: arcade.types.Color) -> None:
"""
Draw a filled triangle.
Args:
x1, y1: First vertex coordinates
x2, y2: Second vertex coordinates
x3, y3: Third vertex coordinates
color: Color as RGB or RGBA tuple (0-255)
"""
def draw_polygon_filled(point_list: arcade.types.PointList, color: arcade.types.Color) -> None:
"""
Draw a filled polygon.
Args:
point_list: List of (x, y) coordinate tuples defining polygon vertices
color: Color as RGB or RGBA tuple (0-255)
"""
def draw_rectangle_filled(center_x: float, center_y: float, width: float, height: float, color: arcade.types.Color, tilt_angle: float = 0) -> None:
"""
Draw a filled rectangle.
Args:
center_x: X coordinate of rectangle center
center_y: Y coordinate of rectangle center
width: Width of the rectangle
height: Height of the rectangle
color: Color as RGB or RGBA tuple (0-255)
tilt_angle: Rotation angle in degrees
"""
def draw_lrbt_rectangle_filled(left: float, right: float, bottom: float, top: float, color: arcade.types.Color) -> None:
"""
Draw a filled rectangle using left, right, bottom, top coordinates.
Args:
left: Left edge X coordinate
right: Right edge X coordinate
bottom: Bottom edge Y coordinate
top: Top edge Y coordinate
color: Color as RGB or RGBA tuple (0-255)
"""
def draw_lbwh_rectangle_filled(left: float, bottom: float, width: float, height: float, color: arcade.types.Color) -> None:
"""
Draw a filled rectangle using left, bottom, width, height.
Args:
left: Left edge X coordinate
bottom: Bottom edge Y coordinate
width: Width of the rectangle
height: Height of the rectangle
color: Color as RGB or RGBA tuple (0-255)
"""Functions for drawing shape outlines and borders with configurable line widths and styles.
def draw_circle_outline(center_x: float, center_y: float, radius: float, color: arcade.types.Color, border_width: float = 1, num_segments: int = -1) -> None:
"""
Draw a circle outline.
Args:
center_x: X coordinate of circle center
center_y: Y coordinate of circle center
radius: Radius of the circle
color: Color as RGB or RGBA tuple (0-255)
border_width: Width of the outline in pixels
num_segments: Number of segments to use for drawing (default auto-calculated)
"""
def draw_ellipse_outline(center_x: float, center_y: float, width: float, height: float, color: arcade.types.Color, border_width: float = 1, tilt_angle: float = 0, num_segments: int = -1) -> None:
"""
Draw an ellipse outline.
Args:
center_x: X coordinate of ellipse center
center_y: Y coordinate of ellipse center
width: Width of the ellipse
height: Height of the ellipse
color: Color as RGB or RGBA tuple (0-255)
border_width: Width of the outline in pixels
tilt_angle: Rotation angle in degrees
num_segments: Number of segments to use for drawing (default auto-calculated)
"""
def draw_arc_outline(center_x: float, center_y: float, width: float, height: float, color: arcade.types.Color, start_angle: float, end_angle: float, border_width: float = 1, tilt_angle: float = 0, num_segments: int = 128) -> None:
"""
Draw an arc outline.
Args:
center_x: X coordinate of arc center
center_y: Y coordinate of arc center
width: Width of the arc
height: Height of the arc
color: Color as RGB or RGBA tuple (0-255)
start_angle: Start angle in degrees
end_angle: End angle in degrees
border_width: Width of the outline in pixels
tilt_angle: Rotation angle of the entire arc in degrees
num_segments: Number of segments to use for drawing
"""
def draw_parabola_outline(start_x: float, start_y: float, end_x: float, height: float, color: arcade.types.Color, border_width: float = 1, tilt_angle: float = 0) -> None:
"""
Draw a parabola outline.
Args:
start_x: X coordinate of parabola start
start_y: Y coordinate of parabola start
end_x: X coordinate of parabola end
height: Height of the parabola
color: Color as RGB or RGBA tuple (0-255)
border_width: Width of the outline in pixels
tilt_angle: Rotation angle in degrees
"""
def draw_triangle_outline(x1: float, y1: float, x2: float, y2: float, x3: float, y3: float, color: arcade.types.Color, border_width: float = 1) -> None:
"""
Draw a triangle outline.
Args:
x1, y1: First vertex coordinates
x2, y2: Second vertex coordinates
x3, y3: Third vertex coordinates
color: Color as RGB or RGBA tuple (0-255)
border_width: Width of the outline in pixels
"""
def draw_polygon_outline(point_list: arcade.types.PointList, color: arcade.types.Color, border_width: float = 1) -> None:
"""
Draw a polygon outline.
Args:
point_list: List of (x, y) coordinate tuples defining polygon vertices
color: Color as RGB or RGBA tuple (0-255)
border_width: Width of the outline in pixels
"""
def draw_rectangle_outline(center_x: float, center_y: float, width: float, height: float, color: arcade.types.Color, border_width: float = 1, tilt_angle: float = 0) -> None:
"""
Draw a rectangle outline.
Args:
center_x: X coordinate of rectangle center
center_y: Y coordinate of rectangle center
width: Width of the rectangle
height: Height of the rectangle
color: Color as RGB or RGBA tuple (0-255)
border_width: Width of the outline in pixels
tilt_angle: Rotation angle in degrees
"""
def draw_lrbt_rectangle_outline(left: float, right: float, bottom: float, top: float, color: arcade.types.Color, border_width: float = 1) -> None:
"""
Draw a rectangle outline using left, right, bottom, top coordinates.
Args:
left: Left edge X coordinate
right: Right edge X coordinate
bottom: Bottom edge Y coordinate
top: Top edge Y coordinate
color: Color as RGB or RGBA tuple (0-255)
border_width: Width of the outline in pixels
"""
def draw_lbwh_rectangle_outline(left: float, bottom: float, width: float, height: float, color: arcade.types.Color, border_width: float = 1) -> None:
"""
Draw a rectangle outline using left, bottom, width, height.
Args:
left: Left edge X coordinate
bottom: Bottom edge Y coordinate
width: Width of the rectangle
height: Height of the rectangle
color: Color as RGB or RGBA tuple (0-255)
border_width: Width of the outline in pixels
"""Functions for drawing lines, line strips, and individual points for creating linear graphics and debug visualization.
def draw_line(start_x: float, start_y: float, end_x: float, end_y: float, color: arcade.types.Color, line_width: float = 1) -> None:
"""
Draw a single line between two points.
Args:
start_x: X coordinate of line start
start_y: Y coordinate of line start
end_x: X coordinate of line end
end_y: Y coordinate of line end
color: Color as RGB or RGBA tuple (0-255)
line_width: Width of the line in pixels
"""
def draw_lines(point_list: arcade.types.PointList, color: arcade.types.Color, line_width: float = 1) -> None:
"""
Draw multiple separate line segments.
Args:
point_list: List of (x, y) coordinates. Must have even number of points.
Each pair defines start and end of a line segment.
color: Color as RGB or RGBA tuple (0-255)
line_width: Width of the lines in pixels
"""
def draw_line_strip(point_list: arcade.types.PointList, color: arcade.types.Color, line_width: float = 1) -> None:
"""
Draw connected line segments (line strip).
Args:
point_list: List of (x, y) coordinates defining connected line segments
color: Color as RGB or RGBA tuple (0-255)
line_width: Width of the lines in pixels
"""
def draw_point(x: float, y: float, color: arcade.types.Color, size: float = 1) -> None:
"""
Draw a single point.
Args:
x: X coordinate of the point
y: Y coordinate of the point
color: Color as RGB or RGBA tuple (0-255)
size: Size of the point in pixels
"""
def draw_points(point_list: arcade.types.PointList, color: arcade.types.Color, size: float = 1) -> None:
"""
Draw multiple points.
Args:
point_list: List of (x, y) coordinate tuples defining point positions
color: Color as RGB or RGBA tuple (0-255)
size: Size of the points in pixels
"""Functions for drawing textures and sprites with support for transformations, tinting, and rectangular regions.
def draw_texture_rect(texture: arcade.Texture, rect: arcade.types.Rect, alpha: int = 255, angle: float = 0, repeat_count_x: int = 1, repeat_count_y: int = 1) -> None:
"""
Draw a texture in a rectangular area.
Args:
texture: Texture to draw
rect: Rectangle defining drawing area (x, y, width, height)
alpha: Transparency (0-255, where 255 is fully opaque)
angle: Rotation angle in degrees
repeat_count_x: Number of times to repeat texture horizontally
repeat_count_y: Number of times to repeat texture vertically
"""
def draw_sprite(sprite: arcade.Sprite) -> None:
"""
Draw an individual sprite.
Args:
sprite: Sprite object to draw
"""
def draw_sprite_rect(sprite: arcade.Sprite, rect: arcade.types.Rect) -> None:
"""
Draw a sprite in a specified rectangular area.
Args:
sprite: Sprite object to draw
rect: Rectangle defining drawing area (x, y, width, height)
"""Utility functions for advanced line drawing and shape generation.
def get_points_for_thick_line(start_x: float, start_y: float, end_x: float, end_y: float, line_width: float) -> arcade.types.PointList:
"""
Generate points for drawing a thick line as a polygon.
Args:
start_x: X coordinate of line start
start_y: Y coordinate of line start
end_x: X coordinate of line end
end_y: Y coordinate of line end
line_width: Width of the line
Returns:
List of (x, y) points defining the thick line polygon
"""Functions for capturing screen content and reading pixel data.
def get_image(x: int = 0, y: int = 0, width: int = None, height: int = None) -> PIL.Image.Image:
"""
Capture screen content as an image.
Args:
x: Left coordinate of capture area (default 0)
y: Bottom coordinate of capture area (default 0)
width: Width of capture area (default full window width)
height: Height of capture area (default full window height)
Returns:
PIL Image object containing captured screen data
"""
def get_pixel(x: int, y: int) -> tuple[int, int, int]:
"""
Get the color of a pixel at specific coordinates.
Args:
x: X coordinate of the pixel
y: Y coordinate of the pixel
Returns:
RGB color tuple (red, green, blue) with values 0-255
"""Functions for managing the rendering pipeline and background settings.
def start_render() -> None:
"""
Begin rendering a frame. Must be called before drawing operations.
"""
def finish_render() -> None:
"""
Complete rendering a frame. Must be called after all drawing operations.
"""
def set_background_color(color: arcade.types.Color) -> None:
"""
Set the window background color.
Args:
color: Background color as RGB or RGBA tuple (0-255)
"""import arcade
# Open a window
arcade.open_window(800, 600, "Shape Drawing")
arcade.set_background_color(arcade.color.WHITE)
arcade.start_render()
# Draw filled shapes
arcade.draw_circle_filled(100, 100, 50, arcade.color.RED)
arcade.draw_rectangle_filled(300, 100, 80, 120, arcade.color.BLUE)
arcade.draw_triangle_filled(500, 50, 450, 150, 550, 150, arcade.color.GREEN)
# Draw outlines
arcade.draw_circle_outline(100, 300, 50, arcade.color.BLACK, 3)
arcade.draw_rectangle_outline(300, 300, 80, 120, arcade.color.BLACK, 2)
# Draw lines and points
arcade.draw_line(50, 500, 150, 500, arcade.color.PURPLE, 5)
arcade.draw_points([(200, 500), (220, 520), (240, 500), (260, 520)],
arcade.color.ORANGE, 8)
arcade.finish_render()
arcade.run()import arcade
import math
def create_star_points(center_x, center_y, outer_radius, inner_radius, points=5):
"""Generate points for a star polygon."""
point_list = []
for i in range(points * 2):
angle = math.radians(i * 180 / points)
radius = outer_radius if i % 2 == 0 else inner_radius
x = center_x + radius * math.cos(angle)
y = center_y + radius * math.sin(angle)
point_list.append((x, y))
return point_list
arcade.open_window(400, 400, "Star Polygon")
arcade.set_background_color(arcade.color.BLACK)
arcade.start_render()
# Draw a filled star
star_points = create_star_points(200, 200, 100, 50)
arcade.draw_polygon_filled(star_points, arcade.color.YELLOW)
# Draw star outline
arcade.draw_polygon_outline(star_points, arcade.color.RED, 3)
arcade.finish_render()
arcade.run()Install with Tessl CLI
npx tessl i tessl/pypi-arcade