pyglet 2.1.13__py3-none-any.whl → 3.0.dev1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (267) hide show
  1. pyglet/__init__.py +67 -61
  2. pyglet/__init__.pyi +15 -8
  3. pyglet/app/__init__.py +22 -13
  4. pyglet/app/async_app.py +212 -0
  5. pyglet/app/base.py +2 -1
  6. pyglet/app/{xlib.py → linux.py} +3 -3
  7. pyglet/config/__init__.py +101 -0
  8. pyglet/config/gl/__init__.py +30 -0
  9. pyglet/config/gl/egl.py +120 -0
  10. pyglet/config/gl/macos.py +262 -0
  11. pyglet/config/gl/windows.py +267 -0
  12. pyglet/config/gl/x11.py +142 -0
  13. pyglet/customtypes.py +43 -2
  14. pyglet/display/__init__.py +8 -6
  15. pyglet/display/base.py +3 -63
  16. pyglet/display/cocoa.py +12 -17
  17. pyglet/display/emscripten.py +39 -0
  18. pyglet/display/headless.py +23 -30
  19. pyglet/display/wayland.py +157 -0
  20. pyglet/display/win32.py +5 -21
  21. pyglet/display/xlib.py +19 -27
  22. pyglet/display/xlib_vidmoderestore.py +2 -2
  23. pyglet/enums.py +183 -0
  24. pyglet/event.py +0 -1
  25. pyglet/experimental/geoshader_sprite.py +15 -13
  26. pyglet/experimental/hidraw.py +6 -15
  27. pyglet/experimental/multitexture_sprite.py +31 -19
  28. pyglet/experimental/particles.py +13 -35
  29. pyglet/font/__init__.py +251 -85
  30. pyglet/font/base.py +116 -61
  31. pyglet/font/dwrite/__init__.py +349 -204
  32. pyglet/font/dwrite/dwrite_lib.py +27 -5
  33. pyglet/font/fontconfig.py +14 -6
  34. pyglet/font/freetype.py +138 -87
  35. pyglet/font/freetype_lib.py +19 -0
  36. pyglet/font/group.py +179 -0
  37. pyglet/font/harfbuzz/__init__.py +3 -3
  38. pyglet/font/pyodide_js.py +310 -0
  39. pyglet/font/quartz.py +319 -126
  40. pyglet/font/ttf.py +45 -3
  41. pyglet/font/user.py +14 -19
  42. pyglet/font/win32.py +45 -21
  43. pyglet/graphics/__init__.py +8 -787
  44. pyglet/graphics/allocation.py +115 -1
  45. pyglet/graphics/api/__init__.py +77 -0
  46. pyglet/graphics/api/base.py +299 -0
  47. pyglet/graphics/api/gl/__init__.py +58 -0
  48. pyglet/graphics/api/gl/base.py +24 -0
  49. pyglet/graphics/{vertexbuffer.py → api/gl/buffer.py} +104 -159
  50. pyglet/graphics/api/gl/cocoa/context.py +76 -0
  51. pyglet/graphics/api/gl/context.py +391 -0
  52. pyglet/graphics/api/gl/default_shaders.py +0 -0
  53. pyglet/graphics/api/gl/draw.py +627 -0
  54. pyglet/graphics/api/gl/egl/__init__.py +0 -0
  55. pyglet/graphics/api/gl/egl/context.py +92 -0
  56. pyglet/graphics/api/gl/enums.py +76 -0
  57. pyglet/graphics/api/gl/framebuffer.py +315 -0
  58. pyglet/graphics/api/gl/gl.py +5463 -0
  59. pyglet/graphics/api/gl/gl_info.py +188 -0
  60. pyglet/graphics/api/gl/global_opengl.py +226 -0
  61. pyglet/{gl → graphics/api/gl}/lib.py +34 -18
  62. pyglet/graphics/api/gl/shader.py +1476 -0
  63. pyglet/graphics/api/gl/shapes.py +55 -0
  64. pyglet/graphics/api/gl/sprite.py +102 -0
  65. pyglet/graphics/api/gl/state.py +219 -0
  66. pyglet/graphics/api/gl/text.py +190 -0
  67. pyglet/graphics/api/gl/texture.py +1526 -0
  68. pyglet/graphics/{vertexarray.py → api/gl/vertexarray.py} +11 -13
  69. pyglet/graphics/api/gl/vertexdomain.py +751 -0
  70. pyglet/graphics/api/gl/win32/__init__.py +0 -0
  71. pyglet/graphics/api/gl/win32/context.py +108 -0
  72. pyglet/graphics/api/gl/win32/wgl_info.py +24 -0
  73. pyglet/graphics/api/gl/xlib/__init__.py +0 -0
  74. pyglet/graphics/api/gl/xlib/context.py +174 -0
  75. pyglet/{gl → graphics/api/gl/xlib}/glx_info.py +26 -31
  76. pyglet/graphics/api/gl1/__init__.py +0 -0
  77. pyglet/{gl → graphics/api/gl1}/gl_compat.py +3 -2
  78. pyglet/graphics/api/gl2/__init__.py +0 -0
  79. pyglet/graphics/api/gl2/buffer.py +320 -0
  80. pyglet/graphics/api/gl2/draw.py +600 -0
  81. pyglet/graphics/api/gl2/global_opengl.py +122 -0
  82. pyglet/graphics/api/gl2/shader.py +200 -0
  83. pyglet/graphics/api/gl2/shapes.py +51 -0
  84. pyglet/graphics/api/gl2/sprite.py +79 -0
  85. pyglet/graphics/api/gl2/text.py +175 -0
  86. pyglet/graphics/api/gl2/vertexdomain.py +364 -0
  87. pyglet/graphics/api/webgl/__init__.py +233 -0
  88. pyglet/graphics/api/webgl/buffer.py +302 -0
  89. pyglet/graphics/api/webgl/context.py +234 -0
  90. pyglet/graphics/api/webgl/draw.py +590 -0
  91. pyglet/graphics/api/webgl/enums.py +76 -0
  92. pyglet/graphics/api/webgl/framebuffer.py +360 -0
  93. pyglet/graphics/api/webgl/gl.py +1537 -0
  94. pyglet/graphics/api/webgl/gl_info.py +130 -0
  95. pyglet/graphics/api/webgl/shader.py +1346 -0
  96. pyglet/graphics/api/webgl/shapes.py +92 -0
  97. pyglet/graphics/api/webgl/sprite.py +102 -0
  98. pyglet/graphics/api/webgl/state.py +227 -0
  99. pyglet/graphics/api/webgl/text.py +187 -0
  100. pyglet/graphics/api/webgl/texture.py +1227 -0
  101. pyglet/graphics/api/webgl/vertexarray.py +54 -0
  102. pyglet/graphics/api/webgl/vertexdomain.py +616 -0
  103. pyglet/graphics/api/webgl/webgl_js.pyi +307 -0
  104. pyglet/{image → graphics}/atlas.py +33 -32
  105. pyglet/graphics/base.py +10 -0
  106. pyglet/graphics/buffer.py +245 -0
  107. pyglet/graphics/draw.py +578 -0
  108. pyglet/graphics/framebuffer.py +26 -0
  109. pyglet/graphics/instance.py +178 -69
  110. pyglet/graphics/shader.py +267 -1553
  111. pyglet/graphics/state.py +83 -0
  112. pyglet/graphics/texture.py +703 -0
  113. pyglet/graphics/vertexdomain.py +695 -538
  114. pyglet/gui/ninepatch.py +10 -10
  115. pyglet/gui/widgets.py +120 -10
  116. pyglet/image/__init__.py +20 -1973
  117. pyglet/image/animation.py +12 -12
  118. pyglet/image/base.py +730 -0
  119. pyglet/image/codecs/__init__.py +9 -0
  120. pyglet/image/codecs/bmp.py +53 -30
  121. pyglet/image/codecs/dds.py +53 -31
  122. pyglet/image/codecs/gdiplus.py +38 -14
  123. pyglet/image/codecs/gdkpixbuf2.py +0 -2
  124. pyglet/image/codecs/js_image.py +99 -0
  125. pyglet/image/codecs/ktx2.py +161 -0
  126. pyglet/image/codecs/pil.py +1 -1
  127. pyglet/image/codecs/png.py +1 -1
  128. pyglet/image/codecs/wic.py +11 -2
  129. pyglet/info.py +26 -24
  130. pyglet/input/__init__.py +8 -0
  131. pyglet/input/base.py +163 -105
  132. pyglet/input/controller.py +13 -19
  133. pyglet/input/controller_db.py +39 -24
  134. pyglet/input/emscripten/__init__.py +18 -0
  135. pyglet/input/emscripten/gamepad_js.py +397 -0
  136. pyglet/input/linux/__init__.py +11 -5
  137. pyglet/input/linux/evdev.py +10 -11
  138. pyglet/input/linux/x11_xinput.py +2 -2
  139. pyglet/input/linux/x11_xinput_tablet.py +1 -1
  140. pyglet/input/macos/__init__.py +7 -2
  141. pyglet/input/macos/darwin_gc.py +559 -0
  142. pyglet/input/win32/__init__.py +1 -1
  143. pyglet/input/win32/directinput.py +34 -29
  144. pyglet/input/win32/xinput.py +11 -61
  145. pyglet/lib.py +3 -3
  146. pyglet/libs/__init__.py +1 -1
  147. pyglet/{gl → libs/darwin}/agl.py +1 -1
  148. pyglet/libs/darwin/cocoapy/__init__.py +2 -2
  149. pyglet/libs/darwin/cocoapy/cocoahelpers.py +181 -0
  150. pyglet/libs/darwin/cocoapy/cocoalibs.py +31 -0
  151. pyglet/libs/darwin/cocoapy/cocoatypes.py +27 -0
  152. pyglet/libs/darwin/cocoapy/runtime.py +81 -45
  153. pyglet/libs/darwin/coreaudio.py +4 -4
  154. pyglet/{gl → libs/darwin}/lib_agl.py +9 -8
  155. pyglet/libs/darwin/quartzkey.py +1 -3
  156. pyglet/libs/egl/__init__.py +2 -0
  157. pyglet/libs/egl/egl_lib.py +576 -0
  158. pyglet/libs/egl/eglext.py +51 -5
  159. pyglet/libs/linux/__init__.py +0 -0
  160. pyglet/libs/linux/egl/__init__.py +0 -0
  161. pyglet/libs/linux/egl/eglext.py +22 -0
  162. pyglet/libs/linux/glx/__init__.py +0 -0
  163. pyglet/{gl → libs/linux/glx}/glx.py +13 -14
  164. pyglet/{gl → libs/linux/glx}/glxext_arb.py +408 -192
  165. pyglet/{gl → libs/linux/glx}/glxext_mesa.py +1 -1
  166. pyglet/{gl → libs/linux/glx}/glxext_nv.py +345 -164
  167. pyglet/{gl → libs/linux/glx}/lib_glx.py +3 -2
  168. pyglet/libs/linux/wayland/__init__.py +0 -0
  169. pyglet/libs/linux/wayland/client.py +1068 -0
  170. pyglet/libs/linux/wayland/lib_wayland.py +207 -0
  171. pyglet/libs/linux/wayland/wayland_egl.py +38 -0
  172. pyglet/libs/{wayland → linux/wayland}/xkbcommon.py +26 -0
  173. pyglet/libs/{x11 → linux/x11}/xf86vmode.py +4 -4
  174. pyglet/libs/{x11 → linux/x11}/xinerama.py +2 -2
  175. pyglet/libs/{x11 → linux/x11}/xinput.py +10 -10
  176. pyglet/libs/linux/x11/xrandr.py +0 -0
  177. pyglet/libs/{x11 → linux/x11}/xrender.py +1 -1
  178. pyglet/libs/shared/__init__.py +0 -0
  179. pyglet/libs/shared/spirv/__init__.py +0 -0
  180. pyglet/libs/shared/spirv/lib_shaderc.py +85 -0
  181. pyglet/libs/shared/spirv/lib_spirv_cross.py +126 -0
  182. pyglet/libs/win32/__init__.py +28 -8
  183. pyglet/libs/win32/constants.py +59 -48
  184. pyglet/libs/win32/context_managers.py +20 -3
  185. pyglet/libs/win32/dinput.py +105 -88
  186. pyglet/{gl → libs/win32}/lib_wgl.py +52 -26
  187. pyglet/libs/win32/types.py +58 -23
  188. pyglet/{gl → libs/win32}/wgl.py +32 -25
  189. pyglet/{gl → libs/win32}/wglext_arb.py +364 -2
  190. pyglet/media/__init__.py +9 -10
  191. pyglet/media/codecs/__init__.py +12 -1
  192. pyglet/media/codecs/base.py +99 -96
  193. pyglet/media/codecs/ffmpeg.py +2 -2
  194. pyglet/media/codecs/ffmpeg_lib/libavformat.py +3 -8
  195. pyglet/media/codecs/webaudio_pyodide.py +111 -0
  196. pyglet/media/drivers/__init__.py +9 -4
  197. pyglet/media/drivers/base.py +4 -4
  198. pyglet/media/drivers/openal/__init__.py +1 -1
  199. pyglet/media/drivers/openal/adaptation.py +3 -3
  200. pyglet/media/drivers/pulse/__init__.py +1 -1
  201. pyglet/media/drivers/pulse/adaptation.py +3 -3
  202. pyglet/media/drivers/pyodide_js/__init__.py +8 -0
  203. pyglet/media/drivers/pyodide_js/adaptation.py +288 -0
  204. pyglet/media/drivers/xaudio2/adaptation.py +3 -3
  205. pyglet/media/player.py +276 -193
  206. pyglet/media/player_worker_thread.py +1 -1
  207. pyglet/model/__init__.py +39 -29
  208. pyglet/model/codecs/base.py +4 -4
  209. pyglet/model/codecs/gltf.py +3 -3
  210. pyglet/model/codecs/obj.py +71 -43
  211. pyglet/resource.py +129 -78
  212. pyglet/shapes.py +154 -194
  213. pyglet/sprite.py +47 -164
  214. pyglet/text/__init__.py +44 -54
  215. pyglet/text/caret.py +12 -7
  216. pyglet/text/document.py +19 -17
  217. pyglet/text/formats/html.py +2 -2
  218. pyglet/text/formats/structured.py +10 -40
  219. pyglet/text/layout/__init__.py +20 -13
  220. pyglet/text/layout/base.py +176 -287
  221. pyglet/text/layout/incremental.py +9 -10
  222. pyglet/text/layout/scrolling.py +7 -95
  223. pyglet/window/__init__.py +183 -172
  224. pyglet/window/cocoa/__init__.py +62 -51
  225. pyglet/window/cocoa/pyglet_delegate.py +2 -25
  226. pyglet/window/cocoa/pyglet_view.py +9 -8
  227. pyglet/window/dialog/__init__.py +184 -0
  228. pyglet/window/dialog/base.py +99 -0
  229. pyglet/window/dialog/darwin.py +121 -0
  230. pyglet/window/dialog/linux.py +72 -0
  231. pyglet/window/dialog/windows.py +194 -0
  232. pyglet/window/emscripten/__init__.py +779 -0
  233. pyglet/window/headless/__init__.py +44 -28
  234. pyglet/window/key.py +2 -0
  235. pyglet/window/mouse.py +2 -2
  236. pyglet/window/wayland/__init__.py +377 -0
  237. pyglet/window/win32/__init__.py +101 -46
  238. pyglet/window/xlib/__init__.py +104 -66
  239. {pyglet-2.1.13.dist-info → pyglet-3.0.dev1.dist-info}/METADATA +2 -3
  240. pyglet-3.0.dev1.dist-info/RECORD +322 -0
  241. {pyglet-2.1.13.dist-info → pyglet-3.0.dev1.dist-info}/WHEEL +1 -1
  242. pyglet/gl/__init__.py +0 -208
  243. pyglet/gl/base.py +0 -499
  244. pyglet/gl/cocoa.py +0 -309
  245. pyglet/gl/gl.py +0 -4625
  246. pyglet/gl/gl.pyi +0 -2320
  247. pyglet/gl/gl_compat.pyi +0 -3097
  248. pyglet/gl/gl_info.py +0 -190
  249. pyglet/gl/headless.py +0 -166
  250. pyglet/gl/wgl_info.py +0 -36
  251. pyglet/gl/wglext_nv.py +0 -1096
  252. pyglet/gl/win32.py +0 -268
  253. pyglet/gl/xlib.py +0 -295
  254. pyglet/image/buffer.py +0 -274
  255. pyglet/image/codecs/s3tc.py +0 -354
  256. pyglet/libs/x11/xrandr.py +0 -166
  257. pyglet-2.1.13.dist-info/RECORD +0 -234
  258. /pyglet/{libs/wayland → graphics/api/gl/cocoa}/__init__.py +0 -0
  259. /pyglet/libs/{egl → linux/egl}/egl.py +0 -0
  260. /pyglet/libs/{egl → linux/egl}/lib.py +0 -0
  261. /pyglet/libs/{ioctl.py → linux/ioctl.py} +0 -0
  262. /pyglet/libs/{wayland → linux/wayland}/gbm.py +0 -0
  263. /pyglet/libs/{x11 → linux/x11}/__init__.py +0 -0
  264. /pyglet/libs/{x11 → linux/x11}/cursorfont.py +0 -0
  265. /pyglet/libs/{x11 → linux/x11}/xlib.py +0 -0
  266. /pyglet/libs/{x11 → linux/x11}/xsync.py +0 -0
  267. {pyglet-2.1.13.dist-info/licenses → pyglet-3.0.dev1.dist-info}/LICENSE +0 -0
