1 | n/a | #!/usr/bin/env python3 |
---|
2 | n/a | """ turtle-example-suite: |
---|
3 | n/a | |
---|
4 | n/a | tdemo_peace.py |
---|
5 | n/a | |
---|
6 | n/a | A simple drawing suitable as a beginner's |
---|
7 | n/a | programming example. Aside from the |
---|
8 | n/a | peacecolors assignment and the for loop, |
---|
9 | n/a | it only uses turtle commands. |
---|
10 | n/a | """ |
---|
11 | n/a | |
---|
12 | n/a | from turtle import * |
---|
13 | n/a | |
---|
14 | n/a | def main(): |
---|
15 | n/a | peacecolors = ("red3", "orange", "yellow", |
---|
16 | n/a | "seagreen4", "orchid4", |
---|
17 | n/a | "royalblue1", "dodgerblue4") |
---|
18 | n/a | |
---|
19 | n/a | reset() |
---|
20 | n/a | Screen() |
---|
21 | n/a | up() |
---|
22 | n/a | goto(-320,-195) |
---|
23 | n/a | width(70) |
---|
24 | n/a | |
---|
25 | n/a | for pcolor in peacecolors: |
---|
26 | n/a | color(pcolor) |
---|
27 | n/a | down() |
---|
28 | n/a | forward(640) |
---|
29 | n/a | up() |
---|
30 | n/a | backward(640) |
---|
31 | n/a | left(90) |
---|
32 | n/a | forward(66) |
---|
33 | n/a | right(90) |
---|
34 | n/a | |
---|
35 | n/a | width(25) |
---|
36 | n/a | color("white") |
---|
37 | n/a | goto(0,-170) |
---|
38 | n/a | down() |
---|
39 | n/a | |
---|
40 | n/a | circle(170) |
---|
41 | n/a | left(90) |
---|
42 | n/a | forward(340) |
---|
43 | n/a | up() |
---|
44 | n/a | left(180) |
---|
45 | n/a | forward(170) |
---|
46 | n/a | right(45) |
---|
47 | n/a | down() |
---|
48 | n/a | forward(170) |
---|
49 | n/a | up() |
---|
50 | n/a | backward(170) |
---|
51 | n/a | left(90) |
---|
52 | n/a | down() |
---|
53 | n/a | forward(170) |
---|
54 | n/a | up() |
---|
55 | n/a | |
---|
56 | n/a | goto(0,300) # vanish if hideturtle() is not available ;-) |
---|
57 | n/a | return "Done!" |
---|
58 | n/a | |
---|
59 | n/a | if __name__ == "__main__": |
---|
60 | n/a | main() |
---|
61 | n/a | mainloop() |
---|