Skip to content

Commit

Permalink
Pyglet 1.5 maintenance (#676)
Browse files Browse the repository at this point in the history
* Fixed the broken position property of the Polygon class.
* Made the _x, _y attributes of the polygon correspond to the first coordinate of the polygon.
  • Loading branch information
Ross-TheBoss committed Aug 31, 2022
1 parent e032638 commit 2f2c8f1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pyglet/shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1388,6 +1388,7 @@ def __init__(self, *coordinates, color=(255, 255, 255), batch=None, group=None):

# len(self._coordinates) = the number of vertices and sides in the shape.
self._coordinates = list(coordinates)
self._x, self._y = self._coordinates[0]

self._rotation = 0

Expand Down Expand Up @@ -1434,7 +1435,7 @@ def x(self):

@x.setter
def x(self, value):
self._coordinates[0][0] = value
self._x = self._coordinates[0][0] = value
self._update_position()

@property
Expand All @@ -1447,7 +1448,7 @@ def y(self):

@y.setter
def y(self, value):
self._coordinates[0][1] = value
self._y = self._coordinates[0][1] = value
self._update_position()

@property
Expand All @@ -1464,7 +1465,11 @@ def position(self):

@position.setter
def position(self, values):
self._coordinates[0][0], self._coordinates[0][1] = values
dx = self._coordinates[0][0] - values[0]
dy = self._coordinates[0][1] - values[1]

self._coordinates = [[x - dx, y - dy] for x, y in self._coordinates]
self._x, self._y = self._coordinates[0]
self._update_position()

@property
Expand Down

0 comments on commit 2f2c8f1

Please sign in to comment.