コード例 #1
0
 def test_export_postscript_circles_and_rectangles(self):
     self._test_export_postscript(
         HorizontalShapes(Circle(10), Rectangle(20, 20), Circle(20),
                          Rectangle(40, 40), Circle(30), Rectangle(120, 60),
                          Circle(20), Rectangle(80, 40), Circle(10),
                          Rectangle(40, 20), Rectangle(20, 40)),
         Point(300, 200))
コード例 #2
0
ファイル: test_all_shapes.py プロジェクト: llundell/pyscript
class AllShapesTestCase(ShapeTestCase):

    _base_circle = Circle(80)
    _rectangle = Rectangle(100, 60)
    _spacer = Spacer(40, 40)
    _square = Square(80)
    _vertical_shapes = VerticalShapes(
        _base_circle,
        LayeredShapes(ScaledShape(_base_circle, 0.75, 0.75), Polygon(5, 20)),
        LayeredShapes(ScaledShape(_base_circle, 0.5, 0.5),
                      RotatedShape(Triangle(20), 180)))
    _shape = HorizontalShapes(_rectangle, _spacer, _square, _vertical_shapes,
                              _square, _spacer, _rectangle)

    def test_get_width(self):
        self.assertEqual(self._shape._get_width(), 600)

    def test_get_height(self):
        self.assertEqual(self._shape._get_height(), 360)

    def test_export_postscript_all_shapes(self):
        self._test_export_postscript(self._shape, Point(305, 300))
コード例 #3
0
    Point, Rectangle, Spacer, Square, Circle, HorizontalShapes, VerticalShapes,
    LayeredShapes, ScaledShape, RotatedShape, Triangle, Polygon
)

if __name__ == "__main__":
    base_circle = Circle(80)
    rectangle = Rectangle(100, 60)
    spacer = Spacer(40, 40)
    square = Square(80)
    vertical_shapes = VerticalShapes(
        base_circle,
        LayeredShapes(
            ScaledShape(base_circle, 0.75, 0.75), Polygon(5, 20)
        ),
        LayeredShapes(
            ScaledShape(base_circle, 0.5, 0.5), RotatedShape(Triangle(20), 180)
        )
    )
    shape = HorizontalShapes(
        rectangle,
        spacer,
        square,
        vertical_shapes,
        square,
        spacer,
        rectangle
    )
    shape.export_postscript(
        center=Point(305, 300), filename="weird-snowperson.ps"
    )
コード例 #4
0
 def test_get_width_no_shapes(self):
     horizontal_shapes = HorizontalShapes()
     self.assertEqual(horizontal_shapes._get_width(), 0)
コード例 #5
0
 def test_export_postscript_circles_on_page(self):
     self._test_export_postscript(
         HorizontalShapes(Circle(10), Circle(20), Circle(30), Circle(20),
                          Circle(10)), Point(90, 30))
コード例 #6
0
 def test_get_height_multiple_shapes(self):
     horizontal_shapes = HorizontalShapes(Circle(1), Rectangle(5, 10),
                                          Circle(21), Rectangle(0, 1),
                                          Rectangle(3, 9))
     self.assertEqual(horizontal_shapes._get_height(), 42)
コード例 #7
0
 def test_get_height_single_shape(self):
     horizontal_shapes = HorizontalShapes(Circle(3))
     self.assertEqual(horizontal_shapes._get_height(), 6)
コード例 #8
0
 def test_get_height_no_shapes(self):
     horizontal_shapes = HorizontalShapes()
     self.assertEqual(horizontal_shapes._get_height(), 0)
コード例 #9
0
 def test_get_width_multiple_shapes(self):
     horizontal_shapes = HorizontalShapes(Circle(1), Rectangle(5, 10),
                                          Circle(21), Rectangle(0, 1),
                                          Rectangle(3, 9))
     self.assertEqual(horizontal_shapes._get_width(), 2 + 5 + 42 + 0 + 3)