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")
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")
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)
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")
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()
def test_recursive(self): init(max_depth=20) mycircle()
def test_ipython(self): init(face_color="#123456", background_color="#aaaaaa") circle(1) display_ipython()
def main(): init(canvas_size=(600, 600), background_color="#ffffff", face_color="#0a0707", max_depth=420) trunk() write_to_png("/tmp/graphite.png")
def test_flip(self): init() with flip_y(): box(0.5) a = get_npimage(y_origin="bottom") self.assertIsInstance(a, np.ndarray)