def wing(scale: float, reflect: bool): """The Swan's wing""" penSize(scale) # Points were selected randomly, attention wing_pts = [(50, 100), (40, 90), (40, 40), (10, 0), (30, 0), (100, 60), (105, 70), (100, 80), (60, 100)] return poly_sr(wing_pts, scale, reflect)
def draw_clouds(center_of_the_fisrt_cloud_x, center_of_the_first_cloud_y, cloud_radius_x, cloud_radius_y): cloud_object = [] g.penSize(pen_width_1) cloud_color = 'white' g.brushColor(cloud_color) g.penColor('grey') step_of_clouds = 3 / 2 * cloud_radius_x center_cloud_1_x = center_of_the_fisrt_cloud_x center_cloud_1_y = center_of_the_first_cloud_y number_of_clouds_1 = 2 for _ in range(number_of_clouds_1): obj = draw_an_ellipse(center_cloud_1_x, center_cloud_1_y, cloud_radius_x, cloud_radius_y) center_cloud_1_x += step_of_clouds cloud_object.append(obj) center_cloud_2_x = center_of_the_fisrt_cloud_x - cloud_radius_x center_cloud_2_y = center_of_the_first_cloud_y + cloud_radius_y number_of_clouds_2 = 3 for _ in range(number_of_clouds_2): obj = draw_an_ellipse(center_cloud_2_x, center_cloud_2_y, cloud_radius_x, cloud_radius_y) center_cloud_2_x += step_of_clouds cloud_object.append(obj) obj1 = draw_an_ellipse(center_cloud_1_x, center_cloud_1_y, cloud_radius_x, cloud_radius_y) cloud_object.append(obj1) obj2 = draw_an_ellipse(center_cloud_2_x, center_cloud_2_y, cloud_radius_x, cloud_radius_y) cloud_object.append(obj2) return cloud_object
def quadrant(x, y, radius): graph.penSize(0) graph.brushColor("brown") graph.circle(x, y, radius) graph.brushColor("blue") graph.rectangle(x - radius, y - radius, x, y) graph.rectangle(x, y - radius, x + radius + 1, y + radius + 1)
def draw_clouds(center_of_the_fisrt_cloud_x, center_of_the_first_cloud_y, cloud_radius_x, cloud_radius_y): g.penSize(pen_width_1) cloud_color = 'white' g.brushColor(cloud_color) g.penColor('grey') step_of_clouds = 3 / 2 * cloud_radius_x center_cloud_1_x = center_of_the_fisrt_cloud_x center_cloud_1_y = center_of_the_first_cloud_y number_of_clouds_1 = 2 for i in range(number_of_clouds_1): draw_an_ellipse(center_cloud_1_x, center_cloud_1_y, cloud_radius_x, cloud_radius_y) center_cloud_1_x += step_of_clouds center_cloud_2_x = center_of_the_fisrt_cloud_x - cloud_radius_x center_cloud_2_y = center_of_the_first_cloud_y + cloud_radius_y number_of_clouds_2 = 3 for i in range(number_of_clouds_2): draw_an_ellipse(center_cloud_2_x, center_cloud_2_y, cloud_radius_x, cloud_radius_y) center_cloud_2_x += step_of_clouds draw_an_ellipse(center_cloud_1_x, center_cloud_1_y, cloud_radius_x, cloud_radius_y) draw_an_ellipse(center_cloud_2_x, center_cloud_2_y, cloud_radius_x, cloud_radius_y)
def fish(): """The Fish""" penSize(1) penColor('black') brushColor('#9c292d') fish_objs = [ polygon([(60, 85), (110, 93), (110, 107), (60, 115), (80, 100)]), # Tail polygon([(140, 100), (135, 70), (162, 74), (188, 68), (205, 76), (200, 100)]), # Upper fin polygon([(134, 110), (150, 110), (152, 130), (130, 127)]), # Lower hind fin polygon([(185, 110), (197, 110), (200, 128), (187, 131)]) ] # Lower front fin brushColor('#9fbde6') penColor(brushColor()) fish_objs.extend([ polygon([(195, 85), (190, 115), (235, 100)]), # Head ellipse_sr(120, 80, 210, 120, 1, False), # Body polygon([(95, 91), (95, 109), (130, 113), (130, 87)]) ]) # Ass brushColor('green') fish_objs.append(circle(206, 96, 5)) # Eyeball brushColor('black') penColor('black') fish_objs.append(circle(207, 95, 2)) # Eye pupil return fish_objs
def sea(x, y): """ Рисует море. (x, y) -- координаты левой верхней точки прямоугольника-моря. """ graph.brushColor(30, 144, 255) graph.penSize(0) graph.rectangle(x, y, x + 800, y + 120)
def foot(scale: float, reflect: bool): """The Swan's foot""" penSize(scale) # Points were selected randomly, attention foot_pts = [(239, 243), (230, 250), (235, 250), (245, 240), (255, 230), (250, 230), (242, 240), (247, 228), (242, 228), (241, 240), (240, 225), (235, 225), (239, 237), (219, 227), (217, 233)] return poly_sr(foot_pts, scale, reflect)
def sky(x, y): """ Рисует небо. (x, y) -- координаты левой верхней точки прямоугольника-неба. """ graph.brushColor(173, 216, 230) graph.penSize(0) graph.rectangle(0, 0, x + 800, y + 330)
def beach(x, y): """ Рисует песчаный пляж. (x, y) -- координаты левой верхней точки прямоугольника-пляжа. """ graph.brushColor('yellow') graph.penSize(0) graph.rectangle(x, y, x + 800, y + 150)
def sun(x, y, r): """ Рисует Солнце. (x, y) -- координаты центра окружности Солнца; r -- радиус Солнца. """ graph.brushColor("yellow") graph.penSize(0) graph.circle(x, y, r)
def bird_pts(): """Generate a point array which can be used to draw a bird""" penColor('white') penSize(3) points = [] for i in range(30): points.append((i - 30, 0.02 * i * (i - 30))) for i in range(31): points.append((i, 0.02 * i * (i - 30))) return points
def ufo_light(x, y, size): # light - light pillar of an ufo penSize(0) brushColor(210, 250, 210) penColor(210, 250, 210) light = [] light.append((x, y)) light.append((x - 20 * size, y + 20 * size)) light.append((x + 20 * size, y + 20 * size)) polygon(light)
def swan(scale: float = 1., reflect: bool = False): """The Swan""" penSize(scale) penColor('black') brushColor('orange') swan_objs = [ ellipse_sr(380, 110, 418, 120, scale, reflect), # Element #0 - beak lower part ellipse_sr(380, 105, 420, 115, scale, reflect), # Element #1 - beak upper part foot(scale, reflect), # Element #2 - left foot foot(scale, reflect) ] # Element #3 - right foot moveObjectBy(swan_objs[2], reflect_offset(14 * scale, reflect), 6 * scale) # Move left foot to needed position moveObjectBy(swan_objs[3], reflect_offset(74 * scale, reflect), 6 * scale) # Move left right to needed position brushColor('white') # Points were selected randomly, attention tail_pts = [(160, 125), (160, 150), (80, 163), (103, 150), (70, 141), (100, 129), (80, 110)] swan_objs.extend([ wing(scale, reflect), # Element #4 - left wing wing(scale, reflect), # Element #5 - right wing poly_sr(tail_pts, scale, reflect) ]) # Element #6 - tail moveObjectBy(swan_objs[4], reflect_offset(140 * scale, reflect), 7 * scale) # Move left wing to needed position moveObjectBy(swan_objs[5], reflect_offset(190 * scale, reflect), 7 * scale) # Move right wing to needed position penColor('white') swan_objs.extend([ ellipse_sr(150, 100, 300, 180, scale, reflect), # Element #7 - body ellipse_sr(280, 110, 340, 140, scale, reflect), # Element #8 - neck ellipse_sr(330, 95, 390, 130, scale, reflect) ]) # Element #9 - head brushColor('black') swan_objs.append(ellipse_sr(360, 102, 372, 110, scale, reflect)) # Element #10 - eye penSize(10 * scale) swan_objs.extend([ line_sr(190, 160, 220, 230, scale, reflect), # Elements ##11-16 - legs line_sr(250, 160, 280, 230, scale, reflect), line_sr(220, 230, 240, 240, scale, reflect), line_sr(280, 230, 300, 240, scale, reflect), circle({ False: 220 * scale, True: 400 - 220 * scale }[reflect], 230 * scale, 1.5 * scale), circle({ False: 280 * scale, True: 400 - 280 * scale }[reflect], 230 * scale, 1.5 * scale) ]) return swan_objs
def eyes(x, y, size, mirror): """ draws two black circles and two ellipses inside them, the coord of middle point is (x,y), can be mirrored """ penSize(1) brushColor('black') circle(x + 1 * size, y - 2.8 * size, size // 2) circle(x - 1 * size, y - 2.8 * size, size // 2) brushColor('white') ellips(x + 1.2 * size * mirror, y - 2.9 * size, size // 6, size // 4, 0) ellips(x - 0.8 * size * mirror, y - 2.9 * size, size // 6, size // 4, 0)
def waves(y): # Enter y coordinate of border between sea and sand. penSize(0) r = 40 n = 15 for i in range(n): x = i * r * 2 * sqrt(3) brushColor(0, 0, 205) circle(x - r * sqrt(3) / 2, y - r / 2, r) brushColor(255, 229, 124) circle(x + r * sqrt(3) / 2, y + r / 2, r)
def spyral(koef=1, X=100, Y=150): penSize(10) moveTo(X * k, Y * k) j = 0 while j < 360 * 4 * abs(koef): rho = j / 10 * koef / abs(koef) lineTo(100 * k + rho * math.sin(j / 360 * 3.14) + X * k - 100 * k, 150 * k + rho * math.cos(j / 360 * 3.14) + Y * k - 150 * k) j += 1 if j % 30 == 0: penColor(randColor())
def horns(x, y, size, color="red"): """ note: it is possible to change the cf alien's ball (horn balls) """ penSize(0.5 * size) line(x + 1.6 * size, y - 3 * size, x + 2.2 * size, y - 4 * size) line(x - 1.6 * size, y - 3 * size, x - 2.2 * size, y - 4 * size) brushColor(color) penSize(0.15 * size) circle(x + 2.3 * size, y - 4.1 * size, 0.3 * size) circle(x - 2.3 * size, y - 4.1 * size, 0.3 * size)
def gradient(R=225, G=0, B=0): i = 0 global k penSize(1) R = R / (300 * k) G = G / (300 * k) B = B / (300 * k) print(R, G, B) while i < 300 * k: penColor(int(R * i) + 20, int(G * i) + 20, int(B * i) + 20) line(0, i, 200 * k, i) i += 1
def tree(bottom_tree_x, bottom_tree_y, barrel_length): """ bottom_tree_x and bottom_tree_y -- центральные координаты низа дерева. barrel_length -- высота дерева barrel_lengt/8 -- ширина этого дерева У всех шариков радиусы barrel_length/4 Центры двух нижних шариков находятся на той же выстое, что и макушка дерева, и они на расстоянии barrel_length/4 от центральной оси симметрии. Их координаты: левая: (bottom_tree_x - barrel_length/4, bottom_tree_y - barrel_length) правая -- (bottom_tree_x + barrel_length/4, bottom_tree_y - barrel_length) Третий шарик считая снизу выше макушки дерева на barrel_length/5 Он находится по центру координата x -- bottom_tree_x координата y -- bottom_tree_y - 6/5 * barrel_length) Четвёртый и пятый шарик считая снизу выше маушки дерева на barrel_length/3, и они на расстоянии barrel_length/3 от центральной оси симметрии левый шарик: координата x -- bottom_tree_x - barrel_length/3 кооридината y -- bottom_tree_y - 4/3 * barrel_length) правый шарик: координата x -- bottom_tree_x + barrel_length/3, координата y -- bottom_tree_y - 4/3 * barrel_length) Наивысшый шарик выше макушки дерева на 4/7*barrel_length, и он расположен по центру координата x -- bottom_tree_x координата y -- bottom_tree_y - 27 / 17 * barrel_length), barrel_length/4) """ # barrel graph.penColor("black") graph.brushColor("black") graph.rectangle(bottom_tree_x - barrel_length / 16, bottom_tree_y, bottom_tree_x + barrel_length / 16, bottom_tree_y - barrel_length) # leaves graph.penSize(1) graph.penColor("black") graph.brushColor("green") graph.circle(bottom_tree_x, bottom_tree_y - 27 / 17 * barrel_length, barrel_length / 4) graph.circle(bottom_tree_x - barrel_length/3, bottom_tree_y - (barrel_length + barrel_length/3), barrel_length/4) graph.circle(bottom_tree_x + barrel_length/3, bottom_tree_y - (barrel_length + barrel_length/3), barrel_length/4) graph.circle(bottom_tree_x, bottom_tree_y - (barrel_length + barrel_length/5), barrel_length/4) graph.circle(bottom_tree_x - barrel_length/4, bottom_tree_y - barrel_length, barrel_length/4) graph.circle(bottom_tree_x + barrel_length/4, bottom_tree_y - barrel_length, barrel_length/4)
def sun(x, y, r, ray): # Enter x, y - center coordinates, r - rad, ray - ray length + rad. brushColor('yellow') penColor('yellow') penSize(0) v = 40 # v is the number of rays. for i in range(v): phi1 = 2 * i * pi / v phi2 = 2 * (i + 1) * pi / v polygon([(x, y), (x + r * cos(phi1), y + r * sin(phi1)), (x + ray * cos(phi1 + pi / v), y + ray * sin(phi1 + pi / v)), (x + r * cos(phi2), y + r * sin(phi2))])
def cloud(x, y, r): """ Рисует облако с круглыми перьями. (x, y) -- координаты центра окружности левого верхнего пера облака; r -- радиус пера облака. """ graph.brushColor('white') graph.penSize(2) number_of_feather = 4 number_of_row = 2 for i in range(number_of_feather): for j in range(number_of_row): graph.circle(x - 25*j + 25*i, y + 25*j, r) graph.circle(x - 25*number_of_row + 25*(number_of_feather + 1), y + 25*(number_of_row - 1), r)
def backgroung(length_sky): """ Эта функция берёт длинну неба и заполняет остальное пространство кроме неба травой. Также она отвечает за ширину и высоту экрана """ main_screen_width = 1600 main_screen_height = 1000 graph.windowSize(main_screen_width, main_screen_height) graph.penSize(0) graph.brushColor("skyblue") graph.rectangle(0, 0, main_screen_width, length_sky) graph.brushColor("limegreen") graph.rectangle(0, length_sky, main_screen_width, main_screen_height)
def plant(a, x, b, y): graph.brushColor(0, 102, 53) graph.penColor(0, 102, 53) graph.penSize(2) # Далее ветки graph.polyline([(119 * a + x, 27 * b + y), (152 * a + x, 30 * b + y), (174 * a + x, 37 * b + y), (199 * a + x, 49 * b + y), (213 * a + x, 58 * b + y), (229 * a + x, 71 * b + y)]) graph.polyline([(274 * a + x, 57 * b + y), (286 * a + x, 41 * b + y), (304 * a + x, 26 * b + y), (326 * a + x, 14 * b + y), (342 * a + x, 7 * b + y), (362 * a + x, 4 * b + y), (376 * a + x, 2 * b + y)]) graph.polyline([(270 * a + x, 113 * b + y), (274 * a + x, 103 * b + y), (280 * a + x, 96 * b + y), (287 * a + x, 88 * b + y), (297 * a + x, 80 * b + y), (305 * a + x, 76 * b + y), (314 * a + x, 76 * b + y), (321 * a + x, 75 * b + y), (329 * a + x, 78 * b + y), (333 * a + x, 79 * b + y)]) graph.polyline([(170 * a + x, 105 * b + y), (178 * a + x, 102 * b + y), (187 * a + x, 100 * b + y), (194 * a + x, 100 * b + y), (203 * a + x, 102 * b + y), (210 * a + x, 105 * b + y), (220 * a + x, 110 * b + y), (228 * a + x, 117 * b + y), (234 * a + x, 123 * b + y), (245 * a + x, 139 * b + y)]) # Далее ствол graph.polygon([(254 * a + x, 53 * b + y), (269 * a + x, 4 * b + y), (275 * a + x, 7 * b + y), (260 * a + x, 56 * b + y)]) graph.polygon([(244 * a + x, 94 * b + y), (256 * a + x, 60 * b + y), (266 * a + x, 64 * b + y), (254 * a + x, 98 * b + y)]) graph.rectangle(247 * a + x, 105 * b + y, 263 * a + x, 165 * b + y) graph.rectangle(247 * a + x, 225 * b + y, 263 * a + x, 173 * b + y) # Далее листья накл. вправо ellipse1(0, -3 * b, a, b, x, y) ellipse1(11 * a, -2 * b, a, b, x, y) ellipse1(21 * a, 0, a, b, x, y) ellipse1(33 * a, 5 * b, a, b, x, y) ellipse1(51 * a, 11 * b, a, b, x, y) ellipse1(50 * a, 71 * b, a, b, x, y) ellipse1(65 * a, 71 * b, a, b, x, y) ellipse1(81 * a, 78 * b, a, b, x, y) # Далее листья накл. влево ellipse2(0, 0, a, b, x, y) ellipse2(15 * a, -10 * b, a, b, x, y) ellipse2(24 * a, -13 * b, a, b, x, y) ellipse2(34 * a, -15 * b, a, b, x, y) ellipse2(44 * a, -16 * b, a, b, x, y) ellipse2(1 * a, 56 * b, a, b, x, y) ellipse2(-13 * a, 56 * b, a, b, x, y) ellipse2(-26 * a, 64 * b, a, b, x, y)
def draw_an_umbrella(umbrella_base_x, umbrella_base_y, umbrella_stick_length, umbrella_stick_width, umbrella_triangle_base, umbrella_triangle_height): g.penSize(umbrella_stick_width) umbrella_color = '#c56200' g.penColor(umbrella_color) fi = math.pi / 180 * 20 for _ in range(umbrella_stick_length // 2): dx_umbrella = math.sin(fi) * 2 dy = math.cos(fi) * 2 g.line(umbrella_base_x, umbrella_base_y, umbrella_base_x + dx_umbrella, umbrella_base_y - dy) # umbrella_triangle_left_angle_y) umbrella_base_x += dx_umbrella umbrella_base_y -= dy fi += math.pi / 180 * 0.5 umbrella_triangle_right_angle_x = umbrella_base_x + umbrella_triangle_base * math.cos(fi) / 2 umbrella_triangle_left_angle_y = umbrella_base_y - umbrella_triangle_base * math.sin(fi) / 2 umbrella_triangle_left_angle_x = umbrella_base_x - umbrella_triangle_base * math.cos(fi) / 2 umbrella_triangle_right_angle_y = umbrella_base_y + umbrella_triangle_base * math.sin(fi) / 2 umbrella_top_angle_x = umbrella_base_x + umbrella_triangle_height * math.sin(fi) umbrella_top_angle_y = umbrella_base_y - umbrella_triangle_height * math.cos(fi) g.penSize(pen_width_1) g.penColor('black') g.brushColor('#f66347') g.polygon([(umbrella_triangle_left_angle_x, umbrella_triangle_left_angle_y), (umbrella_triangle_right_angle_x, umbrella_triangle_right_angle_y), (umbrella_top_angle_x, umbrella_top_angle_y)]) number_of_needle = 6 needle_base_point_x = umbrella_triangle_left_angle_x needle_base_point_y = umbrella_triangle_left_angle_y step_needle_x = umbrella_triangle_base / 7 * math.cos(fi) step_needle_y = umbrella_triangle_base / 7 * math.sin(fi) for _ in range(number_of_needle): needle_base_point_x += step_needle_x needle_base_point_y += step_needle_y g.line(umbrella_top_angle_x, umbrella_top_angle_y, needle_base_point_x, needle_base_point_y)
def cat_body(x0, y0, size, direction, color): """Drawing body, tail and paws of the cat. (x0, y0) - body center, size - radius of the body, direction - side of the tail (1 - right, -1 - left), color - color of the body as string (brown or grey)""" graph.penColor(0, 0, 0) graph.penSize(0.05) if color == 'brown': graph.brushColor(200, 115, 55) else: graph.brushColor(110, 95, 85) oval(x0 + direction * 1.2 * size, y0 + size / 6, size * 2 / 3, 5, direction * pi / 6) oval(x0, y0, size, 2, 0) oval(x0 + direction * 0.8 * size, y0 + size / 4, size / 4, 1, 0) oval(x0 - direction * 0.8 * size, y0 + size / 3, size / 4, 2, 0) oval(x0 + direction * (0.8 * size + size / 5), y0 + size / 4 + size / 3, size / 4, 3, pi / 2)
def home(center_x, center_y, side_length): # side graph.penSize(1) graph.penColor("black") graph.brushColor("peru") graph.rectangle(center_x - side_length / 2, center_y + side_length / 2, center_x + side_length / 2, center_y - side_length / 2) # window graph.penColor("red") graph.brushColor("aqua") graph.rectangle(center_x - side_length / 8, center_y + side_length / 8, center_x + side_length / 8, center_y - side_length / 8) # roof graph.penColor("black") graph.brushColor("red") graph.polygon([(center_x + side_length / 2, center_y - side_length / 2), (center_x - side_length / 2, center_y - side_length / 2), (center_x, center_y - side_length), (center_x + side_length / 2, center_y - side_length / 2)])
def apple(x, y, size, mirror): """ apple function draws the apple of the radius r pxls for size = 1 there are 3 components: 1) main body 2) root, represented by a line 3) leaf, which is obviously a sqrt curve The coords of root and leaf are given regarding to r of an main body, so all "strange" numbers in the further functions are also just a calibrate number for beauty's purposes (._.) mirror is for drawing mirrored images """ # apple body penColor(245, 84, 84) penSize(0) brushColor(245, 84, 84) circle(x, y, 25 * size) # root penColor("black") penSize(2 * size) line(x, y - size * 20, x + size * 12.5 * mirror, y - size * 42.5) # leaf brushColor(100, 225, 100) penSize(size) polygon(curve(x + size * 2.5 * mirror, y - size * 27.5, size, mirror))
def cat(x0, y0, size): """Body""" graph.brushColor("#C87137") ellipse(x0, y0, 250 * size, 115 * size, 0, size) """Head""" graph.brushColor("#C87137") ellipse(x0 - 230 * size, y0 - 20 * size, 80, 80, 0, size) """Nose""" graph.polygon([(x0 - 220 * size, y0 + 10 * size), (x0 - 240 * size, y0 + 10 * size), (x0 - 230 * size, y0 + 20 * size)]) graph.penSize(2) graph.penColor("black") graph.line(x0 - 230 * size, y0 + 20 * size, x0 - 230 * size, y0 + 40 * size) graph.polyline( [(x0 - 230 * size, y0 + 40 * size), (x0 - 229 * size, y0 + 41 * size), (x0 - 229 * size, y0 + 42 * size), (x0 - 228 * size, y0 + 41 * size), (x0 - 227 * size, y0 + 42 * size), (x0 - 220 * size, y0 + 42 * size), (x0 - 217 * size, y0 + 40 * size), (x0 - 214 * size, y0 + 37 * size), (x0 - 214 * size, y0 + 33 * size)]) graph.polyline( [(x0 - 230 * size, y0 + 40 * size), (x0 - 231 * size, y0 + 41 * size), (x0 - 231 * size, y0 + 42 * size), (x0 - 232 * size, y0 + 41 * size), (x0 - 233 * size, y0 + 42 * size), (x0 - 240 * size, y0 + 42 * size), (x0 - 243 * size, y0 + 40 * size), (x0 - 246 * size, y0 + 37 * size), (x0 - 246 * size, y0 + 33 * size)])
def yacht(x, y, s): # Enter x, y - mast base coordinates, s - size (1>2>...). mast = 230 / s w = 60 / s bow = 100 / s col = 5 / s # col is the mast column width. # Draws mast. penSize(w / 5) penColor('black') moveTo(x, y) # Draws sail. penColor('white') brushColor(230, 230, 250) polygon([(x + col, y - mast), (x + col + bow, y - mast / 2), (x + col + bow / 4, y - mast / 2)]) polygon([(x + col, y), (x + col + bow, y - mast / 2), (x + col + bow / 4, y - mast / 2)]) # Draws boat. brushColor(170, 102, 0) penColor(170, 102, 0) rectangle(x - mast / 2, y, x + mast / 2, y + w) polygon([(x + mast / 2, y), (x + mast / 2 + bow, y), (x + mast / 2, y + w)]) for i in range(100): phi1 = i * pi / 200 phi2 = (i + 1) * pi / 200 polygon([(x - mast / 2 - w * cos(phi1), y + w * sin(phi1)), (x - mast / 2 - w * cos(phi2), y + w * sin(phi2)), (x - mast / 2, y)]) # Drwas window. penSize(0) brushColor('black') circle(x + mast / 2 + bow / 4, y + w / 3, w / 4) brushColor('white') circle(x + mast / 2 + bow / 4, y + w / 3, w / 6)
def draw_an_umbrella(umbrella_base_x, umbrella_base_y, umbrella_stick_length, umbrella_stick_width, umbrella_triangle_base, umbrella_triangle_height): umbrella_triangle_left_angle_x = umbrella_base_x - umbrella_triangle_base / 2 umbrella_triangle_left_angle_y = umbrella_base_y - umbrella_stick_length umbrella_triangle_right_angle_x = umbrella_triangle_left_angle_x + umbrella_triangle_base umbrella_triangle_right_angle_y = umbrella_triangle_left_angle_y umbrella_top_angle_x = umbrella_base_x umbrella_top_angle_y = umbrella_triangle_left_angle_y - umbrella_triangle_height g.penSize(umbrella_stick_width) umbrella_color = '#c56200' g.penColor(umbrella_color) g.line(umbrella_base_x, umbrella_base_y, umbrella_base_x, umbrella_triangle_left_angle_y) g.penSize(pen_width_1) g.penColor('black') g.brushColor('#f66347') g.polygon([ (umbrella_triangle_left_angle_x, umbrella_triangle_left_angle_y), (umbrella_triangle_right_angle_x, umbrella_triangle_right_angle_y), (umbrella_top_angle_x, umbrella_top_angle_y) ]) number_of_needle = 6 needle_base_point_x = umbrella_triangle_left_angle_x step_needle = umbrella_triangle_base / 7 for i in range(number_of_needle): needle_base_point_x += step_needle g.line(umbrella_top_angle_x, umbrella_top_angle_y, needle_base_point_x, umbrella_triangle_left_angle_y)