Drawing - Primitives

arcade.draw_commands.get_points_for_thick_line(start_x: float, start_y: float, end_x: float, end_y: float, line_width: float) Tuple[Tuple[float | int, float | int] | Vec2, Tuple[float | int, float | int] | Vec2, Tuple[float | int, float | int] | Vec2, Tuple[float | int, float | int] | Vec2][source]

Function used internally for Arcade. OpenGL draws triangles only, so a thick line must be two triangles that make up a rectangle. This calculates and returns those points.

arcade.draw_commands.draw_arc_filled(center_x: float, center_y: float, width: float, height: float, color: Tuple[int, int, int, int], start_angle: float, end_angle: float, tilt_angle: float = 0, num_segments: int = 128)[source]

Draw a filled in arc. Useful for drawing pie-wedges, or Pac-Man.

Parameters:
  • center_x – x position that is the center of the arc.

  • center_y – y position that is the center of the arc.

  • width – width of the arc.

  • height – height of the arc.

  • color – A 3 or 4 length tuple of 0-255 channel values or a Color instance.

  • start_angle – start angle of the arc in degrees.

  • end_angle – end angle of the arc in degrees.

  • tilt_angle – angle the arc is tilted (clockwise).

  • num_segments – Number of line segments used to draw arc.

arcade.draw_commands.draw_arc_outline(center_x: float, center_y: float, width: float, height: float, color: Tuple[int, int, int, int], start_angle: float, end_angle: float, border_width: float = 1, tilt_angle: float = 0, num_segments: int = 128)[source]

Draw the outside edge of an arc. Useful for drawing curved lines.

Parameters:
  • center_x – x position that is the center of the arc.

  • center_y – y position that is the center of the arc.

  • width – width of the arc.

  • height – height of the arc.

  • color – A 3 or 4 length tuple of 0-255 channel values or a Color instance.

  • start_angle – start angle of the arc in degrees.

  • end_angle – end angle of the arc in degrees.

  • border_width – width of line in pixels.

  • tilt_angle – angle the arc is tilted (clockwise).

  • num_segments – float of triangle segments that make up this circle. Higher is better quality, but slower render time.

arcade.draw_commands.draw_parabola_filled(start_x: float, start_y: float, end_x: float, height: float, color: Tuple[int, int, int, int], tilt_angle: float = 0)[source]

Draws a filled in parabola.

Parameters:
  • start_x – The starting x position of the parabola

  • start_y – The starting y position of the parabola

  • end_x – The ending x position of the parabola

  • height – The height of the parabola

  • color – A 3 or 4 length tuple of 0-255 channel values or a Color instance.

  • tilt_angle – The angle of the tilt of the parabola (clockwise)

arcade.draw_commands.draw_parabola_outline(start_x: float, start_y: float, end_x: float, height: float, color: Tuple[int, int, int, int], border_width: float = 1, tilt_angle: float = 0)[source]

Draws the outline of a parabola.

Parameters:
  • start_x – The starting x position of the parabola

  • start_y – The starting y position of the parabola

  • end_x – The ending x position of the parabola

  • height – The height of the parabola

  • color – A 3 or 4 length tuple of 0-255 channel values or a Color instance.

  • border_width – The width of the parabola

  • tilt_angle – The angle of the tilt of the parabola (clockwise)

arcade.draw_commands.draw_circle_filled(center_x: float, center_y: float, radius: float, color: Tuple[int, int, int, int], tilt_angle: float = 0, num_segments: int = -1)[source]

Draw a filled-in circle.

Parameters:
  • center_x – x position that is the center of the circle.

  • center_y – y position that is the center of the circle.

  • radius – width of the circle.

  • color – A 3 or 4 length tuple of 0-255 channel values or a Color instance.

  • tilt_angle – Angle in degrees to tilt the circle. Useful for low segment count circles

  • num_segments – Number of triangle segments that make up this circle. Higher is better quality, but slower render time. The default value of -1 means arcade will try to calculate a reasonable amount of segments based on the size of the circle.

arcade.draw_commands.draw_circle_outline(center_x: float, center_y: float, radius: float, color: Tuple[int, int, int, int], border_width: float = 1, tilt_angle: float = 0, num_segments: int = -1)[source]

Draw the outline of a circle.

Parameters:
  • center_x – x position that is the center of the circle.

  • center_y – y position that is the center of the circle.

  • radius – width of the circle.

  • color – A 3 or 4 length tuple of 0-255 channel values or a Color instance.

  • border_width – Width of the circle outline in pixels.

  • tilt_angle – Angle in degrees to tilt the circle (clockwise). Useful for low segment count circles

  • num_segments – Number of triangle segments that make up this circle. Higher is better quality, but slower render time. The default value of -1 means arcade will try to calculate a reasonable amount of segments based on the size of the circle.

arcade.draw_commands.draw_ellipse_filled(center_x: float, center_y: float, width: float, height: float, color: Tuple[int, int, int, int], tilt_angle: float = 0, num_segments: int = -1)[source]

Draw a filled in ellipse.

Parameters:
  • center_x – x position that is the center of the circle.

  • center_y – y position that is the center of the circle.

  • width – width of the ellipse.

  • height – height of the ellipse.

  • color – A 3 or 4 length tuple of 0-255 channel values or a Color instance.

  • color – Either a Color instance or an RGBA tuple of 4 byte values (0 to 255).

  • tilt_angle – Angle in degrees to tilt the ellipse (clockwise). Useful when drawing a circle with a low segment count, to make an octagon for example.

  • num_segments – Number of triangle segments that make up this circle. Higher is better quality, but slower render time. The default value of -1 means arcade will try to calculate a reasonable amount of segments based on the size of the circle.

arcade.draw_commands.draw_ellipse_outline(center_x: float, center_y: float, width: float, height: float, color: Tuple[int, int, int, int], border_width: float = 1, tilt_angle: float = 0, num_segments: int = -1)[source]

Draw the outline of an ellipse.

Parameters:
  • center_x – x position that is the center of the circle.

  • center_y – y position that is the center of the circle.

  • width – width of the ellipse.

  • height – height of the ellipse.

  • color – A 3 or 4 length tuple of 0-255 channel values or a Color instance.

  • border_width – Width of the circle outline in pixels.

  • tilt_angle – Angle in degrees to tilt the ellipse (clockwise). Useful when drawing a circle with a low segment count, to make an octagon for example.

  • num_segments – Number of triangle segments that make up this circle. Higher is better quality, but slower render time. The default value of -1 means arcade will try to calculate a reasonable amount of segments based on the size of the circle.

arcade.draw_commands.draw_line_strip(point_list: Sequence[Tuple[float | int, float | int] | Vec2 | Tuple[float | int, float | int, float | int] | Vec3], color: Tuple[int, int, int, int], line_width: float = 1)[source]

Draw a multi-point line.

Parameters:
  • point_list – List of x, y points that make up this strip

  • color – A color, specified as an RGBA tuple or a Color instance.

  • line_width – Width of the line

arcade.draw_commands.draw_line(start_x: float, start_y: float, end_x: float, end_y: float, color: Tuple[int, int, int, int], line_width: float = 1)[source]

Draw a line.

Parameters:
  • start_x – x position of line starting point.

  • start_y – y position of line starting point.

  • end_x – x position of line ending point.

  • end_y – y position of line ending point.

  • color – A color, specified as an RGBA tuple or a Color instance.

  • line_width – Width of the line in pixels.

arcade.draw_commands.draw_lines(point_list: Sequence[Tuple[float | int, float | int] | Vec2 | Tuple[float | int, float | int, float | int] | Vec3], color: Tuple[int, int, int, int], line_width: float = 1)[source]

Draw a set of lines.

Draw a line between each pair of points specified.

Parameters:
  • point_list – List of points making up the lines. Each point is in a list. So it is a list of lists.

  • color – A color, specified as an RGBA tuple or a Color instance.

  • line_width – Width of the line in pixels.

arcade.draw_commands.draw_point(x: float, y: float, color: Tuple[int, int, int, int], size: float)[source]

Draw a point.

Parameters:
  • x – x position of point.

  • y – y position of point.

  • color – A color, specified as an RGBA tuple or a Color instance.

  • size – Size of the point in pixels.

arcade.draw_commands.draw_points(point_list: Sequence[Tuple[float | int, float | int] | Vec2 | Tuple[float | int, float | int, float | int] | Vec3], color: Tuple[int, int, int, int], size: float = 1)[source]

Draw a set of points.

Parameters:
  • point_list – List of points Each point is in a list. So it is a list of lists.

  • color – A color, specified as an RGBA tuple or a Color instance.

  • size – Size of the point in pixels.

arcade.draw_commands.draw_polygon_filled(point_list: Sequence[Tuple[float | int, float | int] | Vec2], color: Tuple[int, int, int, int])[source]

Draw a polygon that is filled in.

Parameters:
  • point_list – List of points making up the lines. Each point is in a list. So it is a list of lists.

  • color – The color, specified in RGB or RGBA format.

arcade.draw_commands.draw_polygon_outline(point_list: Sequence[Tuple[float | int, float | int] | Vec2], color: Tuple[int, int, int, int], line_width: float = 1)[source]

Draw a polygon outline. Also known as a “line loop.”

Parameters:
  • point_list – List of points making up the lines. Each point is in a list. So it is a list of lists.

  • color – The color of the outline as an RGBA tuple or Color instance.

  • line_width – Width of the line in pixels.

arcade.draw_commands.draw_triangle_filled(x1: float, y1: float, x2: float, y2: float, x3: float, y3: float, color: Tuple[int, int, int, int])[source]

Draw a filled in triangle.

Parameters:
  • x1 – x value of first coordinate.

  • y1 – y value of first coordinate.

  • x2 – x value of second coordinate.

  • y2 – y value of second coordinate.

  • x3 – x value of third coordinate.

  • y3 – y value of third coordinate.

  • color – Color of the triangle as an RGBA tuple or Color instance.

arcade.draw_commands.draw_triangle_outline(x1: float, y1: float, x2: float, y2: float, x3: float, y3: float, color: Tuple[int, int, int, int], border_width: float = 1)[source]

Draw a the outline of a triangle.

Parameters:
  • x1 – x value of first coordinate.

  • y1 – y value of first coordinate.

  • x2 – x value of second coordinate.

  • y2 – y value of second coordinate.

  • x3 – x value of third coordinate.

  • y3 – y value of third coordinate.

  • color – RGBA255 of triangle as an RGBA tuple or :py:class`~arcade.types.Color` instance.

  • border_width – Width of the border in pixels. Defaults to 1.

arcade.draw_commands.draw_lrbt_rectangle_outline(left: float, right: float, bottom: float, top: float, color: Tuple[int, int, int, int], border_width: float = 1)[source]

Draw a rectangle by specifying left, right, bottom and top edges.

Parameters:
  • left – The x coordinate of the left edge of the rectangle.

  • right – The x coordinate of the right edge of the rectangle.

  • bottom – The y coordinate of the rectangle bottom.

  • top – The y coordinate of the top of the rectangle.

  • color – The color of the rectangle.

  • border_width – The width of the border in pixels. Defaults to one.

Raises ValueError:

Raised if left > right or top < bottom.

arcade.draw_commands.draw_lbwh_rectangle_outline(left: float, bottom: float, width: float, height: float, color: Tuple[int, int, int, int], border_width: float = 1)[source]

Draw a rectangle extending from bottom left to top right

Parameters:
  • bottom_left_x – The x coordinate of the left edge of the rectangle.

  • bottom_left_y – The y coordinate of the bottom of the rectangle.

  • width – The width of the rectangle.

  • height – The height of the rectangle.

  • color – The color of the rectangle as an RGBA tuple or :py:class`~arcade.types.Color` instance.

  • border_width – The width of the border in pixels. Defaults to one.

arcade.draw_commands.draw_lrbt_rectangle_filled(left: float, right: float, bottom: float, top: float, color: Tuple[int, int, int, int])[source]

Draw a rectangle by specifying left, right, bottom and top edges.

Parameters:
  • left – The x coordinate of the left edge of the rectangle.

  • right – The x coordinate of the right edge of the rectangle.

  • bottom – The y coordinate of the rectangle bottom.

  • top – The y coordinate of the top of the rectangle.

  • color – The color of the rectangle.

Raises ValueError:

Raised if left > right or top < bottom.

arcade.draw_commands.draw_lbwh_rectangle_filled(left: float, bottom: float, width: float, height: float, color: Tuple[int, int, int, int])[source]

Draw a filled rectangle extending from bottom left to top right

Parameters:
  • left – The x coordinate of the left edge of the rectangle.

  • bottom – The y coordinate of the bottom of the rectangle.

  • width – The width of the rectangle.

  • height – The height of the rectangle.

  • color – The color of the rectangles an RGBA tuple or :py:class`~arcade.types.Color` instance.

arcade.draw_commands.draw_scaled_texture_rectangle(center_x: float, center_y: float, texture: Texture, scale: float = 1.0, angle: float = 0, alpha: int = 255)[source]

Draw a textured rectangle on-screen.

Warning

This method can be slow!

Most users should consider using arcade.Sprite with arcade.SpriteList instead of this function.

OpenGL accelerates drawing by using batches to draw multiple things at once. This method doesn’t do that.

If you need finer control or less overhead than arcade allows, consider pyglet’s batching features.

Parameters:
  • center_x – x coordinate of rectangle center.

  • center_y – y coordinate of rectangle center.

  • texture – identifier of texture returned from load_texture() call

  • scale – scale of texture

  • angle – rotation of the rectangle (clockwise). Defaults to zero.

  • alpha – Transparency of image. 0 is fully transparent, 255 (default) is fully visible

arcade.draw_commands.draw_texture_rectangle(center_x: float, center_y: float, width: float, height: float, texture: Texture, angle: float = 0, alpha: int = 255)[source]

Draw a textured rectangle on-screen.

Parameters:
  • center_x – x coordinate of rectangle center.

  • center_y – y coordinate of rectangle center.

  • width – width of texture

  • height – height of texture

  • texture – identifier of texture returned from load_texture() call

  • angle – rotation of the rectangle. Defaults to zero (clockwise).

  • alpha – Transparency of image. 0 is fully transparent, 255 (default) is visible

arcade.draw_commands.draw_lbwh_rectangle_textured(left: float, bottom: float, width: float, height: float, texture: Texture, angle: float = 0, alpha: int = 255)[source]

Draw a texture extending from bottom left to top right.

Parameters:
  • left – The x coordinate of the left edge of the rectangle.

  • bottom – The y coordinate of the bottom of the rectangle.

  • width – The width of the rectangle.

  • height – The height of the rectangle.

  • texture – identifier of texture returned from load_texture() call

  • angle – rotation of the rectangle. Defaults to zero (clockwise).

  • alpha – Transparency of image. 0 is fully transparent, 255 (default) is visible

arcade.draw_commands.draw_rect_outline(rect: Rect, color: Tuple[int, int, int, int], border_width: float = 1, tilt_angle: float = 0)[source]

Draw a rectangle outline.

Parameters:
  • rect – The rectangle to draw. a :py:class`~arcade.types.Rect` instance.

  • color – The color of the rectangle. tuple or :py:class`~arcade.types.Color` instance.

  • border_width – width of the lines, in pixels.

  • tilt_angle – rotation of the rectangle. Defaults to zero (clockwise).

arcade.draw_commands.draw_rect_filled(rect: Rect, color: Tuple[int, int, int, int], tilt_angle: float = 0)[source]

Draw a filled-in rectangle.

Parameters:
  • rect – The rectangle to draw. a :py:class`~arcade.types.Rect` instance.

  • color – The color of the rectangle as an RGBA tuple or :py:class`~arcade.types.Color` instance.

  • tilt_angle – rotation of the rectangle (clockwise). Defaults to zero.

arcade.draw_commands.draw_rect_outline_kwargs(color: Tuple[int, int, int, int] = (255, 255, 255, 255), border_width: int = 1, tilt_angle: float = 0, **kwargs: float | int)[source]
arcade.draw_commands.draw_rect_filled_kwargs(color: Tuple[int, int, int, int] = (255, 255, 255, 255), tilt_angle: float = 0, **kwargs: float | int)[source]
arcade.draw_commands.get_pixel(x: int, y: int, components: int = 3) Tuple[int, ...][source]

Given an x, y, will return a color value of that point.

Parameters:
  • x – x location

  • y – y location

  • components – Number of components to fetch. By default we fetch 3 3 components (RGB). 4 components would be RGBA.

arcade.draw_commands.get_image(x: int = 0, y: int = 0, width: int | None = None, height: int | None = None) Image[source]

Get an image from the screen.

Example:

image = get_image()
image.save('screenshot.png', 'PNG')
Parameters:
  • x – Start (left) x location

  • y – Start (top) y location

  • width – Width of image. Leave blank for grabbing the ‘rest’ of the image

  • height – Height of image. Leave blank for grabbing the ‘rest’ of the image

Returns:

A Pillow Image