creating captain America shield using turtle python

  1. import turtle
  2.  
  3. import math
  4.  
  5. import time
  6.  
  7.  
  8.  
  9. t = turtle.Turtle()
  10.  
  11.  
  12.  
  13.  
  14.  
  15. def fnA(x, y):
  16.  
  17.     t.penup()
  18.  
  19.     t.goto(x, y)
  20.  
  21.     t.pendown()
  22.  
  23.     t.setheading(0)
  24.  
  25.     t.pensize(2)
  26.  
  27.     t.speed(10)
  28.  
  29.  
  30.  
  31.  
  32.  
  33. def fnB(r, color):
  34.  
  35.     x_point = 0
  36.  
  37.     y_pont = -r
  38.  
  39.     fnA(x_point, y_pont)
  40.  
  41.     t.pencolor(color)
  42.  
  43.     t.fillcolor(color)
  44.  
  45.     t.begin_fill()
  46.  
  47.     t.circle(r)
  48.  
  49.     t.end_fill()
  50.  
  51.  
  52.  
  53.  
  54.  
  55. def fnC(r, color):
  56.  
  57.     fnA(0, 0)
  58.  
  59.     t.pencolor(color)
  60.  
  61.     t.setheading(162)
  62.  
  63.     t.forward(r)
  64.  
  65.     t.setheading(0)
  66.  
  67.     t.fillcolor(color)
  68.  
  69.     t.begin_fill()
  70.  
  71.     for i in range(5):
  72.  
  73.         t.forward(math.cos(math.radians(18)) * 2 * r)  # 2cos18°*r
  74.  
  75.         t.right(144)
  76.  
  77.     t.end_fill()
  78.  
  79.     t.hideturtle()
  80.  
  81.  
  82.  
  83.  
  84.  
  85. if __name__ == '__main__':
  86.  
  87.     time.sleep(5)
  88.  
  89.     fnB(288, 'crimson')
  90.  
  91.     fnB(234, 'snow')
  92.  
  93.     fnB(174, 'crimson')
  94.  
  95.     fnB(114, 'blue')
  96.  
  97.     fnC(114, 'snow')
  98.  
  99.     turtle.done()

Comments

Popular posts from this blog

creating lord shiva 2 by turtle python apni programming

creating half face lord shiva by python turtle

navratri special turtle python apni programming