pyglet/shapes.py CHANGED
@@ -72,66 +72,23 @@ from typing import TYPE_CHECKING, Sequence, Tuple, Union
72
72
 
73
73
  import pyglet
74
74
  from pyglet.extlibs import earcut
75
- from pyglet.gl import GL_BLEND, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA, GL_TRIANGLES, glBlendFunc, glDisable, glEnable
76
- from pyglet.graphics import Batch, Group
75
+ from pyglet.graphics import Batch, Group, ShaderProgram
76
+ from pyglet.enums import BlendFactor
77
77
  from pyglet.math import Vec2
78
78
 
79
79
  if TYPE_CHECKING:
80
80
  from pyglet.graphics.shader import ShaderProgram
81
81
 
82
- vertex_source = """#version 150 core
83
- in vec2 position;
84
- in vec2 translation;
85
- in vec4 colors;
86
- in float zposition;
87
-
88
- in float rotation;
89
-
90
-
91
- out vec4 vertex_colors;
92
-
93
- uniform WindowBlock
94
- {
95
- mat4 projection;
96
- mat4 view;
97
- } window;
98
-
99
- mat4 m_rotation = mat4(1.0);
100
- mat4 m_translate = mat4(1.0);
101
-
102
- void main()
103
- {
104
- m_translate[3][0] = translation.x;
105
- m_translate[3][1] = translation.y;
106
- m_rotation[0][0] = cos(-radians(rotation));
107
- m_rotation[0][1] = sin(-radians(rotation));
108
- m_rotation[1][0] = -sin(-radians(rotation));
109
- m_rotation[1][1] = cos(-radians(rotation));
110
-
111
- gl_Position = window.projection * window.view * m_translate * m_rotation * vec4(position, zposition, 1.0);
112
- vertex_colors = colors;
113
- }
114
- """
115
-
116
- fragment_source = """#version 150 core
117
- in vec4 vertex_colors;
118
- out vec4 final_color;
119
-
120
- void main()
121
- {
122
- final_color = vertex_colors;
123
- // No GL_ALPHA_TEST in core, use shader to discard.
124
- if(final_color.a < 0.01){
125
- discard;
126
- }
127
- }
128
- """
129
-
130
-
131
- def get_default_shader() -> ShaderProgram:
132
- return pyglet.gl.current_context.create_program((vertex_source, 'vertex'),
133
- (fragment_source, 'fragment'))
134
82
 
