形状列表#

class arcade.shape_list.Shape(points: Sequence[Tuple[float, float]], colors: Sequence[Tuple[int, int, int, int]], mode: int = 4, program: Program | None = None)[源代码]#

基类:

表示形状的任意几何图形的容器。

可以使用Draw()方法绘制此形状,也可以将其添加到ShapeElementList以进行批量绘制。

参数:
  • points -- 组成形状的点的列表。

  • colors -- 与点对应的颜色列表。

  • mode -- OpenGL绘图模式。默认为GL_TRANGLENGS。

  • program -- 绘制此形状时使用的程序(仅限Shape.Draw())

draw()[源代码]#

画出这个形状。这种绘制方式不如在ShapeElementList中批量绘制多个形状的速度快。

class arcade.shape_list.ShapeElementList[源代码]#

基类:Generic[TShape]

ShapeElementList是可以在背面绘制在一起以获得更好性能的形状的列表。ShapeElementList适合绘制大量静态形状。如果你需要移动很多形状,最好使用侏儒的形状系统。

添加新形状很快,但删除它们却很慢。

🧙 iter(self) Iterable[TShape][源代码]#

返回精灵的可迭代对象。

🧙 len(self) int[源代码]#

返回精灵列表的长度。

append(item: TShape)[源代码]#

将新形状添加到列表中。

clear(position: bool = True, angle: bool = True) None[源代码]#

清除形状列表中的所有内容。

参数:
  • position -- 将位置重置为0,0

  • angle -- 将角度重置为0

draw() None[源代码]#

画出所有的形状。

move(change_x: float, change_y: float)[源代码]#

相对于当前位置更改形状列表的center_x/y。

参数:
  • change_x -- 在x轴上移动的量

  • change_y -- 在y轴上移动的量

remove(item: TShape)[源代码]#

从列表中删除特定形状。

update() None[源代码]#

更新形状列表的内部结构。当您调用DRAW()时,会自动调用它。

在某些情况下,您可能需要手动调用此函数以在绘制之前更新形状列表。

angle#

获取或设置以度为单位的旋转(顺时针)

center_x#

获取或设置ShapeElementList的中心x坐标。

center_y#

获取或设置ShapeElementList的中心y坐标。

position#

获取或设置ShapeElementList的位置。

这相当于设置Center_x和Center_y

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[源代码]#

这将创建一个椭圆顶点缓冲区对象(VBO)。

函数用于返回可使用绘制的Shape对象 my_shape.draw() 。不要在Draw方法中创建形状,而是在Setup方法中创建它,然后将其绘制到 on_draw

为了获得更快的性能,可以将多个形状添加到ShapeElementList中并绘制该列表。这使得几乎可以像绘制一个形状一样快速地绘制无限形状。

参数:
  • center_x -- 椭圆中心的X位置。

  • center_y -- 椭圆中心的Y位置。

  • width -- 椭圆的宽度。

  • height -- 椭圆的高度。

  • color -- 椭圆的颜色。

  • border_width -- 边框的宽度。

  • tilt_angle -- 倾斜椭圆的角度。

  • num_segments -- 用于绘制椭圆的线段数。

  • filled -- 如果为True,则创建一个实心椭圆。如果为False,则创建大纲。

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[源代码]#

创建一个实心椭圆。或者,如果您使用相同的宽度和高度,请将其圈起来。

函数用于返回可使用绘制的Shape对象 my_shape.draw() 。不要在Draw方法中创建形状,而是在Setup方法中创建它,然后将其绘制到 on_draw

为了获得更快的性能,可以将多个形状添加到ShapeElementList中并绘制该列表。这使得几乎可以像绘制一个形状一样快速地绘制无限形状。

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[源代码]#

绘制一个椭圆,并指定内部/外部颜色。用于进行渐变。

函数用于返回可使用绘制的Shape对象 my_shape.draw() 。不要在Draw方法中创建形状,而是在Setup方法中创建它,然后将其绘制到 on_draw

为了获得更快的性能,可以将多个形状添加到ShapeElementList中并绘制该列表。这使得几乎可以像绘制一个形状一样快速地绘制无限形状。

参数:
  • center_x -- 椭圆中心的X位置。

  • center_y -- 椭圆中心的Y位置。

  • width -- 椭圆的宽度。

  • height -- 椭圆的高度。

  • outside_color -- 椭圆外部的颜色。

  • inside_color -- 椭圆内部的颜色。

  • tilt_angle -- 倾斜椭圆的角度。

  • num_segments -- 用于绘制椭圆的线段数。

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[源代码]#

创建椭圆的轮廓。

函数用于返回可使用绘制的Shape对象 my_shape.draw() 。不要在Draw方法中创建形状,而是在Setup方法中创建它,然后将其绘制到 on_draw

