-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrose.py
58 lines (49 loc) · 1.42 KB
/
rose.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
from bokeh.plotting import figure, show
import math
import numpy as np
import random
def get_circle_coords(r, max_deg, sep):
xs = []
ys = []
for deg in np.arange(0.0, max_deg, sep):
rad = math.radians(deg)
x = r * math.cos(rad)
y = r * math.sin(rad)
xs.append(x)
ys.append(y)
return (xs, ys)
def draw(ratios, radiuses, tick):
ratio_coords = []
for i in range(0, len(ratios)):
ratio = ratios[i]
max_deg = ratio * 360
sep = max_deg / tick
ratio_coord = get_circle_coords(radiuses[i], max_deg, sep)
ratio_coords.append(ratio_coord)
lengths = []
for ratio_coord in ratio_coords:
lengths.append(len(ratio_coord[0]))
iter = min(lengths)
p = figure(title = "Rose of Venus", x_axis_label = "x", y_axis_label = "y")
for i in range(0, iter):
xs = []
ys = []
for ratio_coord in ratio_coords:
xs.append(ratio_coord[0][i])
ys.append(ratio_coord[1][i])
r = 237
g = 149
b = 147
# r = random.randint(0, 255)
# g = random.randint(0, 255)
# b = random.randint(0, 255)
p.line(xs, ys, line_width = 0.5, color = (r, g, b))
show(p)
def main():
ratio = [8, 13]
radius = [100, 70]
num_lines = 2000
draw(ratio, radius, num_lines)
# draw([8, 13, 21], [100, 30, 10], 1000)
if __name__ == '__main__':
main()