83
+ if pyglet.options.backend in ("opengl", "gles3"):
84
+ from pyglet.graphics.api.gl.shapes import get_default_shader
85
+ elif pyglet.options.backend in ("gl2", "gles2"):
86
+ from pyglet.graphics.api.gl2.shapes import get_default_shader
87
+ elif pyglet.options.backend == "webgl":
88
+ from pyglet.graphics.api.webgl.shapes import get_default_shader
89
+ elif pyglet.options.backend == "vulkan":
90
+ from pyglet.graphics.api.vulkan.shapes import get_default_shader
91
+ from pyglet.graphics import GeometryMode
135
92
 
136
93
  def _rotate_point(center: tuple[float, float], point: tuple[float, float], angle: float) -> tuple[float, float]:
137
94
  prev_angle = math.atan2(point[1] - center[1], point[0] - center[0])
@@ -243,14 +200,19 @@ def _get_segment(p0: tuple[float, float] | list[float], p1: tuple[float, float]
243
200
  return v_miter2, scale2, v1[0], v1[1], v2[0], v2[1], v3[0], v3[1], v4[0], v4[1], v5[0], v5[1], v6[0], v6[1]
244
201
 
245
202
 
203
+
204
+
246
205
  class _ShapeGroup(Group):
247
206
  """Shared Shape rendering Group.
248
207
 
249
208
  The group is automatically coalesced with other shape groups
250
209
  sharing the same parent group and blend parameters.
251
210
  """
211
+ blend_src: int
212
+ blend_dest: int
252
213
 
253
- def __init__(self, blend_src: int, blend_dest: int, program: ShaderProgram, parent: Group | None = None) -> None:
214
+ def __init__(self, blend_src: BlendFactor, blend_dest: BlendFactor, program: ShaderProgram,
215
+ parent: Group | None = None) -> None:
254
216
  """Create a Shape group.
255
217
 
256
218
  The group is created internally. Usually you do not
@@ -267,28 +229,8 @@ class _ShapeGroup(Group):
267
229
  Optional parent group.
268
230
  """
269
231
  super().__init__(parent=parent)
270
- self.program = program
271
- self.blend_src = blend_src
272
- self.blend_dest = blend_dest
273
-
274
- def set_state(self) -> None:
275
- self.program.bind()
276
- glEnable(GL_BLEND)
277
- glBlendFunc(self.blend_src, self.blend_dest)
278
-
279
- def unset_state(self) -> None:
280
- glDisable(GL_BLEND)
281
- self.program.unbind()
282
-
283
- def __eq__(self, other: Group | _ShapeGroup) -> None:
284
- return (other.__class__ is self.__class__ and
285
- self.program == other.program and
286
- self.parent == other.parent and
287
- self.blend_src == other.blend_src and
288
- self.blend_dest == other.blend_dest)
289
-
290
- def __hash__(self) -> int:
291
- return hash((self.program, self.parent, self.blend_src, self.blend_dest))
232
+ self.set_shader_program(program)
233
+ self.set_blend(blend_src, blend_dest)
292
234
 
293
235
 
294
236
  class ShapeBase(ABC):
@@ -317,13 +259,13 @@ class ShapeBase(ABC):
317
259
  _num_verts: int = 0
318
260
  _user_group: Group | None = None
319
261
  _vertex_list = None
320
- _draw_mode: int = GL_TRIANGLES
262
+ _draw_mode: GeometryMode = GeometryMode.TRIANGLES
321
263
  group_class: Group = _ShapeGroup
322
264
 
323
265
  def __init__(self,
324
266
  vertex_count: int,
325
- blend_src: int = GL_SRC_ALPHA,
326
- blend_dest: int = GL_ONE_MINUS_SRC_ALPHA,
267
+ blend_src: BlendFactor = BlendFactor.SRC_ALPHA,
268
+ blend_dest: BlendFactor = BlendFactor.ONE_MINUS_SRC_ALPHA,
327
269
  batch: Batch | None = None,
328
270
  group: Group | None = None,
329
271
  program: ShaderProgram | None = None,
@@ -336,7 +278,7 @@ class ShapeBase(ABC):
336
278
  blend_src:
337
279
  OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
338
280
  blend_dest:
339
- OpenGL blend destination mode; for example, ``GL_ONE_MINUS_SRC_ALPHA``.
281
+ OpenGL blend destination mode; for example, ``ONE_MINUS_SRC_ALPHA``.
340
282
  batch:
341
283
  Optional batch object.
342
284
  group:
@@ -385,7 +327,7 @@ class ShapeBase(ABC):
385
327
  self._vertex_list.colors[:] = self._rgba * self._num_verts
386
328
 
387
329
  def _update_translation(self) -> None:
388
- self._vertex_list.translation[:] = (self._x, self._y) * self._num_verts
330
+ self._vertex_list.translation[:] = (self._x, self._y, self._z) * self._num_verts
389
331
 
390
332
  def _create_vertex_list(self) -> None:
391
333
  """Build internal vertex list.
@@ -413,7 +355,7 @@ class ShapeBase(ABC):
413
355
  raise NotImplementedError("_update_vertices must be defined for every ShapeBase subclass")
414
356
 
415
357
  @property
416
- def blend_mode(self) -> tuple[int, int]:
358
+ def blend_mode(self) -> tuple[BlendFactor, BlendFactor]:
417
359
  """The current blend mode applied to this shape.
418
360
 
419
361
  .. note:: Changing this can be an expensive operation as it involves a group creation and transfer.
@@ -452,7 +394,7 @@ class ShapeBase(ABC):
452
394
  self._group = self.get_shape_group()
453
395
 
454
396
  if (self._batch and
455
- self._batch.update_shader(self._vertex_list, GL_TRIANGLES, self._group, program)):
397
+ self._batch.update_shader(self._vertex_list, self._draw_mode, self._group, program)):
456
398
  # Exit early if changing domain is not needed.
457
399
  return
458
400
 
@@ -502,9 +444,10 @@ class ShapeBase(ABC):
502
444
  and call its :py:meth:`~Batch.draw` method.
503
445
 
504
446
  """
505
- self._group.set_state_recursive()
447
+ ctx = pyglet.graphics.api.core.current_context
448
+ self._group.set_state_recursive(ctx)
506
449
  self._vertex_list.draw(self._draw_mode)
507
- self._group.unset_state_recursive()
450
+ self._group.unset_state_recursive(ctx)
508
451
 
509
452
  def delete(self) -> None:
510
453
  """Force immediate removal of the shape from video memory.
@@ -572,7 +515,7 @@ class ShapeBase(ABC):
572
515
  @z.setter
573
516
  def z(self, value: float) -> None:
574
517
  self._z = value
575
- self._vertex_list.zposition = (value,) * self._num_verts
518
+ self._update_translation()
576
519
 
577
520
  @property
578
521
  def position(self) -> tuple[float, float]:
@@ -690,7 +633,7 @@ class ShapeBase(ABC):
690
633
 
691
634
  Opacity is implemented as the alpha component of a shape's
692
635
  :py:attr:`.color`. When part of a group with a default blend
693
- mode of ``(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)``, opacities
636
+ mode of ``(GL_SRC_ALPHA, ONE_MINUS_SRC_ALPHA)``, opacities
694
637
  below ``255`` draw with fractional opacity over the background:
695
638
 
696
639
  .. list-table:: Example Values & Effects
@@ -789,8 +732,8 @@ class Arc(ShapeBase):
789
732
  closed: bool = False,
790
733
  thickness: float = 1.0,
791
734
  color: tuple[int, int, int, int] | tuple[int, int, int] = (255, 255, 255, 255),
792
- blend_src: int = GL_SRC_ALPHA,
793
- blend_dest: int = GL_ONE_MINUS_SRC_ALPHA,
735
+ blend_src: BlendFactor = BlendFactor.SRC_ALPHA,
736
+ blend_dest: BlendFactor = BlendFactor.ONE_MINUS_SRC_ALPHA,
794
737
  batch: Batch | None = None,
795
738
  group: Group | None = None,
796
739
  program: ShaderProgram | None = None,
@@ -828,7 +771,7 @@ class Arc(ShapeBase):
828
771
  blend_src:
829
772
  OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
830
773
  blend_dest:
831
- OpenGL blend destination mode; for example, ``GL_ONE_MINUS_SRC_ALPHA``.
774
+ OpenGL blend destination mode; for example, ``ONE_MINUS_SRC_ALPHA``.
832
775
  batch:
833
776
  Optional batch to add the shape to.
834
777
  group:
@@ -864,8 +807,9 @@ class Arc(ShapeBase):
864
807
  self._num_verts, self._draw_mode, self._batch, self._group,
865
808
  position=('f', self._get_vertices()),
866
809
  colors=('Bn', self._rgba * self._num_verts),
867
- translation=('f', (self._x, self._y) * self._num_verts),
868
- rotation=('f', (self._rotation,) * self._num_verts))
810
+ translation=('f', (self._x, self._y, self._z) * self._num_verts),
811
+ rotation=('f', (self._rotation,) * self._num_verts),
812
+ )
869
813
 
