-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtdus.py
44 lines (34 loc) · 1.06 KB
/
tdus.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
import turtledraw as td
td.set_turtlecfg(True)
td.set_filling(True)
td.set_animation(True)
HEIGHT = 600
h = HEIGHT
w = int(h* 1.9)
hs = h/13 # strip_height
wa = w * 2 / 5 # star_area_width
ha = h * 7 / 13 # star_area_height
wc = wa * 3 / 35 # star_cell_width
hc = ha * 3 / 29 # star_cell_height
wp = wa * 1 / 35 # star_padding_width
hp = ha * 1 / 29 # star_padding_height
center_a = (-(w-wa)/2,(h-ha)/2)
td.set_window('National Flag',width=w,height=h,bg='gray')
td.rect(center_a,wa,ha,colors='blue')
for i in range(13):
if i <7:
center_x,ws = wa/2,w-wa
else:
center_x,ws = 0,w
center_y = h/2-hs/2-hs*i
strip_color = 'white' if i%2 else 'red'
td.rect((center_x,center_y),ws,hs,colors=strip_color)
td.grid(center_a,wa-2*wp,ha-2*hp,9,11,colors='black')
for i in range(9):
for j in range(11):
if (i+j) % 2 == 0:
rx,ry = (j+0.5)*wc,(i+0.5)*hc
center = (-w/2+wp+rx,h/2-hp-ry)
td.star(center,hc/2-1,90,colors='white')
td.grid(center_a,wa-2*wp,ha-2*hp,9,11,colors='blue')
td.show()