Drawing - Batch

arcade.Shape

class arcade.Shape[source]

Primitive drawing shape. This can be part of a ShapeElementList so shapes can be drawn faster in batch.

draw()[source]

Draw this shape. Drawing this way isn’t as fast as drawing multiple shapes batched together in a ShapeElementList.

arcade.ShapeElementList

class arcade.ShapeElementList[source]

A program can put multiple drawing primitives in a ShapeElementList, and then move and draw them as one. Do this when you want to create a more complex object out of simpler primitives. This also speeds rendering as all objects are drawn in one operation.

property angle: float

Get the angle of the ShapeElementList in degrees.

append(item: arcade.buffered_draw_commands.TShape)[source]

Add a new shape to the list.

property center_x: float

Get the center x coordinate of the ShapeElementList.

property center_y: float

Get the center y coordinate of the ShapeElementList.

draw()[source]

Draw everything in the list.

move(change_x: float, change_y: float)[source]

Move all the shapes ion the list :param change_x: Amount to move on the x axis :param change_y: Amount to move on the y axis

remove(item: arcade.buffered_draw_commands.TShape)[source]

Remove a specific shape from the list.

arcade.create_ellipse

arcade.create_ellipse(center_x: float, center_y: float, width: float, height: float, color: Union[Tuple[int, int, int], List[int], Tuple[int, int, int, int]], border_width: float = 1, tilt_angle: float = 0, num_segments: int = 32, filled=True) arcade.buffered_draw_commands.Shape[source]

This creates an ellipse vertex buffer object (VBO).

The function returns a Shape object that can be drawn with my_shape.draw(). Don’t create the shape in the draw method, create it in the setup method and then draw it in on_draw.

For even faster performance, add multiple shapes into a ShapeElementList and draw that list. This allows nearly unlimited shapes to be drawn just as fast as one.

arcade.create_ellipse_filled

arcade.create_ellipse_filled(center_x: float, center_y: float, width: float, height: float, color: Union[Tuple[int, int, int], List[int], Tuple[int, int, int, int]], tilt_angle: float = 0, num_segments: int = 128) arcade.buffered_draw_commands.Shape[source]

Create a filled ellipse. Or circle if you use the same width and height.

The function returns a Shape object that can be drawn with my_shape.draw(). Don’t create the shape in the draw method, create it in the setup method and then draw it in on_draw.

For even faster performance, add multiple shapes into a ShapeElementList and draw that list. This allows nearly unlimited shapes to be drawn just as fast as one.

arcade.create_ellipse_filled_with_colors

arcade.create_ellipse_filled_with_colors(center_x: float, center_y: float, width: float, height: float, outside_color: Union[Tuple[int, int, int], List[int], Tuple[int, int, int, int]], inside_color: Union[Tuple[int, int, int], List[int], Tuple[int, int, int, int]], tilt_angle: float = 0, num_segments: int = 32) arcade.buffered_draw_commands.Shape[source]

Draw an ellipse, and specify inside/outside color. Used for doing gradients.

The function returns a Shape object that can be drawn with my_shape.draw(). Don’t create the shape in the draw method, create it in the setup method and then draw it in on_draw.

For even faster performance, add multiple shapes into a ShapeElementList and draw that list. This allows nearly unlimited shapes to be drawn just as fast as one.

Parameters
  • center_x (float) –

  • center_y (float) –

  • width (float) –

  • height (float) –

  • outside_color (Color) –

  • inside_color (float) –

  • tilt_angle (float) –

  • num_segments (int) –

Returns Shape

arcade.create_ellipse_outline

arcade.create_ellipse_outline(center_x: float, center_y: float, width: float, height: float, color: Union[Tuple[int, int, int], List[int], Tuple[int, int, int, int]], border_width: float = 1, tilt_angle: float = 0, num_segments: int = 128) arcade.buffered_draw_commands.Shape[source]

Create an outline of an ellipse.

The function returns a Shape object that can be drawn with my_shape.draw(). Don’t create the shape in the draw method, create it in the setup method and then draw it in on_draw.