870
814
  def _get_vertices(self) -> Sequence[float]:
871
815
  if not self._visible:
@@ -971,8 +915,8 @@ class BezierCurve(ShapeBase):
971
915
  segments: int = 100,
972
916
  thickness: int = 1.0,
973
917
  color: tuple[int, int, int, int] | tuple[int, int, int] = (255, 255, 255, 255),
974
- blend_src: int = GL_SRC_ALPHA,
975
- blend_dest: int = GL_ONE_MINUS_SRC_ALPHA,
918
+ blend_src: BlendFactor = BlendFactor.SRC_ALPHA,
919
+ blend_dest: BlendFactor = BlendFactor.ONE_MINUS_SRC_ALPHA,
976
920
  batch: Batch | None = None,
977
921
  group: Group | None = None,
978
922
  program: ShaderProgram | None = None,
@@ -1000,7 +944,7 @@ class BezierCurve(ShapeBase):
1000
944
  blend_src:
1001
945
  OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
1002
946
  blend_dest:
1003
- OpenGL blend destination mode; for example, ``GL_ONE_MINUS_SRC_ALPHA``.
947
+ OpenGL blend destination mode; for example, ``ONE_MINUS_SRC_ALPHA``.
1004
948
  batch:
1005
949
  Optional batch to add the shape to.
