-
Notifications
You must be signed in to change notification settings - Fork 45
/
generate_examples.py
executable file
·101 lines (97 loc) · 3.04 KB
/
generate_examples.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Created on Tue Apr 22 07:14:05 2014
# License is MIT, see COPYING.txt for more details.
# @author: Danilo de Jesus da Silva Bellini
from fractal import Point, exec_command
try:
from collections import OrderedDict
except ImportError: # Python 2.6
from ordereddict import OrderedDict
# String formatting functions
Point.__str__ = lambda self: "x".join(map(str, self))
basic_str = lambda el: str(el).lstrip("(").rstrip(")") # Complex or model name
item_str = lambda k, v: (basic_str(v) if k in ["model", "c"] else
"{}={}".format(k, v))
filename = lambda kwargs: "_".join(item_str(*pair) for pair in kwargs.items())
# Example list
kwargs_list = [
OrderedDict([("model", "julia"),
("c", -.7102+.2698j),
("size", Point(500, 300)),
("depth", 512),
("zoom", .65),
]),
OrderedDict([("model", "julia"),
("c", -1.037+.17j),
("size", Point(600, 300)),
("depth", 40),
("zoom", .55),
]),
OrderedDict([("model", "julia"),
("c", -.644),
("size", Point(300, 200)),
("depth", 25),
("zoom", .6),
]),
OrderedDict([("model", "julia"),
("c", -.7+.27015j),
("size", Point(500, 300)),
("depth", 512),
("zoom", .6),
]),
OrderedDict([("model", "julia"),
("c", -.8+.156j),
("size", Point(500, 300)),
("depth", 512),
("zoom", .6),
]),
OrderedDict([("model", "julia"),
("c", -.8+.156j),
("size", Point(400, 230)),
("depth", 50),
("zoom", .65),
]),
OrderedDict([("model", "julia"),
("c", -.77777-.25j),
("size", Point(527, 331)),
("depth", 200),
("zoom", .7),
]),
OrderedDict([("model", "mandelbrot"),
("size", Point(500, 500)),
("depth", 80),
("zoom", .8),
("center", Point(-.75, 0)),
]),
OrderedDict([("model", "mandelbrot"),
("size", Point(300, 300)),
("depth", 80),
("zoom", 1.2),
("center", Point(-1, 0)),
]),
OrderedDict([("model", "mandelbrot"),
("size", Point(400, 300)),
("depth", 80),
("zoom", 2),
("center", Point(-1, 0)),
]),
OrderedDict([("model", "mandelbrot"),
("size", Point(500, 500)),
("depth", 256),
("zoom", 6.5),
("center", Point(-1.2, .35)),
]),
OrderedDict([("model", "mandelbrot"),
("size", Point(600, 600)),
("depth", 256),
("zoom", 90),
("center", Point(-1.255, .38)),
]),
]
# Creates all examples
if __name__ == "__main__":
for kwargs in kwargs_list:
kwargs["output"] = "images/{}.png".format(filename(kwargs))
#kwargs["show"] = True
exec_command(kwargs)