Shape Lists#
arcade.shape_list.Shape#
- class arcade.shape_list.Shape(points: Sequence[Tuple[float, float]], colors: Sequence[Tuple[int, int, int, int]], mode: int = 4, program: Program | None = None)[source]#
A container for arbitrary geometry representing a shape.
This shape can be drawn using the draw() method, or added to a ShapeElementList for drawing in batch.
- Parameters:
arcade.shape_list.ShapeElementList#
- class arcade.shape_list.ShapeElementList[source]#
A ShapeElementList is a list of shapes that can be drawn together in a back for better performance. ShapeElementLists are suited for drawing a large number of shapes that are static. If you need to move a lot of shapes it’s better to use pyglet’s shape system.
Adding new shapes is fast, but removing them is slow.
- clear(position: bool = True, angle: bool = True) None [source]#
Clear all the contents from the shape list.
- move(change_x: float, change_y: float)[source]#
Change the center_x/y of the shape list relative to the current position.
- Parameters:
change_x – Amount to move on the x axis
change_y – Amount to move on the y axis
arcade.shape_list.create_ellipse#
- arcade.shape_list.create_ellipse(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 = 32, filled: bool = True) 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 inon_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) – X position of the center of the ellipse.
center_y (float) – Y position of the center of the ellipse.
width (float) – Width of the ellipse.
height (float) – Height of the ellipse.
color (RGBA255) – Color of the ellipse.
border_width (float) – Width of the border.
tilt_angle (float) – Angle to tilt the ellipse.
num_segments (int) – Number of segments to use to draw the ellipse.
filled (bool) – If True, create a filled ellipse. If False, create an outline.
arcade.shape_list.create_ellipse_filled#
- arcade.shape_list.create_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 = 128) 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 inon_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.shape_list.create_ellipse_filled_with_colors#
- arcade.shape_list.create_ellipse_filled_with_colors(center_x: float, center_y: float, width: float, height: float, outside_color: Tuple[int, int, int, int], inside_color: Tuple[int, int, int, int], tilt_angle: float = 0, num_segments: int = 32) 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 inon_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) – X position of the center of the ellipse.
center_y (float) – Y position of the center of the ellipse.
width (float) – Width of the ellipse.
height (float) – Height of the ellipse.
outside_color (RGBA255) – Color of the outside of the ellipse.
inside_color (RGBA255) – Color of the inside of the ellipse.
tilt_angle (float) – Angle to tilt the ellipse.
num_segments (int) – Number of segments to use to draw the ellipse.
arcade.shape_list.create_ellipse_outline#
- arcade.shape_list.create_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 = 128) 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 inon_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.shape_list.create_line#
arcade.shape_list.create_line_generic#
arcade.shape_list.create_line_generic_with_colors#
arcade.shape_list.create_line_loop#
- arcade.shape_list.create_line_loop(point_list: Sequence[Tuple[float, float]], color: Tuple[int, int, int, int], line_width: float = 1) Shape [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.
arcade.shape_list.create_line_strip#
- arcade.shape_list.create_line_strip(point_list: Sequence[Tuple[float, float]], color: Tuple[int, int, int, int], line_width: float = 1) Shape [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 (RGBA255) –
line_width (PointList) –
arcade.shape_list.create_lines#
arcade.shape_list.create_lines_with_colors#
- arcade.shape_list.create_lines_with_colors(point_list: Sequence[Tuple[float, float]], color_list: Sequence[Tuple[int, int, int, int]], line_width: float = 1) Shape [source]#
Create a line segments 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) – Line segments start and end point tuples list
color_list (RGBA255) – Three or four byte tuples list for every point
line_width (float) – Width of the line
- Returns Shape:
arcade.shape_list.create_polygon#
- arcade.shape_list.create_polygon(point_list: Sequence[Tuple[float, float]], color: Tuple[int, int, int, int]) Shape [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 inon_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) – A list of points that make up the shape.
color (RGBA255) – A color such as a
Color
arcade.shape_list.create_rectangle#
- arcade.shape_list.create_rectangle(center_x: float, center_y: float, width: float, height: float, color: Tuple[int, int, int, int], border_width: float = 1, tilt_angle: float = 0, filled=True) 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 inon_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) – X position of the center of the rectangle
center_y (float) – Y position of the center of the rectangle
width (float) – Width of the rectangle
height (float) – Height of the rectangle
color (RGBA255) – A color such as a
Color
border_width (float) – Width of the border
tilt_angle (float) – Angle to tilt the rectangle in degrees
filled (bool) – If True, the rectangle is filled. If False, it is an outline.
arcade.shape_list.create_rectangle_filled#
- arcade.shape_list.create_rectangle_filled(center_x: float, center_y: float, width: float, height: float, color: Tuple[int, int, int, int], tilt_angle: float = 0) 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 inon_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) – X position of the center of the rectangle
center_y (float) – Y position of the center of the rectangle
width (float) – Width of the rectangle
height (float) – Height of the rectangle
color (RGBA255) – A color such as a
Color
tilt_angle (float) – Angle to tilt the rectangle in degrees
arcade.shape_list.create_rectangle_filled_with_colors#
- arcade.shape_list.create_rectangle_filled_with_colors(point_list, color_list) 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 inon_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 – List of points to create the rectangle from
color_list – List of colors to create the rectangle from
arcade.shape_list.create_rectangle_outline#
- arcade.shape_list.create_rectangle_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) 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 inon_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) – X position of the center of the rectangle
center_y (float) – Y position of the center of the rectangle
width (float) – Width of the rectangle
height (float) – Height of the rectangle
color (RGBA255) – A color such as a
Color
border_width (float) – Width of the border
tilt_angle (float) – Angle to tilt the rectangle in degrees
arcade.shape_list.create_rectangles_filled_with_colors#
- arcade.shape_list.create_rectangles_filled_with_colors(point_list, color_list: Sequence[Tuple[int, int, int, int]]) 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 inon_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.shape_list.create_triangles_filled_with_colors#
- arcade.shape_list.create_triangles_filled_with_colors(point_list: Sequence[Tuple[float, float]], color_sequence: Sequence[Tuple[int, int, int, int]]) Shape [source]#
This function creates multiple triangles using a vertex buffer object. Triangles are build for every 3 sequential vertices with step of 3 vertex Total amount of triangles to be rendered: len(point_list) / 3
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 inon_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.shape_list.create_triangles_strip_filled_with_colors#
- arcade.shape_list.create_triangles_strip_filled_with_colors(point_list, color_sequence: Sequence[Tuple[int, int, int, int]]) Shape [source]#
This function creates multiple triangles using a vertex buffer object. Triangles are built for every 3 sequential vertices with step of 1 vertex Total amount of triangles to be rendered: len(point_list) - 2
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 inon_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.