pyglet 2.1.12__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.
- pyglet/__init__.py +67 -61
- pyglet/__init__.pyi +15 -8
- pyglet/app/__init__.py +22 -13
- pyglet/app/async_app.py +212 -0
- pyglet/app/base.py +2 -1
- pyglet/app/{xlib.py → linux.py} +3 -3
- pyglet/config/__init__.py +101 -0
- pyglet/config/gl/__init__.py +30 -0
- pyglet/config/gl/egl.py +120 -0
- pyglet/config/gl/macos.py +262 -0
- pyglet/config/gl/windows.py +267 -0
- pyglet/config/gl/x11.py +142 -0
- pyglet/customtypes.py +43 -2
- pyglet/display/__init__.py +8 -6
- pyglet/display/base.py +3 -63
- pyglet/display/cocoa.py +12 -17
- pyglet/display/emscripten.py +39 -0
- pyglet/display/headless.py +23 -30
- pyglet/display/wayland.py +157 -0
- pyglet/display/win32.py +4 -17
- pyglet/display/xlib.py +19 -27
- pyglet/display/xlib_vidmoderestore.py +2 -2
- pyglet/enums.py +183 -0
- pyglet/event.py +0 -1
- pyglet/experimental/geoshader_sprite.py +15 -13
- pyglet/experimental/hidraw.py +6 -15
- pyglet/experimental/multitexture_sprite.py +31 -19
- pyglet/experimental/particles.py +13 -35
- pyglet/font/__init__.py +251 -85
- pyglet/font/base.py +116 -61
- pyglet/font/dwrite/__init__.py +349 -204
- pyglet/font/dwrite/dwrite_lib.py +27 -5
- pyglet/font/fontconfig.py +14 -6
- pyglet/font/freetype.py +138 -87
- pyglet/font/freetype_lib.py +19 -0
- pyglet/font/group.py +179 -0
- pyglet/font/harfbuzz/__init__.py +3 -3
- pyglet/font/pyodide_js.py +310 -0
- pyglet/font/quartz.py +319 -126
- pyglet/font/ttf.py +45 -3
- pyglet/font/user.py +14 -19
- pyglet/font/win32.py +45 -21
- pyglet/graphics/__init__.py +8 -787
- pyglet/graphics/allocation.py +115 -1
- pyglet/graphics/api/__init__.py +77 -0
- pyglet/graphics/api/base.py +299 -0
- pyglet/graphics/api/gl/__init__.py +58 -0
- pyglet/graphics/api/gl/base.py +24 -0
- pyglet/graphics/{vertexbuffer.py → api/gl/buffer.py} +104 -159
- pyglet/graphics/api/gl/cocoa/context.py +76 -0
- pyglet/graphics/api/gl/context.py +391 -0
- pyglet/graphics/api/gl/default_shaders.py +0 -0
- pyglet/graphics/api/gl/draw.py +627 -0
- pyglet/graphics/api/gl/egl/__init__.py +0 -0
- pyglet/graphics/api/gl/egl/context.py +92 -0
- pyglet/graphics/api/gl/enums.py +76 -0
- pyglet/graphics/api/gl/framebuffer.py +315 -0
- pyglet/graphics/api/gl/gl.py +5463 -0
- pyglet/graphics/api/gl/gl_info.py +188 -0
- pyglet/graphics/api/gl/global_opengl.py +226 -0
- pyglet/{gl → graphics/api/gl}/lib.py +34 -18
- pyglet/graphics/api/gl/shader.py +1476 -0
- pyglet/graphics/api/gl/shapes.py +55 -0
- pyglet/graphics/api/gl/sprite.py +102 -0
- pyglet/graphics/api/gl/state.py +219 -0
- pyglet/graphics/api/gl/text.py +190 -0
- pyglet/graphics/api/gl/texture.py +1526 -0
- pyglet/graphics/{vertexarray.py → api/gl/vertexarray.py} +11 -13
- pyglet/graphics/api/gl/vertexdomain.py +751 -0
- pyglet/graphics/api/gl/win32/__init__.py +0 -0
- pyglet/graphics/api/gl/win32/context.py +108 -0
- pyglet/graphics/api/gl/win32/wgl_info.py +24 -0
- pyglet/graphics/api/gl/xlib/__init__.py +0 -0
- pyglet/graphics/api/gl/xlib/context.py +174 -0
- pyglet/{gl → graphics/api/gl/xlib}/glx_info.py +26 -31
- pyglet/graphics/api/gl1/__init__.py +0 -0
- pyglet/{gl → graphics/api/gl1}/gl_compat.py +3 -2
- pyglet/graphics/api/gl2/__init__.py +0 -0
- pyglet/graphics/api/gl2/buffer.py +320 -0
- pyglet/graphics/api/gl2/draw.py +600 -0
- pyglet/graphics/api/gl2/global_opengl.py +122 -0
- pyglet/graphics/api/gl2/shader.py +200 -0
- pyglet/graphics/api/gl2/shapes.py +51 -0
- pyglet/graphics/api/gl2/sprite.py +79 -0
- pyglet/graphics/api/gl2/text.py +175 -0
- pyglet/graphics/api/gl2/vertexdomain.py +364 -0
- pyglet/graphics/api/webgl/__init__.py +233 -0
- pyglet/graphics/api/webgl/buffer.py +302 -0
- pyglet/graphics/api/webgl/context.py +234 -0
- pyglet/graphics/api/webgl/draw.py +590 -0
- pyglet/graphics/api/webgl/enums.py +76 -0
- pyglet/graphics/api/webgl/framebuffer.py +360 -0
- pyglet/graphics/api/webgl/gl.py +1537 -0
- pyglet/graphics/api/webgl/gl_info.py +130 -0
- pyglet/graphics/api/webgl/shader.py +1346 -0
- pyglet/graphics/api/webgl/shapes.py +92 -0
- pyglet/graphics/api/webgl/sprite.py +102 -0
- pyglet/graphics/api/webgl/state.py +227 -0
- pyglet/graphics/api/webgl/text.py +187 -0
- pyglet/graphics/api/webgl/texture.py +1227 -0
- pyglet/graphics/api/webgl/vertexarray.py +54 -0
- pyglet/graphics/api/webgl/vertexdomain.py +616 -0
- pyglet/graphics/api/webgl/webgl_js.pyi +307 -0
- pyglet/{image → graphics}/atlas.py +33 -32
- pyglet/graphics/base.py +10 -0
- pyglet/graphics/buffer.py +245 -0
- pyglet/graphics/draw.py +578 -0
- pyglet/graphics/framebuffer.py +26 -0
- pyglet/graphics/instance.py +178 -69
- pyglet/graphics/shader.py +267 -1553
- pyglet/graphics/state.py +83 -0
- pyglet/graphics/texture.py +703 -0
- pyglet/graphics/vertexdomain.py +695 -538
- pyglet/gui/ninepatch.py +10 -10
- pyglet/gui/widgets.py +120 -10
- pyglet/image/__init__.py +20 -1973
- pyglet/image/animation.py +12 -12
- pyglet/image/base.py +730 -0
- pyglet/image/codecs/__init__.py +9 -0
- pyglet/image/codecs/bmp.py +53 -30
- pyglet/image/codecs/dds.py +53 -31
- pyglet/image/codecs/gdiplus.py +38 -14
- pyglet/image/codecs/gdkpixbuf2.py +0 -2
- pyglet/image/codecs/js_image.py +99 -0
- pyglet/image/codecs/ktx2.py +161 -0
- pyglet/image/codecs/pil.py +1 -1
- pyglet/image/codecs/png.py +1 -1
- pyglet/image/codecs/wic.py +11 -2
- pyglet/info.py +26 -24
- pyglet/input/__init__.py +8 -0
- pyglet/input/base.py +163 -105
- pyglet/input/controller.py +13 -19
- pyglet/input/controller_db.py +39 -24
- pyglet/input/emscripten/__init__.py +18 -0
- pyglet/input/emscripten/gamepad_js.py +397 -0
- pyglet/input/linux/__init__.py +11 -5
- pyglet/input/linux/evdev.py +10 -11
- pyglet/input/linux/x11_xinput.py +2 -2
- pyglet/input/linux/x11_xinput_tablet.py +1 -1
- pyglet/input/macos/__init__.py +7 -2
- pyglet/input/macos/darwin_gc.py +559 -0
- pyglet/input/win32/__init__.py +1 -1
- pyglet/input/win32/directinput.py +34 -29
- pyglet/input/win32/xinput.py +11 -61
- pyglet/lib.py +3 -3
- pyglet/libs/__init__.py +1 -1
- pyglet/{gl → libs/darwin}/agl.py +1 -1
- pyglet/libs/darwin/cocoapy/__init__.py +2 -2
- pyglet/libs/darwin/cocoapy/cocoahelpers.py +181 -0
- pyglet/libs/darwin/cocoapy/cocoalibs.py +31 -0
- pyglet/libs/darwin/cocoapy/cocoatypes.py +27 -0
- pyglet/libs/darwin/cocoapy/runtime.py +81 -45
- pyglet/libs/darwin/coreaudio.py +4 -4
- pyglet/{gl → libs/darwin}/lib_agl.py +9 -8
- pyglet/libs/darwin/quartzkey.py +1 -3
- pyglet/libs/egl/__init__.py +2 -0
- pyglet/libs/egl/egl_lib.py +576 -0
- pyglet/libs/egl/eglext.py +51 -5
- pyglet/libs/linux/__init__.py +0 -0
- pyglet/libs/linux/egl/__init__.py +0 -0
- pyglet/libs/linux/egl/eglext.py +22 -0
- pyglet/libs/linux/glx/__init__.py +0 -0
- pyglet/{gl → libs/linux/glx}/glx.py +13 -14
- pyglet/{gl → libs/linux/glx}/glxext_arb.py +408 -192
- pyglet/{gl → libs/linux/glx}/glxext_mesa.py +1 -1
- pyglet/{gl → libs/linux/glx}/glxext_nv.py +345 -164
- pyglet/{gl → libs/linux/glx}/lib_glx.py +3 -2
- pyglet/libs/linux/wayland/__init__.py +0 -0
- pyglet/libs/linux/wayland/client.py +1068 -0
- pyglet/libs/linux/wayland/lib_wayland.py +207 -0
- pyglet/libs/linux/wayland/wayland_egl.py +38 -0
- pyglet/libs/{wayland → linux/wayland}/xkbcommon.py +26 -0
- pyglet/libs/{x11 → linux/x11}/xf86vmode.py +4 -4
- pyglet/libs/{x11 → linux/x11}/xinerama.py +2 -2
- pyglet/libs/{x11 → linux/x11}/xinput.py +10 -10
- pyglet/libs/linux/x11/xrandr.py +0 -0
- pyglet/libs/{x11 → linux/x11}/xrender.py +1 -1
- pyglet/libs/shared/__init__.py +0 -0
- pyglet/libs/shared/spirv/__init__.py +0 -0
- pyglet/libs/shared/spirv/lib_shaderc.py +85 -0
- pyglet/libs/shared/spirv/lib_spirv_cross.py +126 -0
- pyglet/libs/win32/__init__.py +27 -5
- pyglet/libs/win32/constants.py +59 -48
- pyglet/libs/win32/context_managers.py +20 -3
- pyglet/libs/win32/dinput.py +105 -88
- pyglet/{gl → libs/win32}/lib_wgl.py +52 -26
- pyglet/libs/win32/types.py +58 -23
- pyglet/{gl → libs/win32}/wgl.py +32 -25
- pyglet/{gl → libs/win32}/wglext_arb.py +364 -2
- pyglet/media/__init__.py +9 -10
- pyglet/media/codecs/__init__.py +12 -1
- pyglet/media/codecs/base.py +99 -96
- pyglet/media/codecs/ffmpeg.py +2 -2
- pyglet/media/codecs/ffmpeg_lib/libavformat.py +3 -8
- pyglet/media/codecs/webaudio_pyodide.py +111 -0
- pyglet/media/drivers/__init__.py +9 -4
- pyglet/media/drivers/base.py +4 -4
- pyglet/media/drivers/openal/__init__.py +1 -1
- pyglet/media/drivers/openal/adaptation.py +3 -3
- pyglet/media/drivers/pulse/__init__.py +1 -1
- pyglet/media/drivers/pulse/adaptation.py +3 -3
- pyglet/media/drivers/pyodide_js/__init__.py +8 -0
- pyglet/media/drivers/pyodide_js/adaptation.py +288 -0
- pyglet/media/drivers/xaudio2/adaptation.py +3 -3
- pyglet/media/player.py +276 -193
- pyglet/media/player_worker_thread.py +1 -1
- pyglet/model/__init__.py +39 -29
- pyglet/model/codecs/base.py +4 -4
- pyglet/model/codecs/gltf.py +3 -3
- pyglet/model/codecs/obj.py +71 -43
- pyglet/resource.py +129 -78
- pyglet/shapes.py +147 -177
- pyglet/sprite.py +47 -164
- pyglet/text/__init__.py +44 -54
- pyglet/text/caret.py +12 -7
- pyglet/text/document.py +19 -17
- pyglet/text/formats/html.py +2 -2
- pyglet/text/formats/structured.py +10 -40
- pyglet/text/layout/__init__.py +20 -13
- pyglet/text/layout/base.py +176 -287
- pyglet/text/layout/incremental.py +9 -10
- pyglet/text/layout/scrolling.py +7 -95
- pyglet/window/__init__.py +183 -172
- pyglet/window/cocoa/__init__.py +62 -51
- pyglet/window/cocoa/pyglet_delegate.py +2 -25
- pyglet/window/cocoa/pyglet_view.py +9 -8
- pyglet/window/dialog/__init__.py +184 -0
- pyglet/window/dialog/base.py +99 -0
- pyglet/window/dialog/darwin.py +121 -0
- pyglet/window/dialog/linux.py +72 -0
- pyglet/window/dialog/windows.py +194 -0
- pyglet/window/emscripten/__init__.py +779 -0
- pyglet/window/headless/__init__.py +44 -28
- pyglet/window/key.py +2 -0
- pyglet/window/mouse.py +2 -2
- pyglet/window/wayland/__init__.py +377 -0
- pyglet/window/win32/__init__.py +101 -46
- pyglet/window/xlib/__init__.py +104 -66
- {pyglet-2.1.12.dist-info → pyglet-3.0.dev1.dist-info}/METADATA +2 -3
- pyglet-3.0.dev1.dist-info/RECORD +322 -0
- {pyglet-2.1.12.dist-info → pyglet-3.0.dev1.dist-info}/WHEEL +1 -1
- pyglet/gl/__init__.py +0 -208
- pyglet/gl/base.py +0 -499
- pyglet/gl/cocoa.py +0 -309
- pyglet/gl/gl.py +0 -4625
- pyglet/gl/gl.pyi +0 -2320
- pyglet/gl/gl_compat.pyi +0 -3097
- pyglet/gl/gl_info.py +0 -190
- pyglet/gl/headless.py +0 -166
- pyglet/gl/wgl_info.py +0 -36
- pyglet/gl/wglext_nv.py +0 -1096
- pyglet/gl/win32.py +0 -268
- pyglet/gl/xlib.py +0 -295
- pyglet/image/buffer.py +0 -274
- pyglet/image/codecs/s3tc.py +0 -354
- pyglet/libs/x11/xrandr.py +0 -166
- pyglet-2.1.12.dist-info/RECORD +0 -234
- /pyglet/{libs/wayland → graphics/api/gl/cocoa}/__init__.py +0 -0
- /pyglet/libs/{egl → linux/egl}/egl.py +0 -0
- /pyglet/libs/{egl → linux/egl}/lib.py +0 -0
- /pyglet/libs/{ioctl.py → linux/ioctl.py} +0 -0
- /pyglet/libs/{wayland → linux/wayland}/gbm.py +0 -0
- /pyglet/libs/{x11 → linux/x11}/__init__.py +0 -0
- /pyglet/libs/{x11 → linux/x11}/cursorfont.py +0 -0
- /pyglet/libs/{x11 → linux/x11}/xlib.py +0 -0
- /pyglet/libs/{x11 → linux/x11}/xsync.py +0 -0
- {pyglet-2.1.12.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.
|
|
76
|
-
from pyglet.
|
|
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:
|
|
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
|
|
271
|
-
self.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:
|
|
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:
|
|
326
|
-
blend_dest:
|
|
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, ``
|
|
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[
|
|
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,
|
|
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
|
-
|
|
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.
|
|
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,
|
|
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:
|
|
793
|
-
blend_dest:
|
|
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, ``
|
|
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:
|
|
975
|
-
blend_dest:
|
|
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, ``
|
|
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:
|
|
1118
|
-
blend_dest:
|
|
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, ``
|
|
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
|
-
|
|
1119
|
+
vert_count, self._draw_mode, self._batch, self._group,
|
|
1174
1120
|
position=('f', self._get_vertices()),
|
|
1175
|
-
colors=('Bn', self._rgba *
|
|
1176
|
-
translation=('f', (self._x, self._y) *
|
|
1177
|
-
rotation=('f', (self._rotation,) *
|
|
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:
|
|
1223
|
-
blend_dest:
|
|
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, ``
|
|
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:
|
|
1353
|
-
blend_dest:
|
|
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, ``
|
|
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:
|
|
@@ -1426,8 +1374,9 @@ class Sector(ShapeBase):
|
|
|
1426
1374
|
self._num_verts, self._draw_mode, self._batch, self._group,
|
|
1427
1375
|
position=('f', self._get_vertices()),
|
|
1428
1376
|
colors=('Bn', self._rgba * self._num_verts),
|
|
1429
|
-
translation=('f', (self._x, self._y) * self._num_verts),
|
|
1430
|
-
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
|
+
)
|
|
1431
1380
|
|
|
1432
1381
|
def _get_vertices(self) -> Sequence[float]:
|
|
1433
1382
|
if not self._visible:
|
|
@@ -1496,8 +1445,8 @@ class Line(ShapeBase):
|
|
|
1496
1445
|
x: float, y: float, x2: float, y2: float,
|
|
1497
1446
|
thickness: float = 1.0,
|
|
1498
1447
|
color: tuple[int, int, int, int] | tuple[int, int, int] = (255, 255, 255, 255),
|
|
1499
|
-
blend_src:
|
|
1500
|
-
blend_dest:
|
|
1448
|
+
blend_src: BlendFactor = BlendFactor.SRC_ALPHA,
|
|
1449
|
+
blend_dest: BlendFactor = BlendFactor.ONE_MINUS_SRC_ALPHA,
|
|
1501
1450
|
batch: Batch | None = None,
|
|
1502
1451
|
group: Group | None = None,
|
|
1503
1452
|
program: ShaderProgram | None = None,
|
|
@@ -1525,7 +1474,7 @@ class Line(ShapeBase):
|
|
|
1525
1474
|
blend_src:
|
|
1526
1475
|
OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
|
|
1527
1476
|
blend_dest:
|
|
1528
|
-
OpenGL blend destination mode; for example, ``
|
|
1477
|
+
OpenGL blend destination mode; for example, ``ONE_MINUS_SRC_ALPHA``.
|
|
1529
1478
|
batch:
|
|
1530
1479
|
Optional batch to add the shape to.
|
|
1531
1480
|
group:
|
|
@@ -1569,8 +1518,9 @@ class Line(ShapeBase):
|
|
|
1569
1518
|
6, self._draw_mode, self._batch, self._group,
|
|
1570
1519
|
position=('f', self._get_vertices()),
|
|
1571
1520
|
colors=('Bn', self._rgba * self._num_verts),
|
|
1572
|
-
translation=('f', (self._x, self._y) * self._num_verts),
|
|
1573
|
-
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
|
+
)
|
|
1574
1524
|
|
|
1575
1525
|
def _get_vertices(self) -> Sequence[float]:
|
|
1576
1526
|
if not self._visible:
|
|
@@ -1638,8 +1588,8 @@ class Rectangle(ShapeBase):
|
|
|
1638
1588
|
x: float, y: float,
|
|
1639
1589
|
width: float, height: float,
|
|
1640
1590
|
color: tuple[int, int, int, int] | tuple[int, int, int] = (255, 255, 255, 255),
|
|
1641
|
-
blend_src:
|
|
1642
|
-
blend_dest:
|
|
1591
|
+
blend_src: BlendFactor = BlendFactor.SRC_ALPHA,
|
|
1592
|
+
blend_dest: BlendFactor = BlendFactor.ONE_MINUS_SRC_ALPHA,
|
|
1643
1593
|
batch: Batch | None = None,
|
|
1644
1594
|
group: Group | None = None,
|
|
1645
1595
|
program: ShaderProgram | None = None,
|
|
@@ -1665,7 +1615,7 @@ class Rectangle(ShapeBase):
|
|
|
1665
1615
|
blend_src:
|
|
1666
1616
|
OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
|
|
1667
1617
|
blend_dest:
|
|
1668
|
-
OpenGL blend destination mode; for example, ``
|
|
1618
|
+
OpenGL blend destination mode; for example, ``ONE_MINUS_SRC_ALPHA``.
|
|
1669
1619
|
batch:
|
|
1670
1620
|
Optional batch to add the shape to.
|
|
1671
1621
|
group:
|
|
@@ -1696,19 +1646,19 @@ class Rectangle(ShapeBase):
|
|
|
1696
1646
|
6, self._draw_mode, self._batch, self._group,
|
|
1697
1647
|
position=('f', self._get_vertices()),
|
|
1698
1648
|
colors=('Bn', self._rgba * self._num_verts),
|
|
1699
|
-
translation=('f', (self._x, self._y) * self._num_verts),
|
|
1700
|
-
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
|
+
)
|
|
1701
1652
|
|
|
1702
1653
|
def _get_vertices(self) -> Sequence[float]:
|
|
1703
1654
|
if not self._visible:
|
|
1704
1655
|
return (0, 0) * self._num_verts
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
y2 = y1 + self._height
|
|
1656
|
+
x1 = -self._anchor_x
|
|
1657
|
+
y1 = -self._anchor_y
|
|
1658
|
+
x2 = x1 + self._width
|
|
1659
|
+
y2 = y1 + self._height
|
|
1710
1660
|
|
|
1711
|
-
|
|
1661
|
+
return x1, y1, x2, y1, x2, y2, x1, y1, x2, y2, x1, y2
|
|
1712
1662
|
|
|
1713
1663
|
def _update_vertices(self) -> None:
|
|
1714
1664
|
self._vertex_list.position[:] = self._get_vertices()
|
|
@@ -1750,8 +1700,8 @@ class BorderedRectangle(ShapeBase):
|
|
|
1750
1700
|
border: float = 1.0,
|
|
1751
1701
|
color: tuple[int, int, int, int] | tuple[int, int, int] = (255, 255, 255),
|
|
1752
1702
|
border_color: tuple[int, int, int, int] | tuple[int, int, int] = (100, 100, 100),
|
|
1753
|
-
blend_src:
|
|
1754
|
-
blend_dest:
|
|
1703
|
+
blend_src: BlendFactor = BlendFactor.SRC_ALPHA,
|
|
1704
|
+
blend_dest: BlendFactor = BlendFactor.ONE_MINUS_SRC_ALPHA,
|
|
1755
1705
|
batch: Batch | None = None,
|
|
1756
1706
|
group: Group | None = None,
|
|
1757
1707
|
program: ShaderProgram | None = None,
|
|
@@ -1788,7 +1738,7 @@ class BorderedRectangle(ShapeBase):
|
|
|
1788
1738
|
blend_src:
|
|
1789
1739
|
OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
|
|
1790
1740
|
blend_dest:
|
|
1791
|
-
OpenGL blend destination mode; for example, ``
|
|
1741
|
+
OpenGL blend destination mode; for example, ``ONE_MINUS_SRC_ALPHA``.
|
|
1792
1742
|
batch:
|
|
1793
1743
|
Optional batch to add the shape to.
|
|
1794
1744
|
group:
|
|
@@ -1815,7 +1765,7 @@ class BorderedRectangle(ShapeBase):
|
|
|
1815
1765
|
"they must both have the same opacity")
|
|
1816
1766
|
|
|
1817
1767
|
# Choose a value to use if there is no conflict
|
|
1818
|
-
|
|
1768
|
+
if fill_a:
|
|
1819
1769
|
alpha = fill_a[0]
|
|
1820
1770
|
elif border_a:
|
|
1821
1771
|
alpha = border_a[0]
|
|
@@ -1840,8 +1790,9 @@ class BorderedRectangle(ShapeBase):
|
|
|
1840
1790
|
8, self._draw_mode, indices, self._batch, self._group,
|
|
1841
1791
|
position=('f', self._get_vertices()),
|
|
1842
1792
|
colors=('Bn', self._rgba * 4 + self._border_rgba * 4),
|
|
1843
|
-
translation=('f', (self._x, self._y) * self._num_verts),
|
|
1844
|
-
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
|
+
)
|
|
1845
1796
|
|
|
1846
1797
|
def _update_color(self) -> None:
|
|
1847
1798
|
self._vertex_list.colors[:] = self._rgba * 4 + self._border_rgba * 4
|
|
@@ -1988,8 +1939,8 @@ class Box(ShapeBase):
|
|
|
1988
1939
|
width: float, height: float,
|
|
1989
1940
|
thickness: float = 1.0,
|
|
1990
1941
|
color: tuple[int, int, int, int] | tuple[int, int, int] = (255, 255, 255, 255),
|
|
1991
|
-
blend_src:
|
|
1992
|
-
blend_dest:
|
|
1942
|
+
blend_src: BlendFactor = BlendFactor.SRC_ALPHA,
|
|
1943
|
+
blend_dest: BlendFactor = BlendFactor.ONE_MINUS_SRC_ALPHA,
|
|
1993
1944
|
batch: Batch | None = None,
|
|
1994
1945
|
group: Group | None = None,
|
|
1995
1946
|
program: ShaderProgram | None = None,
|
|
@@ -2019,7 +1970,7 @@ class Box(ShapeBase):
|
|
|
2019
1970
|
blend_src:
|
|
2020
1971
|
OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
|
|
2021
1972
|
blend_dest:
|
|
2022
|
-
OpenGL blend destination mode; for example, ``
|
|
1973
|
+
OpenGL blend destination mode; for example, ``ONE_MINUS_SRC_ALPHA``.
|
|
2023
1974
|
batch:
|
|
2024
1975
|
Optional batch to add the shape to.
|
|
2025
1976
|
group:
|
|
@@ -2055,8 +2006,9 @@ class Box(ShapeBase):
|
|
|
2055
2006
|
self._num_verts, self._draw_mode, indices, self._batch, self._group,
|
|
2056
2007
|
position=('f', self._get_vertices()),
|
|
2057
2008
|
colors=('Bn', self._rgba * self._num_verts),
|
|
2058
|
-
translation=('f', (self._x, self._y) * self._num_verts),
|
|
2059
|
-
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
|
+
)
|
|
2060
2012
|
|
|
2061
2013
|
def _update_color(self):
|
|
2062
2014
|
self._vertex_list.colors[:] = self._rgba * self._num_verts
|
|
@@ -2136,8 +2088,8 @@ class RoundedRectangle(pyglet.shapes.ShapeBase):
|
|
|
2136
2088
|
radius: _RadiusT | tuple[_RadiusT, _RadiusT, _RadiusT, _RadiusT],
|
|
2137
2089
|
segments: int | tuple[int, int, int, int] | None = None,
|
|
2138
2090
|
color: tuple[int, int, int, int] | tuple[int, int, int] = (255, 255, 255, 255),
|
|
2139
|
-
blend_src:
|
|
2140
|
-
blend_dest:
|
|
2091
|
+
blend_src: BlendFactor = BlendFactor.SRC_ALPHA,
|
|
2092
|
+
blend_dest: BlendFactor = BlendFactor.ONE_MINUS_SRC_ALPHA,
|
|
2141
2093
|
batch: Batch | None = None,
|
|
2142
2094
|
group: Group | None = None,
|
|
2143
2095
|
program: ShaderProgram | None = None,
|
|
@@ -2175,7 +2127,7 @@ class RoundedRectangle(pyglet.shapes.ShapeBase):
|
|
|
2175
2127
|
blend_src:
|
|
2176
2128
|
OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
|
|
2177
2129
|
blend_dest:
|
|
2178
|
-
OpenGL blend destination mode; for example, ``
|
|
2130
|
+
OpenGL blend destination mode; for example, ``ONE_MINUS_SRC_ALPHA``.
|
|
2179
2131
|
batch:
|
|
2180
2132
|
Optional batch to add the shape to.
|
|
2181
2133
|
group:
|
|
@@ -2235,8 +2187,9 @@ class RoundedRectangle(pyglet.shapes.ShapeBase):
|
|
|
2235
2187
|
self._num_verts, self._draw_mode, self._batch, self._group,
|
|
2236
2188
|
position=('f', self._get_vertices()),
|
|
2237
2189
|
colors=('Bn', self._rgba * self._num_verts),
|
|
2238
|
-
translation=('f', (self._x, self._y) * self._num_verts),
|
|
2239
|
-
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
|
+
)
|
|
2240
2193
|
|
|
2241
2194
|
def _get_vertices(self) -> Sequence[float]:
|
|
2242
2195
|
if not self._visible:
|
|
@@ -2324,8 +2277,8 @@ class Triangle(ShapeBase):
|
|
|
2324
2277
|
x2: float, y2: float,
|
|
2325
2278
|
x3: float, y3: float,
|
|
2326
2279
|
color: tuple[int, int, int, int] | tuple[int, int, int] = (255, 255, 255, 255),
|
|
2327
|
-
blend_src:
|
|
2328
|
-
blend_dest:
|
|
2280
|
+
blend_src: BlendFactor = BlendFactor.SRC_ALPHA,
|
|
2281
|
+
blend_dest: BlendFactor = BlendFactor.ONE_MINUS_SRC_ALPHA,
|
|
2329
2282
|
batch: Batch | None = None,
|
|
2330
2283
|
group: Group | None = None,
|
|
2331
2284
|
program: ShaderProgram | None = None,
|
|
@@ -2354,7 +2307,7 @@ class Triangle(ShapeBase):
|
|
|
2354
2307
|
blend_src:
|
|
2355
2308
|
OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
|
|
2356
2309
|
blend_dest:
|
|
2357
|
-
OpenGL blend destination mode; for example, ``
|
|
2310
|
+
OpenGL blend destination mode; for example, ``ONE_MINUS_SRC_ALPHA``.
|
|
2358
2311
|
batch:
|
|
2359
2312
|
Optional batch to add the shape to.
|
|
2360
2313
|
group:
|
|
@@ -2387,20 +2340,20 @@ class Triangle(ShapeBase):
|
|
|
2387
2340
|
3, self._draw_mode, self._batch, self._group,
|
|
2388
2341
|
position=('f', self._get_vertices()),
|
|
2389
2342
|
colors=('Bn', self._rgba * self._num_verts),
|
|
2390
|
-
translation=('f', (self._x, self._y) * self._num_verts),
|
|
2391
|
-
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
|
+
)
|
|
2392
2346
|
|
|
2393
2347
|
def _get_vertices(self) -> Sequence[float]:
|
|
2394
2348
|
if not self._visible:
|
|
2395
2349
|
return (0, 0) * self._num_verts
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
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
|
|
2404
2357
|
|
|
2405
2358
|
def _update_vertices(self) -> None:
|
|
2406
2359
|
self._vertex_list.position[:] = self._get_vertices()
|
|
@@ -2455,8 +2408,8 @@ class Star(ShapeBase):
|
|
|
2455
2408
|
num_spikes: int,
|
|
2456
2409
|
rotation: float = 0.0,
|
|
2457
2410
|
color: tuple[int, int, int, int] | tuple[int, int, int] = (255, 255, 255, 255),
|
|
2458
|
-
blend_src:
|
|
2459
|
-
blend_dest:
|
|
2411
|
+
blend_src: BlendFactor = BlendFactor.SRC_ALPHA,
|
|
2412
|
+
blend_dest: BlendFactor = BlendFactor.ONE_MINUS_SRC_ALPHA,
|
|
2460
2413
|
batch: Batch | None = None,
|
|
2461
2414
|
group: Group | None = None,
|
|
2462
2415
|
program: ShaderProgram | None = None,
|
|
@@ -2488,7 +2441,7 @@ class Star(ShapeBase):
|
|
|
2488
2441
|
blend_src:
|
|
2489
2442
|
OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
|
|
2490
2443
|
blend_dest:
|
|
2491
|
-
OpenGL blend destination mode; for example, ``
|
|
2444
|
+
OpenGL blend destination mode; for example, ``ONE_MINUS_SRC_ALPHA``.
|
|
2492
2445
|
batch:
|
|
2493
2446
|
Optional batch to add the shape to.
|
|
2494
2447
|
group:
|
|
@@ -2524,8 +2477,9 @@ class Star(ShapeBase):
|
|
|
2524
2477
|
self._num_verts, self._draw_mode, self._batch, self._group,
|
|
2525
2478
|
position=('f', self._get_vertices()),
|
|
2526
2479
|
colors=('Bn', self._rgba * self._num_verts),
|
|
2527
|
-
|
|
2528
|
-
|
|
2480
|
+
rotation=('f', (self._rotation,) * self._num_verts),
|
|
2481
|
+
translation=('f', (self._x, self._y, self._z) * self._num_verts),
|
|
2482
|
+
)
|
|
2529
2483
|
|
|
2530
2484
|
def _get_vertices(self) -> Sequence[float]:
|
|
2531
2485
|
if not self._visible:
|
|
@@ -2594,8 +2548,8 @@ class Polygon(ShapeBase):
|
|
|
2594
2548
|
self,
|
|
2595
2549
|
*coordinates: tuple[float, float] | Sequence[float],
|
|
2596
2550
|
color: tuple[int, int, int, int] | tuple[int, int, int] = (255, 255, 255, 255),
|
|
2597
|
-
blend_src:
|
|
2598
|
-
blend_dest:
|
|
2551
|
+
blend_src: BlendFactor = BlendFactor.SRC_ALPHA,
|
|
2552
|
+
blend_dest: BlendFactor = BlendFactor.ONE_MINUS_SRC_ALPHA,
|
|
2599
2553
|
batch: Batch | None = None,
|
|
2600
2554
|
group: Group | None = None,
|
|
2601
2555
|
program: ShaderProgram | None = None,
|
|
@@ -2616,7 +2570,7 @@ class Polygon(ShapeBase):
|
|
|
2616
2570
|
blend_src:
|
|
2617
2571
|
OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
|
|
2618
2572
|
blend_dest:
|
|
2619
|
-
OpenGL blend destination mode; for example, ``
|
|
2573
|
+
OpenGL blend destination mode; for example, ``ONE_MINUS_SRC_ALPHA``.
|
|
2620
2574
|
batch:
|
|
2621
2575
|
Optional batch to add the shape to.
|
|
2622
2576
|
group:
|
|
@@ -2649,8 +2603,9 @@ class Polygon(ShapeBase):
|
|
|
2649
2603
|
self._batch, self._group,
|
|
2650
2604
|
position=('f', vertices),
|
|
2651
2605
|
colors=('Bn', self._rgba * self._num_verts),
|
|
2652
|
-
translation=('f', (self._x, self._y) * self._num_verts),
|
|
2653
|
-
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
|
+
)
|
|
2654
2609
|
|
|
2655
2610
|
def _get_vertices(self) -> Sequence[float]:
|
|
2656
2611
|
if not self._visible:
|
|
@@ -2677,8 +2632,8 @@ class MultiLine(ShapeBase):
|
|
|
2677
2632
|
closed: bool = False,
|
|
2678
2633
|
thickness: float = 1.0,
|
|
2679
2634
|
color: tuple[int, int, int, int] = (255, 255, 255, 255),
|
|
2680
|
-
blend_src:
|
|
2681
|
-
blend_dest:
|
|
2635
|
+
blend_src: BlendFactor = BlendFactor.SRC_ALPHA,
|
|
2636
|
+
blend_dest: BlendFactor = BlendFactor.ONE_MINUS_SRC_ALPHA,
|
|
2682
2637
|
batch: Batch | None = None,
|
|
2683
2638
|
group: Group | None = None,
|
|
2684
2639
|
program: ShaderProgram | None = None,
|
|
@@ -2704,7 +2659,7 @@ class MultiLine(ShapeBase):
|
|
|
2704
2659
|
blend_src:
|
|
2705
2660
|
OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
|
|
2706
2661
|
blend_dest:
|
|
2707
|
-
OpenGL blend destination mode; for example, ``
|
|
2662
|
+
OpenGL blend destination mode; for example, ``ONE_MINUS_SRC_ALPHA``.
|
|
2708
2663
|
batch:
|
|
2709
2664
|
Optional batch to add the shape to.
|
|
2710
2665
|
group:
|
|
@@ -2735,8 +2690,9 @@ class MultiLine(ShapeBase):
|
|
|
2735
2690
|
self._num_verts, self._draw_mode, self._batch, self._group,
|
|
2736
2691
|
position=('f', self._get_vertices()),
|
|
2737
2692
|
colors=('Bn', self._rgba * self._num_verts),
|
|
2738
|
-
translation=('f', (self._x, self._y) * self._num_verts),
|
|
2739
|
-
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
|
+
)
|
|
2740
2696
|
|
|
2741
2697
|
def _get_vertices(self) -> Sequence[float]:
|
|
2742
2698
|
if not self._visible:
|
|
@@ -2780,5 +2736,19 @@ class MultiLine(ShapeBase):
|
|
|
2780
2736
|
self._update_vertices()
|
|
2781
2737
|
|
|
2782
2738
|
|
|
2783
|
-
__all__ = (
|
|
2784
|
-
|
|
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
|
+
)
|