绘图-基本体#

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

绘制一条实心圆弧。用于绘制馅饼楔形或Pac-Man。

参数:
  • center_x -- 作为圆弧中心的X位置。

  • center_y -- 作为圆弧中心的Y位置。

  • width -- 弧线的宽度。

  • height -- 弧线的高度。

  • color -- 0-255通道值的3或4长度元组或 Color 举个例子。

  • start_angle -- 圆弧的起点角度(以度为单位)。

  • end_angle -- 圆弧的终点角度,以度为单位。

  • tilt_angle -- 角度圆弧倾斜(顺时针)。

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

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

绘制圆弧的外边。对于绘制曲线非常有用。

参数:
  • center_x -- 作为圆弧中心的X位置。

  • center_y -- 作为圆弧中心的Y位置。

  • width -- 弧线的宽度。

  • height -- 弧线的高度。

  • color -- 0-255通道值的3或4长度元组或 Color 举个例子。

  • start_angle -- 圆弧的起点角度(以度为单位)。

  • end_angle -- 圆弧的终点角度,以度为单位。

  • border_width -- 以像素为单位的线条宽度。

  • tilt_angle -- 角度圆弧倾斜(顺时针)。

  • num_segments -- 组成此圆的三角形线段的浮动。越高,质量越好,但渲染时间越慢。

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

画一个填满的圆圈。

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

  • center_y -- Y位置,即圆的中心。

  • radius -- 圆的宽度。

  • color -- 0-255通道值的3或4长度元组或 Color 举个例子。

  • tilt_angle -- 角度(以度为单位)以倾斜圆。适用于低段数圆

  • num_segments -- 组成此圆的三角形线段的数量。越高,质量越好,但渲染时间越慢。默认值-1表示Arcade将尝试根据圆的大小计算合理数量的线段。

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

画一个圆的轮廓。

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

  • center_y -- Y位置,即圆的中心。

  • radius -- 圆的宽度。

  • color -- 0-255通道值的3或4长度元组或 Color 举个例子。

  • border_width -- 圆形轮廓的宽度,以像素为单位。

  • tilt_angle -- 角度(以度为单位)使圆倾斜(顺时针)。适用于低段数圆

  • num_segments -- 组成此圆的三角形线段的数量。越高,质量越好,但渲染时间越慢。默认值-1表示Arcade将尝试根据圆的大小计算合理数量的线段。

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

画一个带填充的椭圆。

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

  • center_y -- Y位置,即圆的中心。

  • width -- 椭圆的宽度。

  • height -- 椭圆的高度。

  • color -- 0-255通道值的3或4长度元组或 Color 举个例子。

  • color -- 要么是A Color 实例或RGBA tuple 4字节值(0到255)。

  • tilt_angle -- 角度(以度为单位)以倾斜椭圆(顺时针方向)。在绘制线段数较低的圆时非常有用,例如,绘制一个八角形。

  • num_segments -- 组成此圆的三角形线段的数量。越高,质量越好,但渲染时间越慢。默认值-1表示Arcade将尝试根据圆的大小计算合理数量的线段。

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

画出椭圆的轮廓。

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

  • center_y -- Y位置,即圆的中心。

  • width -- 椭圆的宽度。

  • height -- 椭圆的高度。

  • color -- 0-255通道值的3或4长度元组或 Color 举个例子。

  • border_width -- 圆形轮廓的宽度,以像素为单位。

  • tilt_angle -- 角度(以度为单位)以倾斜椭圆(顺时针方向)。在绘制线段数较低的圆时非常有用,例如,绘制一个八角形。

  • num_segments -- 组成此圆的三角形线段的数量。越高,质量越好,但渲染时间越慢。默认值-1表示Arcade将尝试根据圆的大小计算合理数量的线段。

arcade.draw_line(start_x: float, start_y: float, end_x: float, end_y: float, color: Tuple[int, int, int, int], line_width: float = 1)[源代码]#

划一条线。