1006
950
  group:
@@ -1035,8 +979,9 @@ class BezierCurve(ShapeBase):
1035
979
  self._num_verts, self._draw_mode, self._batch, self._group,
1036
980
  position=('f', self._get_vertices()),
1037
981
  colors=('Bn', self._rgba * self._num_verts),
1038
- translation=('f', (self._x, self._y) * self._num_verts),
1039
- rotation=('f', (self._rotation,) * self._num_verts))
982
+ translation=('f', (self._x, self._y, self._z) * self._num_verts),
983
+ rotation=('f', (self._rotation,) * self._num_verts),
984
+ )
1040
985
 
1041
986
  def _get_vertices(self) -> Sequence[float]:
1042
987
  if not self._visible:
@@ -1114,8 +1059,8 @@ class Circle(ShapeBase):
1114
1059
  radius: float,
1115
1060
  segments: int | None = None,
1116
1061
  color: tuple[int, int, int, int] | tuple[int, int, int] = (255, 255, 255, 255),
1117
- blend_src: int = GL_SRC_ALPHA,
1118
- blend_dest: int = GL_ONE_MINUS_SRC_ALPHA,
1062
+ blend_src: BlendFactor = BlendFactor.SRC_ALPHA,
1063
+ blend_dest: BlendFactor = BlendFactor.ONE_MINUS_SRC_ALPHA,
1119
1064
  batch: Batch | None = None,
1120
1065
  group: Group | None = None,
1121
1066
  program: ShaderProgram | None = None,
@@ -1143,7 +1088,7 @@ class Circle(ShapeBase):
1143
1088
  blend_src:
1144
1089
  OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
1145
1090
  blend_dest:
1146
- OpenGL blend destination mode; for example, ``GL_ONE_MINUS_SRC_ALPHA``.
1091
+ OpenGL blend destination mode; for example, ``ONE_MINUS_SRC_ALPHA``.
1147
1092
  batch:
1148
1093
  Optional batch to add the shape to.
1149
1094
  group:
@@ -1169,12 +1114,14 @@ class Circle(ShapeBase):
1169
1114
  return math.dist((self._x - self._anchor_x, self._y - self._anchor_y), point) < self._radius
1170
1115
 
1171
1116
  def _create_vertex_list(self) -> None:
1117
+ vert_count = self._segments * 3
1172
1118
  self._vertex_list = self._program.vertex_list(
1173
- self._segments * 3, self._draw_mode, self._batch, self._group,
1119
+ vert_count, self._draw_mode, self._batch, self._group,
1174
1120
  position=('f', self._get_vertices()),
1175
- colors=('Bn', self._rgba * self._num_verts),
1176
- translation=('f', (self._x, self._y) * self._num_verts),
1177
- rotation=('f', (self._rotation,) * self._num_verts))
1121
+ colors=('Bn', self._rgba * vert_count),
1122
+ translation=('f', (self._x, self._y, self._z) * vert_count),
1123
+ rotation=('f', (self._rotation,) * vert_count),
1124
+ )
1178
1125
 
1179
1126
  def _get_vertices(self) -> Sequence[float]:
1180
1127
  if not self._visible:
@@ -1219,8 +1166,8 @@ class Ellipse(ShapeBase):
1219
1166
  a: float, b: float,
1220
1167
  segments: int | None = None,
1221
1168
  color: tuple[int, int, int, int] | tuple[int, int, int] = (255, 255, 255, 255),
1222
- blend_src: int = GL_SRC_ALPHA,
1223
- blend_dest: int = GL_ONE_MINUS_SRC_ALPHA,
1169
+ blend_src: BlendFactor = BlendFactor.SRC_ALPHA,
1170
+ blend_dest: BlendFactor = BlendFactor.ONE_MINUS_SRC_ALPHA,
1224
1171
  batch: Batch | None = None,
1225
1172
  group: Group | None = None,
1226
1173
  program: ShaderProgram | None = None,
@@ -1251,7 +1198,7 @@ class Ellipse(ShapeBase):
1251
1198
  blend_src:
1252
1199
  OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
1253
1200
  blend_dest:
1254
- OpenGL blend destination mode; for example, ``GL_ONE_MINUS_SRC_ALPHA``.
1201
+ OpenGL blend destination mode; for example, ``ONE_MINUS_SRC_ALPHA``.
1255
1202
  batch:
1256
1203
  Optional batch to add the shape to.
1257
1204
  group:
@@ -1292,8 +1239,9 @@ class Ellipse(ShapeBase):
1292
1239
  self._segments * 3, self._draw_mode, self._batch, self._group,
1293
1240
  position=('f', self._get_vertices()),
1294
1241
  colors=('Bn', self._rgba * self._num_verts),
1295
- translation=('f', (self._x, self._y) * self._num_verts),
1296
- rotation=('f', (self._rotation,) * self._num_verts))
1242
+ translation=('f', (self._x, self._y, self._z) * self._num_verts),
1243
+ rotation=('f', (self._rotation,) * self._num_verts),
1244
+ )
1297
1245
 
1298
1246
  def _get_vertices(self) -> Sequence[float]:
1299
1247
  if not self._visible:
@@ -1349,8 +1297,8 @@ class Sector(ShapeBase):
1349
1297
  angle: float = 360.0,
1350
1298
  start_angle: float = 0.0,
1351
1299
  color: tuple[int, int, int, int] | tuple[int, int, int] = (255, 255, 255, 255),
1352
- blend_src: int = GL_SRC_ALPHA,
1353
- blend_dest: int = GL_ONE_MINUS_SRC_ALPHA,
1300
+ blend_src: BlendFactor = BlendFactor.SRC_ALPHA,
1301
+ blend_dest: BlendFactor = BlendFactor.ONE_MINUS_SRC_ALPHA,
1354
1302
  batch: Batch | None = None,
1355
1303
  group: Group | None = None,
1356
1304
  program: ShaderProgram | None = None,
@@ -1385,7 +1333,7 @@ class Sector(ShapeBase):
1385
1333
  blend_src:
1386
1334
  OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
1387
1335
  blend_dest:
1388
- OpenGL blend destination mode; for example, ``GL_ONE_MINUS_SRC_ALPHA``.
1336
+ OpenGL blend destination mode; for example, ``ONE_MINUS_SRC_ALPHA``.
1389
1337
  batch:
1390
1338
  Optional batch to add the shape to.
1391
1339
  group:
@@ -1414,30 +1362,21 @@ class Sector(ShapeBase):
1414
1362
  def __contains__(self, point: tuple[float, float]) -> bool:
1415
1363
  assert len(point) == 2
1416
1364
  point = _rotate_point((self._x, self._y), point, math.radians(self._rotation))
1417
- if math.dist((self._x - self._anchor_x, self._y - self._anchor_y), point) > self._radius:
1418
- return False
1419
- angle = math.degrees(math.atan2(point[1] - self._y + self._anchor_y, point[0] - self._x + self._anchor_x))
1420
- angle = angle % 360
1421
- start_angle = self._start_angle % 360
1422
- end_angle = (start_angle + self._angle) % 360
1423
- if self._angle >= 0:
1424
- if start_angle <= end_angle:
1425
- return start_angle <= angle <= end_angle
1426
- else:
1427
- return angle >= start_angle or angle <= end_angle
1428
- else:
1429
- if end_angle <= start_angle:
1430
- return end_angle <= angle <= start_angle
1431
- else:
1432
- return angle >= end_angle or angle <= start_angle
1365
+ angle = math.atan2(point[1] - self._y + self._anchor_y, point[0] - self._x + self._anchor_x)
1366
+ if angle < 0:
1367
+ angle += 2 * math.pi
1368
+ if self._start_angle < angle < self._start_angle + self._angle:
1369
+ return math.dist((self._x - self._anchor_x, self._y - self._anchor_y), point) < self._radius
1370
+ return False
1433
1371
 
