sync pyglet update (sprite)

This commit is contained in:
shenjack 2023-05-24 21:13:16 +08:00
parent 43bb9bd7e0
commit 5f4b64d961

View File

@ -299,7 +299,7 @@ class Sprite(event.EventDispatcher):
else: else:
self._texture = img.get_texture() self._texture = img.get_texture()
self._batch = batch or graphics.get_default_batch() self._batch = batch
self._group = self.group_class(self._texture, blend_src, blend_dest, self.program, group) self._group = self.group_class(self._texture, blend_src, blend_dest, self.program, group)
self._subpixel = subpixel self._subpixel = subpixel
self._create_vertex_list() self._create_vertex_list()
@ -656,27 +656,31 @@ class Sprite(event.EventDispatcher):
def width(self): def width(self):
"""Scaled width of the sprite. """Scaled width of the sprite.
Read-only. Invariant under rotation. Invariant under rotation.
:type: int :type: int
""" """
if self._subpixel: w = self._texture.width * abs(self._scale_x) * abs(self._scale)
return self._texture.width * abs(self._scale_x) * abs(self._scale) return w if self._subpixel else int(w)
else:
return int(self._texture.width * abs(self._scale_x) * abs(self._scale)) @width.setter
def width(self, width):
self.scale_x = width / (self._texture.width * abs(self._scale))
@property @property
def height(self): def height(self):
"""Scaled height of the sprite. """Scaled height of the sprite.
Read-only. Invariant under rotation. Invariant under rotation.
:type: int :type: int
""" """
if self._subpixel: h = self._texture.height * abs(self._scale_y) * abs(self._scale)
return self._texture.height * abs(self._scale_y) * abs(self._scale) return h if self._subpixel else int(h)
else:
return int(self._texture.height * abs(self._scale_y) * abs(self._scale)) @height.setter
def height(self, height):
self.scale_y = height / (self._texture.height * abs(self._scale))
@property @property
def opacity(self): def opacity(self):