コード例 #1
0
 def test_main(self):
     init(face_color="#123456", background_color="#aaaaaa")
     circle(1)
     a = get_npimage()
     print(a.shape)
     report()
     write_to_png("/tmp/test.png")
コード例 #2
0
 def test_primitives(self):
     init(face_color="#123456", background_color="#aaaaaa")
     line(1, 1)
     triangle(0.5)
     a = get_npimage()
     print(a.shape)
     report()
     write_to_png("/tmp/primitives.png")
コード例 #3
0
 def test_rnd(self):
     init(face_color="#123456", background_color="#aaaaaa")
     circle(1)
     res = rnd(1)
     self.assertLess(res, 1.01)
     res = prnd(1)
     self.assertLess(res, 1.01)
     random.seed(5)
     res = coinflip(2)
     self.assertIn(res, [True, False])
     res = coinflip(1)
     self.assertEqual(res, False)
コード例 #4
0
    def test_color(self):
        init(face_color="#123456", background_color="#aaaaaa")
        circle(0.5)
        with transform(x=1, alpha=1, hue=10):
            circle(0.5)
        with transform(x=1, y=1, scale=0.6, alpha=-0.3, hue=0):
            circle(0.5)
        with transform(x=-1, y=1, scale=0.6, alpha=0.7, hue=10, saturation=-1, lightness=1):
            circle(0.5)
        with transform(x=-1, y=-1, scale=0.6, alpha=0.7, hue=-10, saturation=-1, lightness=-1):
            circle(0.5)

        write_to_png("/tmp/color.png")
コード例 #5
0
    def test_scale_limit(self):
        @check_limits
        def element():
            circle(1)
            with transform(x=1, scale=0.2):
                element()

        init()
        element()
        write_to_png("/tmp/scale.png")

        @check_limits
        def element_non_recursive():
            pass
        init()
        for i in range(MAX_ELEMENTS + 1):
            element_non_recursive()
コード例 #6
0
 def test_recursive(self):
     init(max_depth=20)
     mycircle()
コード例 #7
0
 def test_ipython(self):
     init(face_color="#123456", background_color="#aaaaaa")
     circle(1)
     display_ipython()
コード例 #8
0
def main():
    init(canvas_size=(600, 600), background_color="#ffffff", face_color="#0a0707", max_depth=420)
    trunk()
    write_to_png("/tmp/graphite.png")
コード例 #9
0
 def test_flip(self):
     init()
     with flip_y():
         box(0.5)
     a = get_npimage(y_origin="bottom")
     self.assertIsInstance(a, np.ndarray)