This repository has been archived by the owner on Feb 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 96
/
main_detail_ani.py
executable file
·108 lines (63 loc) · 1.66 KB
/
main_detail_ani.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
102
103
104
105
106
107
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from numpy import pi
from numpy.random import random
from modules.growth import spawn_curl
from modules.growth import spawn
from numpy import zeros
NMAX = 10**6
SIZE = 800
ONE = 1./SIZE
PROCS = 2
INIT_RAD = 25*ONE
INIT_NUM = 40
STP = ONE*0.4
NEARL = 6*ONE
FARL = 60*ONE
MID = 0.5
LINEWIDTH = 5.*ONE
BACK = [1,1,1,1]
FRONT = [0,0,0,5]
RED = [1,0,0,0.3]
TWOPI = pi*2.
i = 0
def steps(df):
from time import time
from modules.helpers import print_stats
global i
t1 = time()
df.optimize_position(STP)
spawn_curl(df, NEARL)
#spawn(df, NEARL, 0.05)
if df.safe_vertex_positions(3*STP)<0:
print('vertices reached the boundary. stopping.')
return False
t2 = time()
print_stats(i, t2-t1, df)
return True
np_coords = zeros(shape=(NMAX,4), dtype='float')
np_vert_coords = zeros(shape=(NMAX,2), dtype='float')
def main():
from iutils.render import Animate
from differentialLine import DifferentialLine
from modules.show import show_closed
from modules.show import show_detail
from modules.show import show
DF = DifferentialLine(NMAX, FARL*2, NEARL, FARL, PROCS)
angles = sorted(random(INIT_NUM)*TWOPI)
DF.init_circle_segment(MID,MID,INIT_RAD, angles)
def wrap(render):
global i
# animation stops when res is False
res = steps(DF)
## if fn is a path each image will be saved to that path
fn = None
## render outline with marked circles
num = DF.np_get_edges_coordinates(np_coords)
show_detail(render,np_coords[:num,:],fn)
i += 1
return res
render = Animate(SIZE, BACK, FRONT, wrap)
render.start()
if __name__ == '__main__':
main()