为了获得更快的性能,可以将多个形状添加到ShapeElementList中并绘制该列表。这使得几乎可以像绘制一个形状一样快速地绘制无限形状。

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[源代码]#

创建一条直线的形状对象。

参数:
  • start_x -- 起始x位置

  • start_y -- 开始y位置

  • end_x -- 结束x位置

  • end_y -- 结束y位置

  • color -- 线条的颜色

  • line_width -- 线条宽度

arcade.shape_list.create_line_generic(point_list: Sequence[Tuple[float, float]], color: Tuple[int, int, int, int], shape_mode: int) Shape[源代码]#

此函数由使用 create_line_stripcreate_line_loop ,只需更改线条绘制的OpenGL类型。

参数:
  • point_list -- 组成形状的点的列表。

  • color -- 一种颜色,如 Color

  • shape_mode -- OpenGL绘图模式。默认为GL_TRANGLENGS。

arcade.shape_list.create_line_generic_with_colors(point_list: Sequence[Tuple[float, float]], color_sequence: Sequence[Tuple[int, int, int, int]], shape_mode: int) Shape[源代码]#

此函数由使用 create_line_stripcreate_line_loop ,只需更改线条绘制的OpenGL类型。

参数:
  • point_list -- 组成形状的点的列表。

  • color_sequence -- 一系列颜色,如 list ;每种颜色必须是 Color 实例或4长度RGBA tuple

  • shape_mode -- OpenGL绘图模式。默认为GL_TRANGLENGS。

arcade.shape_list.create_line_loop(point_list: Sequence[Tuple[float, float]], color: Tuple[int, int, int, int], line_width: float = 1) Shape[源代码]#

创建要在稍后渲染的多点线循环。这比DRAW_LINE更快,因为顶点只加载到图形卡一次,而不是每一帧。

参数:
  • point_list -- 组成形状的点的列表。

  • color -- 一种颜色,如 Color

  • line_width -- 线条宽度

arcade.shape_list.create_line_strip(point_list: Sequence[Tuple[float, float]], color: Tuple[int, int, int, int], line_width: float = 1) Shape[源代码]#

创建稍后要渲染的多点直线。这比DRAW_LINE更快,因为顶点只加载到图形卡一次,而不是每一帧。

在内部,粗线由两个三角形创建。

参数:
  • point_list --

  • color --

  • line_width --

arcade.shape_list.create_lines(point_list: Sequence[Tuple[float, float]], color: Tuple[int, int, int, int]) Shape[源代码]#

创建要在稍后渲染的多点线循环。这比DRAW_LINE更快,因为顶点只加载到图形卡一次,而不是每一帧。

参数:
  • point_list -- 组成形状的点的列表。

  • color -- 一种颜色,如 Color

  • line_width -- 线条宽度

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[源代码]#

创建稍后要渲染的线段。这比DRAW_LINE更快,因为顶点只加载到图形卡一次,而不是每一帧。

参数:
  • point_list -- 线段起点和终点元组列表

  • color_list -- 每个点的三字节或四字节元组列表

  • line_width -- 线条宽度

返回形状:

arcade.shape_list.create_polygon(point_list: Sequence[Tuple[float, float]], color: Tuple[int, int, int, int]) Shape[源代码]#

绘制一个凸面多边形。这将不会绘制凹面多边形。因此,您可能不想使用此函数。

函数用于返回可使用绘制的Shape对象 my_shape.draw() 。不要在Draw方法中创建形状,而是在Setup方法中创建它,然后将其绘制到 on_draw

为了获得更快的性能,可以将多个形状添加到ShapeElementList中并绘制该列表。这使得几乎可以像绘制一个形状一样快速地绘制无限形状。

参数:
  • point_list -- 组成形状的点的列表。

  • color -- 一种颜色,如 Color

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[源代码]#

此函数使用顶点缓冲区对象创建矩形。

函数用于返回可使用绘制的Shape对象 my_shape.draw() 。不要在Draw方法中创建形状,而是在Setup方法中创建它,然后将其绘制到 on_draw

为了获得更快的性能,可以将多个形状添加到ShapeElementList中并绘制该列表。这使得几乎可以像绘制一个形状一样快速地绘制无限形状。