For even faster performance, add multiple shapes into a ShapeElementList and draw that list. This allows nearly unlimited shapes to be drawn just as fast as one.

arcade.create_line

arcade.create_line(start_x: float, start_y: float, end_x: float, end_y: float, color: Union[Tuple[int, int, int], List[int], Tuple[int, int, int, int]], line_width: float = 1) arcade.buffered_draw_commands.Shape[source]

Create a line to be rendered later. This works faster than draw_line because the vertexes are only loaded to the graphics card once, rather than each frame.

Parameters
Returns Shape

arcade.create_line_generic

arcade.create_line_generic(point_list: Sequence[Union[Tuple[float, float], List[float]]], color: Union[Tuple[int, int, int], List[int], Tuple[int, int, int, int]], shape_mode: int, line_width: float = 1) arcade.buffered_draw_commands.Shape[source]

This function is used by create_line_strip and create_line_loop, just changing the OpenGL type for the line drawing.

arcade.create_line_generic_with_colors

arcade.create_line_generic_with_colors(point_list: Sequence[Union[Tuple[float, float], List[float]]], color_list: Iterable[Union[Tuple[int, int, int], List[int], Tuple[int, int, int, int]]], shape_mode: int, line_width: float = 1) arcade.buffered_draw_commands.Shape[source]

This function is used by create_line_strip and create_line_loop, just changing the OpenGL type for the line drawing.

Parameters
  • point_list (PointList) –

  • color_list (Iterable[Color]) –

  • shape_mode (float) –

  • line_width (float) –

Returns Shape

arcade.create_line_loop

arcade.create_line_loop(point_list: Sequence[Union[Tuple[float, float], List[float]]], color: Union[Tuple[int, int, int], List[int], Tuple[int, int, int, int]], line_width: float = 1)[source]

Create a multi-point line loop to be rendered later. This works faster than draw_line because the vertexes are only loaded to the graphics card once, rather than each frame.

Parameters
  • point_list (PointList) –

  • color (Color) –

  • line_width (float) –

Returns Shape

arcade.create_line_strip

arcade.create_line_strip(point_list: Sequence[Union[Tuple[float, float], List[float]]], color: Union[Tuple[int, int, int], List[int], Tuple[int, int, int, int]], line_width: float = 1)[source]

Create a multi-point line to be rendered later. This works faster than draw_line because the vertexes are only loaded to the graphics card once, rather than each frame.

Internally, thick lines are created by two triangles.

Parameters
  • point_list (PointList) –

  • color (Color) –

  • line_width (PointList) –

Returns Shape

arcade.create_lines

arcade.create_lines(point_list: Sequence[Union[Tuple[float, float], List[float]]], color: Union[Tuple[int, int, int], List[int], Tuple[int, int, int, int]], line_width: float = 1)[source]

Create a multi-point line loop to be rendered later. This works faster than draw_line because the vertexes are only loaded to the graphics card once, rather than each frame.

Parameters
  • point_list (PointList) –

  • color (Color) –

  • line_width (float) –

Returns Shape

arcade.create_lines_with_colors

arcade.create_lines_with_colors(point_list: Sequence[Union[Tuple[float, float], List[float]]], color_list: Sequence[Union[Tuple[int, int, int], List[int], Tuple[int, int, int, int]]], line_width: float = 1)[source]

arcade.create_polygon

arcade.create_polygon(point_list: Sequence[Union[Tuple[float, float], List[float]]], color: Union[Tuple[int, int, int], List[int], Tuple[int, int, int, int]])[source]

Draw a convex polygon. This will NOT draw a concave polygon. Because of this, you might not want to use this function.

The function returns a Shape object that can be drawn with my_shape.draw(). Don’t create the shape in the draw method, create it in the setup method and then draw it in on_draw.

For even faster performance, add multiple shapes into a ShapeElementList and draw that list. This allows nearly unlimited shapes to be drawn just as fast as one.

Parameters
  • point_list (PointList) –

  • color

