-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
117 lines (106 loc) · 3.51 KB
/
main.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
108
109
110
111
112
113
114
115
116
117
# import wx
# from drawing_frame_wx import DrawingFrame
import tkinter
from drawing_frame_tk import DrawingFrame
from drawing import Drawing
from linear_shift_drawing import LinearShiftDrawing
from linear_taper_drawing import LinearTaperDrawing
from linear_start_drawing import LinearStartDrawing
from sized_start_drawing import SizedStartDrawing
from fade_drawing import FadeDrawing
from multiplier_drawing import MultiplierDrawing
class ShiftCombo(FadeDrawing,MultiplierDrawing,LinearStartDrawing,LinearShiftDrawing):
pass
class TaperCombo(FadeDrawing,MultiplierDrawing,LinearStartDrawing,LinearTaperDrawing):
pass
STANDARDS = {
'blueshift': (ShiftCombo,{
'background' : 'black',
'start_length' : 600,
'start_variation' : 20,
'variation' : 8,
'lines' : 70,
'weight' : 0.5,
'points' : 5,
'strokes' : 5,
'start_rgba' : [0,0,0,255],
'start_rgba_variation': [0,0,0,0],
'end_rgba' : [50,150,200,255],
'end_rgba_variation' : [20,50,50,0],
'bounded' : True
}),
'redshift' : (ShiftCombo,{
'background' : 'black',
'start_length' : 600,
'start_variation' : 20,
'variation' : 8,
'lines' : 70,
'weight' : 0.5,
'points' : 5,
'strokes' : 5,
'start_rgba' : [0,0,0,255],
'start_rgba_variation': [0,0,0,0],
'end_rgba' : [200,50,50,255],
'end_rgba_variation' : [50,30,20,0],
'bounded' : True
}),
'bluetaper': (TaperCombo,{
'background' : 'black',
'start_length' : 600,
'start_variation' : 20,
'variation' : 15,
'lines' : 70,
'weight' : 0.5,
'points' : 5,
'strokes' : 5,
'start_rgba' : [0,0,0,255],
'start_rgba_variation': [0,0,0,0],
'end_rgba' : [50,150,200,255],
'end_rgba_variation' : [20,50,50,0],
'bounded' : True
}),
'redtaper' : (TaperCombo,{
'background' : 'black',
'start_length' : 600,
'start_variation' : 20,
'variation' : 15,
'lines' : 70,
'weight' : 0.5,
'points' : 5,
'strokes' : 5,
'start_rgba' : [0,0,0,255],
'start_rgba_variation': [0,0,0,0],
'end_rgba' : [200,50,50,255],
'end_rgba_variation' : [50,30,20,0],
'bounded' : True
})
}
def invoke(drawing_class, **kargs):
tk = tkinter.Tk()
DrawingFrame(tk,drawing_class(**kargs),**kargs)
tk.mainloop()
def quick(standard_type, **kargs):
if standard_type not in STANDARDS:
print('Unknown type.')
return
drawing,settings = STANDARDS.get(standard_type.lower(),(None,None))
settings.update(kargs)
invoke(drawing,**settings)
def autosave(standard_type, num=10, folder='Images/AutoBackgrounds/', name_pattern='image_{i}.png', **kargs):
if standard_type not in STANDARDS:
print('Unknown type.')
return
if folder[-1] != '/':
folder += '/'
drawing,settings = STANDARDS.get(standard_type.lower(),(None,None))
settings.update(kargs)
tk = tkinter.Tk()
df = DrawingFrame(tk, drawing(**settings), **settings)
def _save(i):
if i > num:
tk.destroy() # TODO: check this
return
df.redraw()
df.save(name = folder + name_pattern.format(i=i))
tk.after(200, _save, i + 1)
tk.after(1000, _save, 1)