参数:
  • center_x -- 矩形中心的X位置

  • center_y -- 矩形中心的Y位置

  • width -- 矩形的宽度

  • height -- 矩形的高度

  • color -- 一种颜色,如 Color

  • border_width -- 边框的宽度

  • tilt_angle -- 将矩形倾斜的角度(以度为单位

  • filled -- 如果为True,则填充矩形。如果为False,则为大纲。

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[源代码]#

创建填充矩形。

函数用于返回可使用绘制的Shape对象 my_shape.draw() 。不要在Draw方法中创建形状,而是在Setup方法中创建它,然后将其绘制到 on_draw

为了获得更快的性能,可以将多个形状添加到ShapeElementList中并绘制该列表。这使得几乎可以像绘制一个形状一样快速地绘制无限形状。

参数:
  • center_x -- 矩形中心的X位置

  • center_y -- 矩形中心的Y位置

  • width -- 矩形的宽度

  • height -- 矩形的高度

  • color -- 一种颜色,如 Color

  • tilt_angle -- 将矩形倾斜的角度(以度为单位

arcade.shape_list.create_rectangle_filled_with_colors(point_list, color_list) Shape[源代码]#

此函数使用顶点缓冲区对象创建一个矩形/四边形。

函数用于返回可使用绘制的Shape对象 my_shape.draw() 。不要在Draw方法中创建形状,而是在Setup方法中创建它,然后将其绘制到 on_draw

为了获得更快的性能,可以将多个形状添加到ShapeElementList中并绘制该列表。这使得几乎可以像绘制一个形状一样快速地绘制无限形状。

参数:
  • point_list -- 要从中创建矩形的点的列表

  • color_list -- 用于创建矩形的颜色列表

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[源代码]#

创建一个矩形轮廓。

函数用于返回可使用绘制的Shape对象 my_shape.draw() 。不要在Draw方法中创建形状,而是在Setup方法中创建它,然后将其绘制到 on_draw

为了获得更快的性能,可以将多个形状添加到ShapeElementList中并绘制该列表。这使得几乎可以像绘制一个形状一样快速地绘制无限形状。

参数:
  • center_x -- 矩形中心的X位置

  • center_y -- 矩形中心的Y位置

  • width -- 矩形的宽度

  • height -- 矩形的高度

  • color -- 一种颜色,如 Color

  • border_width -- 边框的宽度

  • tilt_angle -- 将矩形倾斜的角度(以度为单位

arcade.shape_list.create_rectangles_filled_with_colors(point_list, color_list: Sequence[Tuple[int, int, int, int]]) Shape[源代码]#

此函数使用顶点缓冲区对象创建多个矩形/四边形。

函数用于返回可使用绘制的Shape对象 my_shape.draw() 。不要在Draw方法中创建形状,而是在Setup方法中创建它,然后将其绘制到 on_draw

为了获得更快的性能,可以将多个形状添加到ShapeElementList中并绘制该列表。这使得几乎可以像绘制一个形状一样快速地绘制无限形状。

arcade.shape_list.create_triangles_filled_with_colors(point_list: Sequence[Tuple[float, float]], color_sequence: Sequence[Tuple[int, int, int, int]]) Shape[源代码]#

此函数使用顶点缓冲区对象创建多个三角形。以3个顶点为步长为每3个连续顶点构建三角形要渲染的三角形总数:LEN(POINT_LIST)/3

函数用于返回可使用绘制的Shape对象 my_shape.draw() 。不要在Draw方法中创建形状,而是在Setup方法中创建它,然后将其绘制到 on_draw

为了获得更快的性能,可以将多个形状添加到ShapeElementList中并绘制该列表。这使得几乎可以像绘制一个形状一样快速地绘制无限形状。

参数:
  • point_list -- 三角形顶点元组。

  • color_sequence -- 一系列颜色,如 list ;每种颜色必须是 Color 实例或4长度RGBA tuple

arcade.shape_list.create_triangles_strip_filled_with_colors(point_list, color_sequence: Sequence[Tuple[int, int, int, int]]) Shape[源代码]#

此函数使用顶点缓冲区对象创建多个三角形。以1个顶点为步长为每3个连续顶点构建三角形要渲染的三角形总数:LEN(POINT_LIST)-2

函数用于返回可使用绘制的Shape对象 my_shape.draw() 。不要在Draw方法中创建形状,而是在Setup方法中创建它,然后将其绘制到 on_draw

为了获得更快的性能,可以将多个形状添加到ShapeElementList中并绘制该列表。这使得几乎可以像绘制一个形状一样快速地绘制无限形状。

参数:
  • point_list -- 三角形顶点元组。

  • color_sequence -- 一系列颜色,如 list ;每种颜色必须是 Color 实例或4长度RGBA tuple

arcade.shape_list.get_rectangle_points(center_x: float, center_y: float, width: float, height: float, tilt_angle: float = 0) Sequence[Tuple[float, float]][源代码]#

该实用程序函数将返回给定x、y中心、宽度、高度和旋转的矩形的所有四个坐标点。

参数:
  • center_x -- 矩形中心的X位置

  • center_y -- 矩形中心的Y位置

  • width -- 矩形的宽度

  • height -- 矩形的高度

  • tilt_angle -- 将矩形倾斜的角度(以度为单位