-
Notifications
You must be signed in to change notification settings - Fork 0
/
marazm-falling-snowflake-2.py
executable file
·93 lines (70 loc) · 1.93 KB
/
marazm-falling-snowflake-2.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
#!/usr/bin/python3
#
# jip, 20.12.2017, falling into marasmus... :-)
#
import sys
import tkinter
from tkinter import Button
from tkinter import TOP, BOTTOM, LEFT
import time
from random import randint
#from Line import Line
from Point import Point
from Snowflake import Snowflake
def quit():
root.destroy()
sys.exit(0)
def get_color( r, g, b ):
c = '#%02x%02x%02x' % (r, g, b)
return c
# ------------------------------------
root = tkinter.Tk()
root.title("... marasmus was getting stronger ...")
Button(root, text="ой фсё...", command=quit).pack( side = BOTTOM )
w=1200
h=800
canvas = tkinter.Canvas(root, width=w, height=h, background='black')
canvas.pack()
def start():
h = int( canvas['height'] )
w = int( canvas['width'] )
number_w = 14.0
between_w = w/number_w
r = 255
g = 255
b = 255
x = 0
y = 0
sfss = []
distance = 75
LIM = 11
while True:
if distance%75 == 0:
#if distance <= 45:
sfs = []
while x < w + 10:
direction = randint(-1, 1)
start_angle = randint(-10, 10)
l = randint(6, 9)
x_delta = randint(-30, 30)
y_delta = randint(-15, 15)
s = Snowflake( Point( x+x_delta, y_delta ), get_color( r, g, b ), l, start_angle, direction )
s.draw( canvas )
sfs.append( s )
x += between_w
sfss.insert( 0, sfs )
# sfss.append( sfs )
x = 0
distance += 1
#l += l
canvas.update()
time.sleep(0.0001)
for sf in sfss:
for s in sf:
s.mv( canvas, 0, 1 )
# canvas.update()
# print( "len(sfss): ", len(sfss) )
if( distance%1500) == 0: LIM -= 1
if len(sfss) >= LIM: del sfss[ len(sfss)-1 ]
root.after(0, start)
root.mainloop()