Advertisement
Guest User

Untitled

a guest
Jul 25th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. from turtle import Turtle
  2. def init_drawman():
  3. global t, x_current, y_corrent, _drawman_scale
  4. t = Turtle()
  5. t.penup()
  6. x_current = 0
  7. y_corrent = 0
  8. t.goto(x_current,y_corrent)
  9. drawman_scale(10)
  10.  
  11.  
  12. def drawman_setka():
  13. t.color("grey")
  14. y = _drawman_scale*-5
  15. x = _drawman_scale*-5
  16. for i in range(16):
  17. t.goto(x, y-_drawman_scale)
  18. pen_down()
  19. t.goto(x,y*-2+_drawman_scale)
  20. pen_up()
  21. x = x +_drawman_scale
  22. y = _drawman_scale * -5
  23. x = _drawman_scale * -5
  24. for i in range(16):
  25. t.goto(x-_drawman_scale, y)
  26. pen_down()
  27. t.goto(x*-2+_drawman_scale, y)
  28. pen_up()
  29. y = y + _drawman_scale
  30. t.color("black")
  31. y = _drawman_scale * -5
  32. x = _drawman_scale * -5
  33. t.goto(x-2*_drawman_scale,0)
  34. pen_down()
  35. t.goto(x*-2+2*_drawman_scale,0)
  36. pen_up()
  37. t.goto(0,y-2*_drawman_scale)
  38. pen_down()
  39. t.goto(0,y*-2+2*_drawman_scale)
  40. pen_up()
  41. t.color("red")
  42.  
  43. def drawman_scale(scale):
  44. global _drawman_scale
  45. _drawman_scale = scale
  46.  
  47. def test_drawman():
  48. pen_down()
  49. for i in range(5):
  50. on_vector(10,20)
  51. on_vector(0,-20)
  52. pen_up()
  53. to_point(0,0)
  54.  
  55. def pen_down():
  56. t.pendown()
  57.  
  58. def pen_up():
  59. t.penup()
  60.  
  61. def on_vector(dx,dy):
  62. to_point(x_current + dx,y_corrent + dy)
  63.  
  64. def to_point(x,y):
  65. global x_current, y_corrent
  66. x_current=x
  67. y_current=y
  68. t.goto(_drawman_scale*x_current,_drawman_scale*y_current)
  69.  
  70.  
  71. init_drawman()
  72. if __name__ == '__main__':
  73. test_drawman()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement