Skip to content

Commit

Permalink
Merge #204
Browse files Browse the repository at this point in the history
204: Immutable vectors r=astronouth7303 a=astronouth7303

Refactor the sides APIs to not mutate Vectors anymore.

Closes #188 

(Note: This is WIP because it depends on Vector 1.0 APIs. It is otherwise ready for review.)

Co-authored-by: Jamie Bliss <jamie@ivyleav.es>
  • Loading branch information
bors[bot] and AstraLuma committed May 5, 2019
2 parents 7498600 + 8c28091 commit 6b4293b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ppb/sprites.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,11 @@ def center(self):
def center(self, value):
self.parent.position = self._mk_update_vector_center(value)

def _mk_update_vector_side(self, attribute, value):
def _mk_update_vector_side(self, attribute, value: Vector):
"""
Calculate the updated vector for the given corner
Calculate the updated vector, based on the given corner.
That is, handles the calculation for forms like sprite.top.left = vector
"""
value = Vector(value)
assert attribute != 'center'
Expand All @@ -152,7 +154,9 @@ def _mk_update_vector_side(self, attribute, value):

def _mk_update_vector_center(self, value):
"""
Calculate the update vector for the midpoint of this side
Calculate the update vector, based on the given side.
That is, handles the calculation for forms like sprite.right = number
"""
value = Vector(value)
# Pretty similar to ._mk_update_vector_side()
Expand Down

0 comments on commit 6b4293b

Please sign in to comment.