Skip to content

Commit

Permalink
Make Rect's members normal private variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
kalekundert committed Dec 30, 2016
1 parent 8d28c89 commit 5cebf42
Showing 1 changed file with 34 additions and 34 deletions.
68 changes: 34 additions & 34 deletions vecrec/shapes.py
Expand Up @@ -519,10 +519,10 @@ def set_tuple(self, coordinates):
class Rectangle (Shape):

def __init__(self, left, bottom, width, height):
self.__left = left
self.__bottom = bottom
self.__width = width
self.__height = height
self._left = left
self._bottom = bottom
self._width = width
self._height = height

def __repr__(self):
return "Rectangle(%f, %f, %f, %f)" % self.tuple
Expand Down Expand Up @@ -670,10 +670,10 @@ def from_intersection(*inputs):

def grow(self, padding):
""" Grow this rectangle by the given padding on all sides. """
self.__bottom -= padding
self.__left -= padding
self.__width += 2 * padding
self.__height += 2 * padding
self._bottom -= padding
self._left -= padding
self._width += 2 * padding
self._height += 2 * padding
return self

def shrink(self, padding):
Expand All @@ -684,8 +684,8 @@ def shrink(self, padding):
@accept_anything_as_vector
def displace(self, vector):
""" Displace this rectangle by the given vector. """
self.__bottom += vector.y
self.__left += vector.x
self._bottom += vector.y
self._left += vector.x
return self

def set(self, shape):
Expand Down Expand Up @@ -759,41 +759,41 @@ def align_bottom(self, target):


def get_left(self):
return self.__left
return self._left

def get_center_x(self):
return self.__left + self.__width / 2
return self._left + self._width / 2

def get_right(self):
return self.__left + self.__width
return self._left + self._width

def get_top(self):
return self.__bottom + self.__height
return self._bottom + self._height

def get_center_y(self):
return self.__bottom + self.__height / 2
return self._bottom + self._height / 2

def get_bottom(self):
return self.__bottom
return self._bottom

def get_width(self):
return self.__width
return self._width

def get_height(self):
return self.__height
return self._height

def get_half_width(self):
return self.__width / 2
return self._width / 2

def get_half_height(self):
return self.__height / 2
return self._height / 2

def get_size(self):
return self.__width, self.__height
return self._width, self._height

def get_size_as_int(self):
from math import ceil
return int(ceil(self.__width)), int(ceil(self.__height))
return int(ceil(self._width)), int(ceil(self._height))


def get_top_left(self):
Expand Down Expand Up @@ -828,10 +828,10 @@ def get_vertices(self):


def get_dimensions(self):
return (self.__left, self.__bottom), (self.__width, self.__height)
return (self._left, self._bottom), (self._width, self._height)

def get_tuple(self):
return self.__left, self.__bottom, self.__width, self.__height
return self._left, self._bottom, self._width, self._height

def get_union(self, *rectangles):
return Rectangle.from_union(self, *rectangles)
Expand All @@ -851,32 +851,32 @@ def get_shrunk(self, padding):


def set_left(self, x):
self.__left = x
self._left = x

def set_center_x(self, x):
self.__left = x - self.__width / 2
self._left = x - self._width / 2

def set_right(self, x):
self.__left = x - self.__width
self._left = x - self._width

def set_top(self, y):
self.__bottom = y - self.__height
self._bottom = y - self._height

def set_center_y(self, y):
self.__bottom = y - self.__height / 2
self._bottom = y - self._height / 2

def set_bottom(self, y):
self.__bottom = y
self._bottom = y

def set_width(self, width):
self.__width = width
self._width = width

def set_height(self, height):
self.__height = height
self._height = height

def set_size(self, width, height):
self.__width = width
self.__height = height
self._width = width
self._height = height


@accept_anything_as_vector
Expand Down

0 comments on commit 5cebf42

Please sign in to comment.