Shape Lists
- class arcade.shape_list.Shape(points: Sequence[tuple[float | int, float | int] | Vec2 | tuple[float | int, float | int, float | int] | Vec3], colors: Sequence[tuple[int, int, int, int]], mode: int = 4, program: Program | None = None)[source]
Bases:
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:
points – A list of points that make up the shape.
colors – A list of colors that correspond to the points.
mode – The OpenGL drawing mode. Defaults to GL_TRIANGLES.
program – The program to use when drawing this shape (Shape.draw() only)
- class arcade.shape_list.ShapeElementList(blend: bool = True)[source]
Bases:
Generic
[TShape
]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.
- Parameters:
blend – If True, shapes will be drawn with blending enabled.
- append(item: TShape) None [source]
Add a new shape to the list.
- Parameters:
item – Shape to add to the list.
- clear(position: bool = True, angle: bool = True) None [source]
Clear all the contents from the shape list.
- Parameters:
position – Reset the position to
0, 0
angle – Reset the angle to
0.0
- move(change_x: float, change_y: float) None [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
- property position: tuple[float, float]
Get or set the position of the ShapeElementList.
This is the equivalent of setting center_x and center_y
- arcade.shape_list.create_line(start_x: float, start_y: float, end_x: float, end_y: float, color: tuple[int, int, int, int], line_width: float = 1) Shape [source]
Create a Shape object for a line.
- Parameters:
start_x – Starting x position
start_y – Starting y position
end_x – Ending x position
end_y – Ending y position
color – Color of the line
line_width – Width of the line
- arcade.shape_list.create_line_generic_with_colors(point_list: Sequence[tuple[float | int, float | int] | Vec2 | tuple[float | int, float | int, float | int] | Vec3], color_sequence: Sequence[tuple[int, int, int, int]], shape_mode: int) Shape [source]
This function is used by
create_line_strip
andcreate_line_loop
, just changing the OpenGL type for the line drawing.
- arcade.shape_list.create_line_generic(point_list: Sequence[tuple[float | int, float | int] | Vec2 | tuple[float | int, float | int, float | int] | Vec3], color: tuple[int, int, int, int], shape_mode: int) Shape [source]
This function is used by
create_line_strip
andcreate_line_loop
, just changing the OpenGL type for the line drawing.- Parameters:
point_list – A list of points that make up the shape.
color – A color such as a
Color
shape_mode – The OpenGL drawing mode. Defaults to
GL_TRIANGLES
.
- arcade.shape_list.create_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) 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 – A list of points that make up the shape.
color – A color such as a
Color
line_width – Width of the line
- arcade.shape_list.create_line_loop(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) 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.
- Parameters:
point_list – A list of points that make up the shape.
color – A color such as a
Color
line_width – Width of the line
- arcade.shape_list.create_lines(point_list: Sequence[tuple[float | int, float | int] | Vec2 | tuple[float | int, float | int, float | int] | Vec3], color: tuple[int, int, int, int]) 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.
- Parameters:
point_list – A list of points that make up the shape.
color – A color such as a
Color
- arcade.shape_list.create_lines_with_colors(point_list: Sequence[tuple[float | int, float | int] | Vec2 | tuple[float | int, float | int, float | int] | Vec3], 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 – Line segments start and end point tuples list
color_list – Three or four byte tuples list for every point
line_width – Width of the line
- arcade.shape_list.create_polygon(point_list: Sequence[tuple[float | int, float | int] | Vec2 | tuple[float | int, float | int, float | int] | Vec3], 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 – A list of points that make up the shape.
color – A color such as a
Color
- 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 – X position of the center of the rectangle
center_y – Y position of the center of the rectangle
width – Width of the rectangle
height – Height of the rectangle
color – A color such as a
Color
tilt_angle – Angle to tilt the rectangle in degrees
- 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 – X position of the center of the rectangle
center_y – Y position of the center of the rectangle
width – Width of the rectangle
height – Height of the rectangle
color – A color such as a
Color
border_width – Width of the border
tilt_angle – Angle to tilt the rectangle in degrees
- arcade.shape_list.get_rectangle_points(center_x: float, center_y: float, width: float, height: float, tilt_angle: float = 0) Sequence[tuple[float | int, float | int] | Vec2 | tuple[float | int, float | int, float | int] | Vec3] [source]
Utility function that will return all four coordinate points of a rectangle given the x, y center, width, height, and rotation.
- Parameters:
center_x – X position of the center of the rectangle
center_y – Y position of the center of the rectangle
width – Width of the rectangle
height – Height of the rectangle
tilt_angle – Angle to tilt the rectangle in degrees
- 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 – X position of the center of the rectangle
center_y – Y position of the center of the rectangle
width – Width of the rectangle
height – Height of the rectangle
color – A color such as a
Color
border_width – Width of the border
tilt_angle – Angle to tilt the rectangle in degrees
filled – If True, the rectangle is filled. If False, it is an outline.
- 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_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.
- Parameters:
point_list – List of points to create the rectangles from
color_list – List of colors to create the rectangles from
- arcade.shape_list.create_triangles_filled_with_colors(point_list: Sequence[tuple[float | int, float | int] | Vec2 | tuple[float | int, float | int, float | int] | Vec3], 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(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.
- 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.
- Parameters:
center_x – X position of the center of the ellipse
center_y – Y position of the center of the ellipse
width – Width of the ellipse
height – Height of the ellipse
color – A color such as a
Color
tilt_angle – Angle to tilt the ellipse
num_segments – Number of segments to use to draw the ellipse
- 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.
- Parameters:
center_x – X position of the center of the ellipse
center_y – Y position of the center of the ellipse
width – Width of the ellipse
height – Height of the ellipse
color – A color such as a
Color
border_width – Width of the border
tilt_angle – Angle to tilt the ellipse
num_segments – Number of segments to use to draw the 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 – X position of the center of the ellipse.
center_y – Y position of the center of the ellipse.
width – Width of the ellipse.
height – Height of the ellipse.
color – Color of the ellipse.
border_width – Width of the border.
tilt_angle – Angle to tilt the ellipse.
num_segments – Number of segments to use to draw the ellipse.
filled – If True, create a filled ellipse. If False, create an outline.
- 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 – X position of the center of the ellipse.
center_y – Y position of the center of the ellipse.
width – Width of the ellipse.
height – Height of the ellipse.
outside_color – Color of the outside of the ellipse.
inside_color – Color of the inside of the ellipse.
tilt_angle – Angle to tilt the ellipse.
num_segments – Number of segments to use to draw the ellipse.