参数:
  • start_x -- 直线起点的X位置。

  • start_y -- 直线起点的Y位置。

  • end_x -- 直线终点的X位置。

  • end_y -- 直线终点的Y位置。

  • color -- 颜色,指定为RGBA元组或 Color 举个例子。

  • line_width -- 以像素为单位的线条宽度。

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

绘制一条多点直线。

参数:
  • point_list -- 组成该条带的x,y点的列表

  • color -- 颜色,指定为RGBA元组或 Color 举个例子。

  • line_width -- 线条宽度

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

画一组线。

在指定的每一对点之间画一条线。

参数:
  • point_list -- 组成直线的点的列表。每一点都在一个列表中。所以这是一份清单清单。

  • color -- 颜色,指定为RGBA元组或 Color 举个例子。

  • line_width -- 以像素为单位的线条宽度。

arcade.draw_lrbt_rectangle_filled(left: float, right: float, bottom: float, top: float, color: Tuple[int, int, int, int])[源代码]#

通过指定左、右、下和上边缘绘制矩形。

参数:
  • left -- 矩形左边缘的x坐标。

  • right -- 矩形右边缘的x坐标。

  • bottom -- 矩形底部的y坐标。

  • top -- 矩形顶部的y坐标。

  • color -- 矩形的颜色。

引发ValueError:

如果左>右或上<下,则引发。

arcade.draw_lrbt_rectangle_outline(left: float, right: float, bottom: float, top: float, color: Tuple[int, int, int, int], border_width: float = 1)[源代码]#

通过指定左、右、下和上边缘绘制矩形。

参数:
  • left -- 矩形左边缘的x坐标。

  • right -- 矩形右边缘的x坐标。

  • bottom -- 矩形底部的y坐标。

  • top -- 矩形顶部的y坐标。

  • color -- 矩形的颜色。

  • border_width -- 边框的宽度,以像素为单位。默认为1。

引发ValueError:

如果左>右或上<下,则引发。

arcade.draw_lrtb_rectangle_filled(left: float, right: float, top: float, bottom: float, color: Tuple[int, int, int, int])[源代码]#

通过指定左边缘、右边缘、上边缘和下边缘绘制矩形。

自 3.0 版本弃用: 使用 draw_lrbt_rectangle_filled() 相反,是这样!

参数:
  • left -- 矩形左边缘的x坐标。

  • right -- 矩形右边缘的x坐标。

  • top -- 矩形顶部的y坐标。

  • bottom -- 矩形底部的y坐标。

  • color -- 作为RGBA的矩形的颜色 tuple 或者:Py:Class`~arcade.tyes.Color`实例。

引发AttributeError:

如果左>右或上<下,则引发。

arcade.draw_lrtb_rectangle_outline(left: float, right: float, top: float, bottom: float, color: Tuple[int, int, int, int], border_width: float = 1)[源代码]#

通过指定左边缘、右边缘、上边缘和下边缘绘制矩形。

自 3.0 版本弃用: 使用 draw_lrbt_rectangle_outline() 相反,是这样!

参数:
  • left -- 矩形左边缘的x坐标。

  • right -- 矩形右边缘的x坐标。

  • top -- 矩形顶部的y坐标。

  • bottom -- 矩形底部的y坐标。

  • color -- 作为RGBA的矩形的颜色 tuple 或者:Py:Class`~arcade.tyes.Color`实例。

  • border_width -- 边框的宽度,以像素为单位。默认为1。

引发AttributeError:

如果左>右或上<下,则引发。

arcade.draw_lrwh_rectangle_textured(bottom_left_x: float, bottom_left_y: float, width: float, height: float, texture: Texture, angle: float = 0, alpha: int = 255)[源代码]#

绘制一个从左下角到右上角的纹理。

参数:
  • bottom_left_x -- 矩形左边缘的x坐标。

  • bottom_left_y -- 矩形底部的y坐标。

  • width -- 矩形的宽度。

  • height -- 矩形的高度。

  • texture -- 从Load_Texture()调用返回的纹理的标识符

  • angle -- 矩形的旋转。默认为零(顺时针)。

  • alpha -- 图像的透明度。0为完全透明,255(默认)可见

