/Demo/turtle/tdemo_yinyang.py

http://unladen-swallow.googlecode.com/ · Python · 49 lines · 36 code · 2 blank · 11 comment · 0 complexity · 0611772967609a1b8bd3a523909e5b83 MD5 · raw file

  1. #!/usr/bin/python
  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")
  13. fill(True)
  14. circle(radius/2., 180)
  15. circle(radius, 180)
  16. left(180)
  17. circle(-radius/2., 180)
  18. color(color1)
  19. fill(True)
  20. color(color2)
  21. left(90)
  22. up()
  23. forward(radius*0.375)
  24. right(90)
  25. down()
  26. circle(radius*0.125)
  27. left(90)
  28. fill(False)
  29. up()
  30. backward(radius*0.375)
  31. down()
  32. left(90)
  33. def main():
  34. reset()
  35. yin(200, "white", "black")
  36. yin(200, "black", "white")
  37. ht()
  38. return "Done!"
  39. if __name__ == '__main__':
  40. main()
  41. mainloop()