1 | n/a | #!/usr/bin/env python3 |
---|
2 | n/a | """ turtle-example-suite: |
---|
3 | n/a | |
---|
4 | n/a | tdemo_yinyang.py |
---|
5 | n/a | |
---|
6 | n/a | Another drawing suitable as a beginner's |
---|
7 | n/a | programming example. |
---|
8 | n/a | |
---|
9 | n/a | The small circles are drawn by the circle |
---|
10 | n/a | command. |
---|
11 | n/a | |
---|
12 | n/a | """ |
---|
13 | n/a | |
---|
14 | n/a | from turtle import * |
---|
15 | n/a | |
---|
16 | n/a | def yin(radius, color1, color2): |
---|
17 | n/a | width(3) |
---|
18 | n/a | color("black", color1) |
---|
19 | n/a | begin_fill() |
---|
20 | n/a | circle(radius/2., 180) |
---|
21 | n/a | circle(radius, 180) |
---|
22 | n/a | left(180) |
---|
23 | n/a | circle(-radius/2., 180) |
---|
24 | n/a | end_fill() |
---|
25 | n/a | left(90) |
---|
26 | n/a | up() |
---|
27 | n/a | forward(radius*0.35) |
---|
28 | n/a | right(90) |
---|
29 | n/a | down() |
---|
30 | n/a | color(color1, color2) |
---|
31 | n/a | begin_fill() |
---|
32 | n/a | circle(radius*0.15) |
---|
33 | n/a | end_fill() |
---|
34 | n/a | left(90) |
---|
35 | n/a | up() |
---|
36 | n/a | backward(radius*0.35) |
---|
37 | n/a | down() |
---|
38 | n/a | left(90) |
---|
39 | n/a | |
---|
40 | n/a | def main(): |
---|
41 | n/a | reset() |
---|
42 | n/a | yin(200, "black", "white") |
---|
43 | n/a | yin(200, "white", "black") |
---|
44 | n/a | ht() |
---|
45 | n/a | return "Done!" |
---|
46 | n/a | |
---|
47 | n/a | if __name__ == '__main__': |
---|
48 | n/a | main() |
---|
49 | n/a | mainloop() |
---|