arcade.draw_parabola_filled(start_x: float, start_y: float, end_x: float, height: float, color: Tuple[int, int, int, int], tilt_angle: float = 0)[源代码]#

绘制一条填充的抛物线。

参数:
  • start_x -- 抛物线的起始x位置

  • start_y -- 抛物线的起点y位置

  • end_x -- 抛物线的终点x位置

  • height -- 抛物线的高度

  • color -- 0-255通道值的3或4长度元组或 Color 举个例子。

  • tilt_angle -- 抛物线的倾斜角度(顺时针)

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

绘制抛物线的轮廓。

参数:
  • start_x -- 抛物线的起始x位置

  • start_y -- 抛物线的起点y位置

  • end_x -- 抛物线的终点x位置

  • height -- 抛物线的高度

  • color -- 0-255通道值的3或4长度元组或 Color 举个例子。

  • border_width -- 抛物线的宽度

  • tilt_angle -- 抛物线的倾斜角度(顺时针)

arcade.draw_point(x: float, y: float, color: Tuple[int, int, int, int], size: float)[源代码]#

画一个点。

参数:
  • x -- 点的X位置。

  • y -- 点的Y位置。

  • color -- 颜色,指定为RGBA元组或 Color 举个例子。

  • size -- 以像素为单位的点大小。

arcade.draw_points(point_list: Sequence[Tuple[float, float]], color: Tuple[int, int, int, int], size: float = 1)[源代码]#

绘制一组点。

参数:
  • point_list -- 点的列表每个点都在列表中。所以这是一份清单清单。

  • color -- 颜色,指定为RGBA元组或 Color 举个例子。

  • size -- 以像素为单位的点大小。

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

绘制一个填充的多边形。

参数:
  • point_list -- 组成直线的点的列表。每一点都在一个列表中。所以这是一份清单清单。

  • color -- 以RGB或RGBA格式指定的颜色。

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

绘制一个多边形轮廓。也被称为“线循环”。

参数:
  • point_list -- 组成直线的点的列表。每一点都在一个列表中。所以这是一份清单清单。

  • color -- 作为RGBA的轮廓的颜色 tupleColor 举个例子。

  • line_width -- 以像素为单位的线条宽度。

arcade.draw_rectangle_filled(center_x: float, center_y: float, width: float, height: float, color: Tuple[int, int, int, int], tilt_angle: float = 0)[源代码]#

绘制一个填充的矩形。

参数:
  • center_x -- 矩形中心的X坐标。

  • center_y -- 矩形中心的Y坐标。

  • width -- 矩形的宽度。

  • height -- 矩形的高度。

  • color -- 作为RGBA的矩形的颜色 tuple 或者:Py:Class`~arcade.tyes.Color`实例。

  • tilt_angle -- 矩形的旋转(顺时针)。默认为零。

arcade.draw_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)[源代码]#

画一个矩形轮廓。

参数:
  • center_x -- 左上角矩形点的X坐标。

  • center_y -- 左上角矩形点的Y坐标。

  • width -- 矩形的宽度。

  • height -- 矩形的高度。

  • color -- 作为RGBA的矩形的颜色 tuple 或者:Py:Class`~arcade.tyes.Color`实例。

  • border_width -- 线条的宽度,以像素为单位。

  • tilt_angle -- 矩形的旋转。默认为零(顺时针)。

arcade.draw_scaled_texture_rectangle(center_x: float, center_y: float, texture: Texture, scale: float = 1.0, angle: float = 0, alpha: int = 255)[源代码]#

在屏幕上绘制一个带纹理的矩形。

警告

这种方法可能会很慢!

大多数用户应该考虑使用 arcade.Sprite 使用 arcade.SpriteList 而不是这个函数。

OpenGL通过使用批处理一次绘制多个对象来加快绘制速度。此方法不能做到这一点。

如果您需要更好的控制或比Arcade所允许的更少的开销,请考虑 pyglet's batching features

