WHCSRL 技术网

用python的turtle库画一个写轮眼(血轮眼)

如下

  1. from math import *
  2. from turtle import *
  3. home()
  4. speed(0)
  5. r=260#大小 圆设置
  6. x=2
  7. screensize(400,300,"black")
  8. y=x*r
  9. z=sqrt(pow(r,2)+pow(y,2))
  10. w=40
  11. pu()
  12. right(90)
  13. fd(240)
  14. left(90)
  15. pd()
  16. fillcolor("red")
  17. begin_fill()
  18. circle(r)
  19. end_fill()
  20. pu()
  21. left(90)
  22. fd(r)
  23. #复位中心上键
  24. #print(pos())(显示坐标)
  25. speed(0)
  26. width(7)
  27. for i in range(6):
  28.     right(60+90)#六边
  29.     fd(y)
  30.     right(90)
  31.     fd(z)
  32.     left(90)
  33.     pd()
  34.     circle(z)
  35.     pu()
  36.     #取线
  37.     left(90)
  38.     fd(z)
  39.     left(90)
  40.     fd(y)
  41.     right(90)
  42. fd(w)
  43. #内小圆
  44. left(90)
  45. pd()
  46. fillcolor("red")#内小圆颜色
  47. begin_fill()
  48. print(pos())
  49. circle(w)
  50. end_fill()
  51. #circle(w)
  52. left(90)
  53. pu()
  54. fd(w)
  55. left(90)
  56. fd(39)
  57. pd()
  58. fillcolor("black")
  59. begin_fill()
  60. goto(0,220)
  61. goto(-40,20)
  62. pu()
  63. goto(20,20*sqrt(3)+20)
  64. end_fill()
  65. pd()
  66. fillcolor("black")
  67. begin_fill()
  68. goto(100*sqrt(3),-80)
  69. goto(-20,20-20*sqrt(3))
  70. pu()
  71. goto(20,20-20*sqrt(3))
  72. end_fill()
  73. pd()
  74. fillcolor("black")
  75. begin_fill()
  76. goto(-100*sqrt(3),-80)
  77. goto(-20,20*sqrt(3)+20)
  78. pu()
  79. goto(0,20)
  80. end_fill()
  81. goto(0,60)
  82. right(180)
  83. fillcolor("red")#内小圆颜色
  84. begin_fill()
  85. print(pos())
  86. circle(w)
  87. end_fill()
  88. hideturtle()#隐藏海龟
  89. #新赤
  90. exitonclick()

推荐阅读