1434
1372
  def _create_vertex_list(self) -> None:
1435
1373
  self._vertex_list = self._program.vertex_list(
1436
1374
  self._num_verts, self._draw_mode, self._batch, self._group,
1437
1375
  position=('f', self._get_vertices()),
1438
1376
  colors=('Bn', self._rgba * self._num_verts),
1439
- translation=('f', (self._x, self._y) * self._num_verts),
1440
- rotation=('f', (self._rotation,) * self._num_verts))
1377
+ translation=('f', (self._x, self._y, self._z) * self._num_verts),
1378
+ rotation=('f', (self._rotation,) * self._num_verts),
1379
+ )
1441
1380
 
1442
1381
  def _get_vertices(self) -> Sequence[float]:
1443
1382
  if not self._visible:
@@ -1447,7 +1386,7 @@ class Sector(ShapeBase):
1447
1386
  y = -self._anchor_y
1448
1387
  r = self._radius
1449
1388
  segment_radians = math.radians(self._angle) / self._segments
1450
- start_radians = math.radians(self._start_angle)
1389
+ start_radians = math.radians(self._start_angle - self._rotation)
1451
1390
 
1452
1391
  # Calculate the outer points of the sector.
1453
1392
  points = [(x + (r * math.cos((i * segment_radians) + start_radians)),
@@ -1506,8 +1445,8 @@ class Line(ShapeBase):
1506
1445
  x: float, y: float, x2: float, y2: float,
1507
1446
  thickness: float = 1.0,
1508
1447
  color: tuple[int, int, int, int] | tuple[int, int, int] = (255, 255, 255, 255),
1509
- blend_src: int = GL_SRC_ALPHA,
1510
- blend_dest: int = GL_ONE_MINUS_SRC_ALPHA,
1448
+ blend_src: BlendFactor = BlendFactor.SRC_ALPHA,
1449
+ blend_dest: BlendFactor = BlendFactor.ONE_MINUS_SRC_ALPHA,
1511
1450
  batch: Batch | None = None,
1512
1451
  group: Group | None = None,
1513
1452
  program: ShaderProgram | None = None,
@@ -1535,7 +1474,7 @@ class Line(ShapeBase):
1535
1474
  blend_src:
1536
1475
  OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
1537
1476
  blend_dest:
1538
- OpenGL blend destination mode; for example, ``GL_ONE_MINUS_SRC_ALPHA``.
1477
+ OpenGL blend destination mode; for example, ``ONE_MINUS_SRC_ALPHA``.
1539
1478
  batch:
1540
1479
  Optional batch to add the shape to.
1541
1480
  group:
@@ -1579,8 +1518,9 @@ class Line(ShapeBase):
1579
1518
  6, self._draw_mode, self._batch, self._group,
1580
1519
  position=('f', self._get_vertices()),
1581
1520
  colors=('Bn', self._rgba * self._num_verts),
1582
- translation=('f', (self._x, self._y) * self._num_verts),
1583
- rotation=('f', (self._rotation,) * self._num_verts))
1521
+ translation=('f', (self._x, self._y, self._z) * self._num_verts),
1522
+ rotation=('f', (self._rotation,) * self._num_verts),
1523
+ )
1584
1524
 
1585
1525
  def _get_vertices(self) -> Sequence[float]:
1586
1526
  if not self._visible:
@@ -1648,8 +1588,8 @@ class Rectangle(ShapeBase):
1648
1588
  x: float, y: float,
1649
1589
  width: float, height: float,
1650
1590
  color: tuple[int, int, int, int] | tuple[int, int, int] = (255, 255, 255, 255),
1651
- blend_src: int = GL_SRC_ALPHA,
1652
- blend_dest: int = GL_ONE_MINUS_SRC_ALPHA,
1591
+ blend_src: BlendFactor = BlendFactor.SRC_ALPHA,
1592
+ blend_dest: BlendFactor = BlendFactor.ONE_MINUS_SRC_ALPHA,
1653
1593
  batch: Batch | None = None,
1654
1594
  group: Group | None = None,
1655
1595
  program: ShaderProgram | None = None,
@@ -1675,7 +1615,7 @@ class Rectangle(ShapeBase):
1675
1615
  blend_src:
1676
1616
  OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
1677
1617
  blend_dest:
1678
- OpenGL blend destination mode; for example, ``GL_ONE_MINUS_SRC_ALPHA``.
1618
+ OpenGL blend destination mode; for example, ``ONE_MINUS_SRC_ALPHA``.
1679
1619
  batch:
1680
1620
  Optional batch to add the shape to.
1681
1621
  group:
@@ -1706,19 +1646,19 @@ class Rectangle(ShapeBase):
1706
1646
  6, self._draw_mode, self._batch, self._group,
1707
1647
  position=('f', self._get_vertices()),
1708
1648
  colors=('Bn', self._rgba * self._num_verts),
1709
- translation=('f', (self._x, self._y) * self._num_verts),
1710
- rotation=('f', (self._rotation,) * self._num_verts))
1649
+ translation=('f', (self._x, self._y, self._z) * self._num_verts),
1650
+ rotation = ('f', (self._rotation,) * self._num_verts),
1651
+ )
1711
1652
 
1712
1653
  def _get_vertices(self) -> Sequence[float]:
1713
1654
  if not self._visible:
1714
1655
  return (0, 0) * self._num_verts
1715
- else:
1716
- x1 = -self._anchor_x
1717
- y1 = -self._anchor_y
1718
- x2 = x1 + self._width
1719
- y2 = y1 + self._height
1656
+ x1 = -self._anchor_x
1657
+ y1 = -self._anchor_y
1658
+ x2 = x1 + self._width
1659
+ y2 = y1 + self._height
1720
1660
 
1721
- return x1, y1, x2, y1, x2, y2, x1, y1, x2, y2, x1, y2
1661
+ return x1, y1, x2, y1, x2, y2, x1, y1, x2, y2, x1, y2
1722
1662
 
1723
1663
  def _update_vertices(self) -> None:
1724
1664
  self._vertex_list.position[:] = self._get_vertices()
@@ -1760,8 +1700,8 @@ class BorderedRectangle(ShapeBase):
1760
1700
  border: float = 1.0,
1761
1701
  color: tuple[int, int, int, int] | tuple[int, int, int] = (255, 255, 255),
1762
1702
  border_color: tuple[int, int, int, int] | tuple[int, int, int] = (100, 100, 100),
1763
- blend_src: int = GL_SRC_ALPHA,
1764
- blend_dest: int = GL_ONE_MINUS_SRC_ALPHA,
1703
+ blend_src: BlendFactor = BlendFactor.SRC_ALPHA,
1704
+ blend_dest: BlendFactor = BlendFactor.ONE_MINUS_SRC_ALPHA,
1765
1705
  batch: Batch | None = None,
1766
1706
  group: Group | None = None,
1767
1707
  program: ShaderProgram | None = None,
@@ -1798,7 +1738,7 @@ class BorderedRectangle(ShapeBase):
1798
1738
  blend_src:
1799
1739
  OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
1800
1740
  blend_dest:
1801
- OpenGL blend destination mode; for example, ``GL_ONE_MINUS_SRC_ALPHA``.
1741
+ OpenGL blend destination mode; for example, ``ONE_MINUS_SRC_ALPHA``.
1802
1742
  batch:
