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