(f, name, samples=2**26, **kwargs)
| 2 | import os |
| 3 | |
| 4 | def generate(f, name, samples=2**26, **kwargs): |
| 5 | os.makedirs('models', exist_ok=True) |
| 6 | os.makedirs('images', exist_ok=True) |
| 7 | stl_path = 'models/%s.stl' % name |
| 8 | png_path = 'images/%s.png' % name |
| 9 | if os.path.exists(png_path): |
| 10 | return |
| 11 | render_cmd = './render %s %s' % (stl_path, png_path) |
| 12 | f.save(stl_path, samples=samples, **kwargs) |
| 13 | os.system(render_cmd) |
| 14 | |
| 15 | # example |
| 16 | f = sphere(1) & box(1.5) |