1803
1743
  Optional batch to add the shape to.
1804
1744
  group:
@@ -1825,7 +1765,7 @@ class BorderedRectangle(ShapeBase):
1825
1765
  "they must both have the same opacity")
1826
1766
 
1827
1767
  # Choose a value to use if there is no conflict
1828
- elif fill_a:
1768
+ if fill_a:
1829
1769
  alpha = fill_a[0]
1830
1770
  elif border_a:
1831
1771
  alpha = border_a[0]
@@ -1850,8 +1790,9 @@ class BorderedRectangle(ShapeBase):
1850
1790
  8, self._draw_mode, indices, self._batch, self._group,
1851
1791
  position=('f', self._get_vertices()),
1852
1792
  colors=('Bn', self._rgba * 4 + self._border_rgba * 4),
1853
- translation=('f', (self._x, self._y) * self._num_verts),
1854
- rotation=('f', (self._rotation,) * self._num_verts))
1793
+ translation=('f', (self._x, self._y, self._z) * self._num_verts),
1794
+ rotation=('f', (self._rotation,) * self._num_verts),
1795
+ )
1855
1796
 
1856
1797
  def _update_color(self) -> None:
1857
1798
  self._vertex_list.colors[:] = self._rgba * 4 + self._border_rgba * 4
@@ -1998,8 +1939,8 @@ class Box(ShapeBase):
1998
1939
  width: float, height: float,
1999
1940
  thickness: float = 1.0,
2000
1941
  color: tuple[int, int, int, int] | tuple[int, int, int] = (255, 255, 255, 255),
2001
- blend_src: int = GL_SRC_ALPHA,
2002
- blend_dest: int = GL_ONE_MINUS_SRC_ALPHA,
1942
+ blend_src: BlendFactor = BlendFactor.SRC_ALPHA,
1943
+ blend_dest: BlendFactor = BlendFactor.ONE_MINUS_SRC_ALPHA,
2003
1944
  batch: Batch | None = None,
2004
1945
  group: Group | None = None,
2005
1946
  program: ShaderProgram | None = None,
@@ -2029,7 +1970,7 @@ class Box(ShapeBase):
2029
1970
  blend_src:
2030
1971
  OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
2031
1972
  blend_dest:
2032
- OpenGL blend destination mode; for example, ``GL_ONE_MINUS_SRC_ALPHA``.
1973
+ OpenGL blend destination mode; for example, ``ONE_MINUS_SRC_ALPHA``.
2033
1974
  batch:
2034
1975
  Optional batch to add the shape to.
2035
1976
  group:
@@ -2065,8 +2006,9 @@ class Box(ShapeBase):
2065
2006
  self._num_verts, self._draw_mode, indices, self._batch, self._group,
2066
2007
  position=('f', self._get_vertices()),
2067
2008
  colors=('Bn', self._rgba * self._num_verts),
2068
- translation=('f', (self._x, self._y) * self._num_verts),
2069
- rotation=('f', (self._rotation,) * self._num_verts))
2009
+ translation=('f', (self._x, self._y, self._z) * self._num_verts),
2010
+ rotation = ('f', (self._rotation,) * self._num_verts),
2011
+ )
2070
2012
 
2071
2013
  def _update_color(self):
2072
2014
  self._vertex_list.colors[:] = self._rgba * self._num_verts
@@ -2146,8 +2088,8 @@ class RoundedRectangle(pyglet.shapes.ShapeBase):
2146
2088
  radius: _RadiusT | tuple[_RadiusT, _RadiusT, _RadiusT, _RadiusT],
2147
2089
  segments: int | tuple[int, int, int, int] | None = None,
2148
2090
  color: tuple[int, int, int, int] | tuple[int, int, int] = (255, 255, 255, 255),
2149
- blend_src: int = GL_SRC_ALPHA,
2150
- blend_dest: int = GL_ONE_MINUS_SRC_ALPHA,
2091
+ blend_src: BlendFactor = BlendFactor.SRC_ALPHA,
2092
+ blend_dest: BlendFactor = BlendFactor.ONE_MINUS_SRC_ALPHA,
2151
2093
  batch: Batch | None = None,
2152
2094
  group: Group | None = None,
2153
2095
  program: ShaderProgram | None = None,
@@ -2185,7 +2127,7 @@ class RoundedRectangle(pyglet.shapes.ShapeBase):
2185
2127
  blend_src:
2186
2128
  OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
2187
2129
  blend_dest:
2188
- OpenGL blend destination mode; for example, ``GL_ONE_MINUS_SRC_ALPHA``.
2130
+ OpenGL blend destination mode; for example, ``ONE_MINUS_SRC_ALPHA``.
2189
2131
  batch:
2190
2132
  Optional batch to add the shape to.
2191
2133
  group:
@@ -2245,8 +2187,9 @@ class RoundedRectangle(pyglet.shapes.ShapeBase):
2245
2187
  self._num_verts, self._draw_mode, self._batch, self._group,
2246
2188
  position=('f', self._get_vertices()),
2247
2189
  colors=('Bn', self._rgba * self._num_verts),
2248
- translation=('f', (self._x, self._y) * self._num_verts),
2249
- rotation=('f', (self._rotation,) * self._num_verts))
2190
+ translation=('f', (self._x, self._y, self._z) * self._num_verts),
2191
+ rotation=('f', (self._rotation,) * self._num_verts),
2192
+ )
2250
2193
 
2251
2194
  def _get_vertices(self) -> Sequence[float]:
2252
2195
  if not self._visible:
@@ -2334,8 +2277,8 @@ class Triangle(ShapeBase):
2334
2277
  x2: float, y2: float,
2335
2278
  x3: float, y3: float,
2336
2279
  color: tuple[int, int, int, int] | tuple[int, int, int] = (255, 255, 255, 255),
2337
- blend_src: int = GL_SRC_ALPHA,
2338
- blend_dest: int = GL_ONE_MINUS_SRC_ALPHA,
2280
+ blend_src: BlendFactor = BlendFactor.SRC_ALPHA,
2281
+ blend_dest: BlendFactor = BlendFactor.ONE_MINUS_SRC_ALPHA,
2339
2282
  batch: Batch | None = None,
2340
2283
  group: Group | None = None,
2341
2284
  program: ShaderProgram | None = None,
@@ -2364,7 +2307,7 @@ class Triangle(ShapeBase):
2364
2307
  blend_src:
2365
2308
  OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
2366
2309
  blend_dest:
2367
- OpenGL blend destination mode; for example, ``GL_ONE_MINUS_SRC_ALPHA``.
2310
+ OpenGL blend destination mode; for example, ``ONE_MINUS_SRC_ALPHA``.
2368
2311
  batch:
2369
2312
  Optional batch to add the shape to.
2370
2313
  group:
@@ -2397,20 +2340,20 @@ class Triangle(ShapeBase):
2397
2340
  3, self._draw_mode, self._batch, self._group,
2398
2341
  position=('f', self._get_vertices()),
2399
2342
  colors=('Bn', self._rgba * self._num_verts),
2400
- translation=('f', (self._x, self._y) * self._num_verts),
2401
- rotation=('f', (self._rotation,) * self._num_verts))
2343
+ translation=('f', (self._x, self._y, self._z) * self._num_verts),
2344
+ rotation=('f', (self._rotation,) * self._num_verts),
2345
+ )
2402
2346
 
2403
2347
  def _get_vertices(self) -> Sequence[float]:
2404
2348
  if not self._visible:
2405
2349
  return (0, 0) * self._num_verts
