Guest User

Untitled

a guest
Apr 21st, 2020
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.62 KB | None | 0 0
  1. from graph import *
  2. from math import sin, cos, pi
  3. window = mainWindow()
  4. window.geometry('600x600+350+70')
  5. canvasSize(600, 600)
  6.  
  7.  
  8. def ellipse(x1, y1, x2, y2, vertex_count = 36):
  9.     (x1, x2) = (min(x1, x2), max(x1, x2))
  10.     (y1, y2) = (min(y1, y2), max(y1, y2))
  11.     a = (x2 - x1) / 2
  12.     b = (y2 - y1) / 2
  13.     VERTEX = [(a * cos(i * 2 * pi / vertex_count) + (x1 + x2) / 2,\
  14.                 b * sin(i * 2 * pi / vertex_count) + (y1 + y2) / 2)\
  15.                     for i in range(vertex_count)]
  16.     mypol = polygon(VERTEX)
  17.     return mypol
  18.  
  19.  
  20. # Draw a background
  21. penColor('cyan')
  22. brushColor('cyan')
  23. rectangle(90, 0, 510, 600)
  24. penColor(231, 231, 231)
  25. brushColor(231, 231, 231)
  26. rectangle(90, 340, 510, 600)
  27. penColor('black')
  28. line(90, 340, 510, 340)
  29.  
  30. # Draw a sun
  31. penColor(161, 249, 228)
  32. brushColor(161, 249, 228)
  33. ellipse(196, - 33, 489, 243, vertex_count = 36)
  34.  
  35. penColor('cyan')
  36. brushColor('cyan')
  37. circle(343, 103, 118)
  38.  
  39. penColor(161, 249, 228)
  40. brushColor(161, 249, 228)
  41. polygon([(334, - 30), (354, - 30), (347, 243), (328, 242)])
  42. polygon([(194, 95), (490, 100), (490, 120), (194, 115)])
  43.  
  44. brushColor(221, 247, 219)
  45. polygon([(328, 242), (328, 220), (349, 220), (349, 243)])
  46. polygon([(196, 95), (226, 95), (226, 117), (196, 117)])
  47. polygon([(461, 99), (489, 99), (489, 120), (460, 120)])
  48. polygon([(330, 97), (352, 97), (352, 119), (330, 119)])
  49.  
  50. penColor(255, 246, 214)
  51. brushColor(255, 246, 214)
  52. ellipse(332, 226, 347, 241, vertex_count = 36)
  53. ellipse(197, 98, 216, 114, vertex_count = 36)
  54. ellipse(467, 102, 487, 117, vertex_count = 36)
  55. ellipse(328, 91, 364, 121, vertex_count = 36)
  56.  
  57. # Draw a hole
  58. penColor('black')
  59. brushColor(76, 76, 76)
  60. ellipse(335, 430, 490, 480, vertex_count = 36)
  61. brushColor(15, 79, 66)
  62. ellipse(350, 445, 475, 480, vertex_count = 36)
  63.  
  64. # Draw a fishing rod
  65. penColor('black')
  66. penSize(2)
  67. line(235, 382, 246, 336)
  68. line(246, 336, 425, 165)
  69. penSize(1)
  70. line(425, 165, 425, 465)
  71.  
  72. # Draw a bear:
  73. # a head
  74. penColor('black')
  75. brushColor(231, 231, 231)
  76. ellipse(160, 236, 252, 283, vertex_count = 36)
  77. circle(173, 246, 8)
  78. brushColor('black')
  79. circle(200, 250, 2.6)
  80. circle(252, 256, 2.6)
  81. line(195, 271, 225, 271)
  82. line(225, 271, 248, 269)
  83.  
  84. # a torso
  85. brushColor(231, 231, 231)
  86. ellipse(91, 270, 231, 520, vertex_count = 36)
  87. ellipse(165, 450, 270, 530, vertex_count = 36)
  88. ellipse(230, 510, 310, 538, vertex_count = 36)
  89. ellipse(207, 324, 264, 350, vertex_count = 36)
  90.  
  91. # Draw a fish:
  92. # a torso
  93. brushColor(193, 204, 202)
  94. polygon([(380, 540),
  95.          (390, 530),
  96.          (400, 523),
  97.          (410, 519),
  98.          (420, 516),
  99.          (430, 516),
  100.          (440, 517),
  101.          (450, 519),
  102.          (460, 522),
  103.          (450, 531),
  104.          (440, 537),
  105.          (430, 540),
  106.          (420, 542),
  107.          (410, 543),
  108.          (400, 543),
  109.          (390, 542),
  110.          (380, 540)])
  111.  
  112. # a tail
  113. polygon([(360, 565),
  114.          (350, 545),
  115.          (360, 545),
  116.          (370, 544),
  117.          (380, 540)])
  118.  
  119. # a fins
  120. brushColor(222, 167, 167)
  121. polygon([(410, 519),
  122.          (405, 516),
  123.          (400, 513),
  124.          (390, 510),
  125.          (430, 506),
  126.          (433, 511),
  127.          (430, 516),
  128.          (420, 516)])
  129.  
  130. polygon([(439, 538),
  131.          (444, 542),
  132.          (449, 542),
  133.          (437, 550),
  134.          (434, 548),
  135.          (432, 545),
  136.          (430, 540)])
  137.  
  138. polygon([(400, 543),
  139.          (399, 546),
  140.          (396, 551),
  141.          (392, 553),
  142.          (409, 553),
  143.          (411, 549),
  144.          (409, 543)])
  145.  
  146. # an eye
  147. brushColor(121, 121, 243)
  148. circle(442, 526, 5)
  149. brushColor(127, 133, 141)
  150. circle(443, 527, 2)
  151. penColor(219, 219, 36)
  152. penSize(2)
  153. line(439, 525, 441, 527)
  154.  
  155. run()
Advertisement
Add Comment
Please, Sign In to add comment