Returns Shape

arcade.create_rectangle

arcade.create_rectangle(center_x: float, center_y: float, width: float, height: float, color: Union[Tuple[int, int, int], List[int], Tuple[int, int, int, int]], border_width: float = 1, tilt_angle: float = 0, filled=True) arcade.buffered_draw_commands.Shape[source]

This function creates a rectangle using a vertex buffer object.

The function returns a Shape object that can be drawn with my_shape.draw(). Don’t create the shape in the draw method, create it in the setup method and then draw it in on_draw.

For even faster performance, add multiple shapes into a ShapeElementList and draw that list. This allows nearly unlimited shapes to be drawn just as fast as one.

Parameters

arcade.create_rectangle_filled

arcade.create_rectangle_filled(center_x: float, center_y: float, width: float, height: float, color: Union[Tuple[int, int, int], List[int], Tuple[int, int, int, int]], tilt_angle: float = 0) arcade.buffered_draw_commands.Shape[source]

Create a filled rectangle.

The function returns a Shape object that can be drawn with my_shape.draw(). Don’t create the shape in the draw method, create it in the setup method and then draw it in on_draw.

For even faster performance, add multiple shapes into a ShapeElementList and draw that list. This allows nearly unlimited shapes to be drawn just as fast as one.

Parameters
Returns Shape

arcade.create_rectangle_filled_with_colors

arcade.create_rectangle_filled_with_colors(point_list, color_list) arcade.buffered_draw_commands.Shape[source]

This function creates one rectangle/quad using a vertex buffer object.

The function returns a Shape object that can be drawn with my_shape.draw(). Don’t create the shape in the draw method, create it in the setup method and then draw it in on_draw.

For even faster performance, add multiple shapes into a ShapeElementList and draw that list. This allows nearly unlimited shapes to be drawn just as fast as one.

arcade.create_rectangle_outline

arcade.create_rectangle_outline(center_x: float, center_y: float, width: float, height: float, color: Union[Tuple[int, int, int], List[int], Tuple[int, int, int, int]], border_width: float = 1, tilt_angle: float = 0) arcade.buffered_draw_commands.Shape[source]

Create a rectangle outline.

The function returns a Shape object that can be drawn with my_shape.draw(). Don’t create the shape in the draw method, create it in the setup method and then draw it in on_draw.

For even faster performance, add multiple shapes into a ShapeElementList and draw that list. This allows nearly unlimited shapes to be drawn just as fast as one.

Parameters
  • center_x (float) –

  • center_y (float) –

  • width (float) –

  • height (float) –

  • color (Color) –

  • border_width (Color) –

  • tilt_angle (float) –

Returns: Shape

arcade.create_rectangles_filled_with_colors

arcade.create_rectangles_filled_with_colors(point_list, color_list) arcade.buffered_draw_commands.Shape[source]

This function creates multiple rectangle/quads using a vertex buffer object.

The function returns a Shape object that can be drawn with my_shape.draw(). Don’t create the shape in the draw method, create it in the setup method and then draw it in on_draw.

For even faster performance, add multiple shapes into a ShapeElementList and draw that list. This allows nearly unlimited shapes to be drawn just as fast as one.

arcade.create_triangles_filled_with_colors

arcade.create_triangles_filled_with_colors(point_list, color_list) arcade.buffered_draw_commands.Shape[source]

This function creates multiple rectangle/quads using a vertex buffer object.

The function returns a Shape object that can be drawn with my_shape.draw(). Don’t create the shape in the draw method, create it in the setup method and then draw it in on_draw.

For even faster performance, add multiple shapes into a ShapeElementList and draw that list. This allows nearly unlimited shapes to be drawn just as fast as one.

arcade.get_rectangle_points

arcade.get_rectangle_points(center_x: float, center_y: float, width: float, height: float, tilt_angle: float = 0) Sequence[Union[Tuple[float, float], List[float]]][source]

Utility function that will return all four coordinate points of a rectangle given the x, y center, width, height, and rotation.

Parameters

Returns: PointList