参数:
  • center_x -- 矩形中心的X坐标。

  • center_y -- 矩形中心的Y坐标。

  • texture -- 从Load_Texture()调用返回的纹理的标识符

  • scale -- 纹理比例

  • angle -- 矩形的旋转(顺时针)。默认为零。

  • alpha -- 图像的透明度。0为完全透明,255(默认)为完全可见

arcade.draw_texture_rectangle(center_x: float, center_y: float, width: float, height: float, texture: Texture, angle: float = 0, alpha: int = 255)[源代码]#

在屏幕上绘制一个带纹理的矩形。

参数:
  • center_x -- 矩形中心的X坐标。

  • center_y -- 矩形中心的Y坐标。

  • width -- 纹理的宽度

  • height -- 纹理高度

  • texture -- 从Load_Texture()调用返回的纹理的标识符

  • angle -- 矩形的旋转。默认为零(顺时针)。

  • alpha -- 图像的透明度。0为完全透明,255(默认)可见

arcade.draw_triangle_filled(x1: float, y1: float, x2: float, y2: float, x3: float, y3: float, color: Tuple[int, int, int, int])[源代码]#

画一个填充的三角形。

参数:
  • x1 -- 第一个坐标的X值。

  • y1 -- 第一个坐标的Y值。

  • x2 -- 第二个坐标的X值。

  • y2 -- 第二个坐标的Y值。

  • x3 -- 第三个坐标的X值。

  • y3 -- 第三个坐标的Y值。

  • color -- 作为RGBA的三角形的颜色 tupleColor 举个例子。

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

画一个三角形的轮廓。

参数:
  • x1 -- 第一个坐标的X值。

  • y1 -- 第一个坐标的Y值。

  • x2 -- 第二个坐标的X值。

  • y2 -- 第二个坐标的Y值。

  • x3 -- 第三个坐标的X值。

  • y3 -- 第三个坐标的Y值。

  • color -- 作为RGBA的三角形的RGBA255 tuple 或者:Py:Class`~arcade.tyes.Color`实例。

  • border_width -- 边框宽度(以像素为单位)。默认为1。

arcade.draw_xywh_rectangle_filled(bottom_left_x: float, bottom_left_y: float, width: float, height: float, color: Tuple[int, int, int, int])[源代码]#

绘制一个从左下角到右上角的实心矩形

参数:
  • bottom_left_x -- 矩形左边缘的x坐标。

  • bottom_left_y -- 矩形底部的y坐标。

  • width -- 矩形的宽度。

  • height -- 矩形的高度。

  • color -- RGBA中矩形的颜色 tuple 或者:Py:Class`~arcade.tyes.Color`实例。

arcade.draw_xywh_rectangle_outline(bottom_left_x: float, bottom_left_y: float, width: float, height: float, color: Tuple[int, int, int, int], border_width: float = 1)[源代码]#

画一个从左下角到右上角的矩形

参数:
  • bottom_left_x -- 矩形左边缘的x坐标。

  • bottom_left_y -- 矩形底部的y坐标。

  • width -- 矩形的宽度。

  • height -- 矩形的高度。

  • color -- 作为RGBA的矩形的颜色 tuple 或者:Py:Class`~arcade.tyes.Color`实例。

  • border_width -- 边框的宽度,以像素为单位。默认为1。

arcade.get_image(x: int = 0, y: int = 0, width: int | None = None, height: int | None = None) Image[源代码]#

从屏幕上获取图像。

示例::

image = get_image()
image.save('screenshot.png', 'PNG')
参数:
  • x -- 起点(左)x位置

  • y -- 起点(顶部)y位置

  • width -- 图像的宽度。留空以抓取图像的其余部分

  • height -- 图像的高度。留空以抓取图像的其余部分

返回:

枕头形象

arcade.get_pixel(x: int, y: int, components: int = 3) Tuple[int, ...][源代码]#

给定x,y,将返回该点的颜色值。

参数:
  • x -- X位置

  • y -- Y位置

  • components -- 要提取的组件数。默认情况下,我们获取3 3组件(RGB)。4个组件将是RGBA。