2406
- else:
2407
- x1 = -self._anchor_x
2408
- y1 = -self._anchor_y
2409
- x2 = self._x2 + x1 - self._x
2410
- y2 = self._y2 + y1 - self._y
2411
- x3 = self._x3 + x1 - self._x
2412
- y3 = self._y3 + y1 - self._y
2413
- return x1, y1, x2, y2, x3, y3
2350
+ x1 = -self._anchor_x
2351
+ y1 = -self._anchor_y
2352
+ x2 = self._x2 + x1 - self._x
2353
+ y2 = self._y2 + y1 - self._y
2354
+ x3 = self._x3 + x1 - self._x
2355
+ y3 = self._y3 + y1 - self._y
2356
+ return x1, y1, x2, y2, x3, y3
2414
2357
 
2415
2358
  def _update_vertices(self) -> None:
2416
2359
  self._vertex_list.position[:] = self._get_vertices()
@@ -2465,8 +2408,8 @@ class Star(ShapeBase):
2465
2408
  num_spikes: int,
2466
2409
  rotation: float = 0.0,
2467
2410
  color: tuple[int, int, int, int] | tuple[int, int, int] = (255, 255, 255, 255),
2468
- blend_src: int = GL_SRC_ALPHA,
2469
- blend_dest: int = GL_ONE_MINUS_SRC_ALPHA,
2411
+ blend_src: BlendFactor = BlendFactor.SRC_ALPHA,
2412
+ blend_dest: BlendFactor = BlendFactor.ONE_MINUS_SRC_ALPHA,
2470
2413
  batch: Batch | None = None,
2471
2414
  group: Group | None = None,
2472
2415
  program: ShaderProgram | None = None,
@@ -2498,7 +2441,7 @@ class Star(ShapeBase):
2498
2441
  blend_src:
2499
2442
  OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
2500
2443
  blend_dest:
2501
- OpenGL blend destination mode; for example, ``GL_ONE_MINUS_SRC_ALPHA``.
2444
+ OpenGL blend destination mode; for example, ``ONE_MINUS_SRC_ALPHA``.
2502
2445
  batch:
2503
2446
  Optional batch to add the shape to.
2504
2447
  group:
@@ -2534,8 +2477,9 @@ class Star(ShapeBase):
2534
2477
  self._num_verts, self._draw_mode, self._batch, self._group,
2535
2478
  position=('f', self._get_vertices()),
2536
2479
  colors=('Bn', self._rgba * self._num_verts),
2537
- translation=('f', (self._x, self._y) * self._num_verts),
2538
- rotation=('f', (self._rotation,) * self._num_verts))
2480
+ rotation=('f', (self._rotation,) * self._num_verts),
2481
+ translation=('f', (self._x, self._y, self._z) * self._num_verts),
2482
+ )
2539
2483
 
2540
2484
  def _get_vertices(self) -> Sequence[float]:
2541
2485
  if not self._visible:
@@ -2604,8 +2548,8 @@ class Polygon(ShapeBase):
2604
2548
  self,
2605
2549
  *coordinates: tuple[float, float] | Sequence[float],
2606
2550
  color: tuple[int, int, int, int] | tuple[int, int, int] = (255, 255, 255, 255),
2607
- blend_src: int = GL_SRC_ALPHA,
2608
- blend_dest: int = GL_ONE_MINUS_SRC_ALPHA,
2551
+ blend_src: BlendFactor = BlendFactor.SRC_ALPHA,
2552
+ blend_dest: BlendFactor = BlendFactor.ONE_MINUS_SRC_ALPHA,
2609
2553
  batch: Batch | None = None,
2610
2554
  group: Group | None = None,
2611
2555
  program: ShaderProgram | None = None,
@@ -2626,7 +2570,7 @@ class Polygon(ShapeBase):
2626
2570
  blend_src:
2627
2571
  OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
2628
2572
  blend_dest:
2629
- OpenGL blend destination mode; for example, ``GL_ONE_MINUS_SRC_ALPHA``.
2573
+ OpenGL blend destination mode; for example, ``ONE_MINUS_SRC_ALPHA``.
2630
2574
  batch:
2631
2575
  Optional batch to add the shape to.
2632
2576
  group:
@@ -2659,8 +2603,9 @@ class Polygon(ShapeBase):
2659
2603
  self._batch, self._group,
2660
2604
  position=('f', vertices),
2661
2605
  colors=('Bn', self._rgba * self._num_verts),
2662
- translation=('f', (self._x, self._y) * self._num_verts),
2663
- rotation=('f', (self._rotation,) * self._num_verts))
2606
+ translation=('f', (self._x, self._y, self._z) * self._num_verts),
2607
+ rotation=('f', (self._rotation,) * self._num_verts),
2608
+ )
2664
2609
 
2665
2610
  def _get_vertices(self) -> Sequence[float]:
2666
2611
  if not self._visible:
@@ -2687,8 +2632,8 @@ class MultiLine(ShapeBase):
2687
2632
  closed: bool = False,
2688
2633
  thickness: float = 1.0,
2689
2634
  color: tuple[int, int, int, int] = (255, 255, 255, 255),
2690
- blend_src: int = GL_SRC_ALPHA,
2691
- blend_dest: int = GL_ONE_MINUS_SRC_ALPHA,
2635
+ blend_src: BlendFactor = BlendFactor.SRC_ALPHA,
2636
+ blend_dest: BlendFactor = BlendFactor.ONE_MINUS_SRC_ALPHA,
2692
2637
  batch: Batch | None = None,
2693
2638
  group: Group | None = None,
2694
2639
  program: ShaderProgram | None = None,
@@ -2714,7 +2659,7 @@ class MultiLine(ShapeBase):
2714
2659
  blend_src:
2715
2660
  OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
2716
2661
  blend_dest:
2717
- OpenGL blend destination mode; for example, ``GL_ONE_MINUS_SRC_ALPHA``.
2662
+ OpenGL blend destination mode; for example, ``ONE_MINUS_SRC_ALPHA``.
2718
2663
  batch:
2719
2664
  Optional batch to add the shape to.
2720
2665
  group:
@@ -2745,8 +2690,9 @@ class MultiLine(ShapeBase):
2745
2690
  self._num_verts, self._draw_mode, self._batch, self._group,
2746
2691
  position=('f', self._get_vertices()),
2747
2692
  colors=('Bn', self._rgba * self._num_verts),
2748
- translation=('f', (self._x, self._y) * self._num_verts),
2749
- rotation=('f', (self._rotation,) * self._num_verts))
2693
+ translation=('f', (self._x, self._y, self._z) * self._num_verts),
2694
+ rotation=('f', (self._rotation,) * self._num_verts),
2695
+ )
2750
2696
 
2751
2697
  def _get_vertices(self) -> Sequence[float]:
2752
2698
  if not self._visible:
@@ -2790,5 +2736,19 @@ class MultiLine(ShapeBase):
2790
2736
  self._update_vertices()
2791
2737
 
2792
2738
 
2793
- __all__ = ('Arc', 'Box', 'BezierCurve', 'Circle', 'Ellipse', 'Line', 'MultiLine', 'Rectangle',
2794
- 'BorderedRectangle', 'Triangle', 'Star', 'Polygon', 'Sector', 'ShapeBase')
2739
+ __all__ = (
2740
+ 'Arc',
2741
+ 'BezierCurve',
2742
+ 'BorderedRectangle',
2743
+ 'Box',
2744
+ 'Circle',
2745
+ 'Ellipse',
2746
+ 'Line',
2747
+ 'MultiLine',
2748
+ 'Polygon',
2749
+ 'Rectangle',
2750
+ 'Sector',
2751
+ 'ShapeBase',
2752
+ 'Star',
2753
+ 'Triangle',
2754
+ )