Beispiel #1
0
 def test_rotate_0_degrees(self):
     width = 5
     height = 3
     rect = Rectangle(width, height)
     rect.rotate(0)
     expected_points = [Point2D(0, 0), Point2D(width, 0), Point2D(width, height), Point2D(0, height)]
     actual_points = rect.points
     self._assert_points_are_equal(expected_points, actual_points)
Beispiel #2
0
 def test_points_for_rotated_rectangle_at_origin(self):
     width = 5
     height = 3
     rect = Rectangle(width, height)
     rect.rotate(90)
     expected_points = [Point2D(0, 0), Point2D(0, width), Point2D(-height, width), Point2D(-height, 0)]
     actual_points = rect.points
     self._assert_points_are_equal(expected_points, actual_points)
Beispiel #3
0
 def test_rotate_clockwise(self):
     width = 5
     height = 3
     rect = Rectangle(width, height)
     rect.rotate(-90)
     expected_points = [Point2D(0, 0), Point2D(0, -width), Point2D(height, -width), Point2D(height, 0)]
     actual_points = rect.points
     self._assert_points_are_equal(expected_points, actual_points)
Beispiel #4
0
 def test_rotate_2_times(self):
     width = 5
     height = 3
     rect = Rectangle(width, height)
     rect.rotate(45)
     rect.rotate(45)
     expected_points = [Point2D(0, 0), Point2D(0, width), Point2D(-height, width), Point2D(-height, 0)]
     actual_points = rect.points
     self._assert_points_are_equal(expected_points, actual_points)
Beispiel #5
0
 def test_points_for_positioned_rectangle(self):
     width = 5
     height = 3
     position = Point2D(1, 2)
     rect = Rectangle(width, height)
     rect.position = position
     expected_points = [position,
                        Point2D(position.x + width, position.y),
                        Point2D(position.x + width, position.y + height),
                        Point2D(position.x, position.y + height)]
     actual_points = rect.points
     self._assert_points_are_equal(expected_points, actual_points)