Beispiel #1
0
    def test_x_y_property(self):
        x = 20
        y = 40
        point = Point(x, y)

        assert point.x == x
        assert point.y == y
Beispiel #2
0
    def test_assert_correct_rectangle_transformation_from_two_points(self):
        geometric_factory = GeometricFactory()
        x1 = 40
        y1 = 100
        x2 = 200
        y2 = 150
        point1 = Point(x1, y1)
        point2 = Point(x2, y2)

        translated_point1 = Point(x1, self.window_height - y1)
        translated_point2 = Point(x2, self.window_height - y2)

        rectangle = geometric_factory.rectangle(point1, point2)

        assert rectangle.point1.x == translated_point1.x or rectangle.point2.x == translated_point1.x
        assert rectangle.point1.x == translated_point2.x or rectangle.point2.x == translated_point2.x
        assert rectangle.point1.y == translated_point1.y or rectangle.point2.y == translated_point1.y
        assert rectangle.point1.y == translated_point2.y or rectangle.point2.y == translated_point2.y
Beispiel #3
0
 def test_position_values(self):
     point = Point(20, 40)
     assert point.position == (20, 40)
Beispiel #4
0
 def lower_left_corner(self):
     x = self.upper_left_corner.x
     y = self.upper_left_corner.y - self.height
     return Point(x, y)
Beispiel #5
0
 def from_lower_left_point(cls, lower_left_point, height, width):
     x = lower_left_point.x
     y = lower_left_point.y + height
     upper_left_corner = Point(x, y)
     return cls(upper_left_corner, height, width)
Beispiel #6
0
 def from_central_point(cls, central_point, height, width):
     x = central_point.x - round(width / 2)
     y = central_point.y + round(height / 2)
     upper_left_corner = Point(x, y)
     return cls(upper_left_corner, height, width)
Beispiel #7
0
 def __get_upper_left_corner(cls, point: Point,
                             diagonally_opposite_point: Point):
     x = cls.__get_smaller_x_position(point, diagonally_opposite_point)
     y = cls.__get_bigger_y_position(point, diagonally_opposite_point)
     return Point(x, y)