Advertisement
AntonioVillanueva

Un hexagono en Python con turtle

Feb 11th, 2019
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | None | 0 0
  1. #https://youtu.be/1kvBKFkqMHM
  2. import turtle
  3. import math
  4.  
  5. soixante =math.pi/3 #60 degrees ou pi/3 rads.
  6. angle=0
  7. radio =200
  8.  
  9. #Calculer une position un point de l'hexagone
  10. def  position(angle):
  11.     return ( (round (math.cos( angle)*radio )), round ((math.sin (angle))*radio))
  12.  
  13. turtle.shape('turtle')
  14. turtle.color('blue')
  15.  
  16. #premier point ...
  17. turtle.up()
  18. turtle.goto(radio,0)
  19. turtle.down()
  20.  
  21. #turtle.begin_fill()
  22.  
  23. while (angle<= (soixante*6) ):#6 fois 60 deg
  24.     #print (position(angle))   
  25.  
  26.     turtle.goto(position (angle))
  27.     #turtle.write(arg, move=False, align="left", font=("Arial", 8, "normal"))
  28.     turtle.write(  str(round (math.degrees (angle)))+"°"  +str (position(angle)),font=("Arial", 16, "normal"))#    écrire l'angle
  29.  
  30.     turtle.delay(100) #retard
  31.     angle+=soixante
  32.        
  33. #turtle.end_fill() 
  34. turtle.done()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement