yinyang.py 821 B

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