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 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 heart(a, b): line(a, b, a - 20, b - 80) penColor(255, 0, 0) brushColor(255, 0, 0) polygon([(a - 20, b - 80), (a - 7, b - 140), (a - 62, b - 120), (a - 20, b - 80)]) circle(a - 25, b - 135, 18) circle(a - 47, b - 128, 18)
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 head(x_coord, r, g, b, hair_color): brushColor(233, 200, 176) penColor(200, 200, 200) circle(x_coord, 384, 200) penColor(0, 0, 0) eyes(r, g, b, x_coord) nose_and_mouth(x_coord) hair(hair_color, x_coord)
def sun(x, y, r): """ Рисует Солнце. (x, y) -- координаты центра окружности Солнца; r -- радиус Солнца. """ graph.brushColor("yellow") graph.penSize(0) graph.circle(x, y, r)
def left_arm(length, angle, x_coord): brushColor(233, 200, 176) penColor(200, 200, 200) polygon([(x_coord - 233, 569), (x_coord - 193, 549), (x_coord - 193 - length * cos(angle), 549 + length * sin(angle)), (x_coord - 233 - length * cos(angle), 569 + length * sin(angle))]) penColor('white') circle( (2 * x_coord - length * cos(angle) - 233 - length * cos(angle) - 193) / 2, (549 + length * sin(angle) + 569 + length * sin(angle)) / 2, 40)
def right_arm(length, angle, x_coord): brushColor(233, 200, 176) penColor(200, 200, 200) polygon([(x_coord + 167, 549), (x_coord + 207, 569), (x_coord + 207 + length * cos(angle), 569 - length * sin(angle)), (x_coord + 167 + length * cos(angle), 549 - length * sin(angle))]) penColor('white') circle( (2 * x_coord + length * cos(angle) + 207 + length * cos(angle) + 167) / 2, (569 - length * sin(angle) + 549 - length * sin(angle)) / 2, 40)
def clouds(x, y, s): # s - size's cloud b_c = 21 * s # between_clouds r_c = 30 * s # radius of cloud graph.brushColor('#ffffff') graph.circle(x, y, r_c) graph.circle(x + b_c, y + b_c, r_c) graph.circle(x + 2 * b_c, y, r_c) graph.circle(x + 3 * b_c, y + b_c, r_c) graph.circle(x + 4 * b_c, y, r_c)
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 main_body(color, x_coord): penColor(color) brushColor(color) circle(x_coord, 769, 300) penColor('black') brushColor(color) # shoulders polygon([(x_coord - 163, 629), (x_coord - 243, 629), (x_coord - 253, 539), (x_coord - 183, 489), (x_coord - 143, 549)]) polygon([(x_coord + 237, 629), (x_coord + 157, 629), (x_coord + 147, 539), (x_coord + 217, 489), (x_coord + 257, 549)])
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 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 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 sheep(x, y, n): coordintes = [] for i in range(20): coordintes.append([-i * mod / 20, 1 - (i / 20)**2]) coordintes.append([3 * mod, 0]) for i in range(20): coordintes.append([(3 - i / 20) * mod, (i / 20)**2]) for i in range(len(coordintes)): coordintes[i] = [n * coordintes[i][0] + x, n * coordintes[i][1] + y] brushColor('red') penColor('black') rectangle(mod * n * (3 / 4) + x, y, mod * n + x, y - (2 / 2) * n) brushColor('light grey') rectangle(x, +n / 2 + y, x + n * mod, y - n * (1 / 2)) polygon(coordintes) brushColor('grey') circle(x + mod * n / 4, y - 0.25 * n, n // 6) brushColor("light grey") penColor("light grey") circle(x + (n + n // 7) * mod, y - 1.5 * n, n // 8) circle(x + (n + n // 2) * mod, y - 2.0 * n, n // 7) circle(x + mod * 2.2 * n, y - 2.5 * n, n // 6)
def eyes(color_red, color_green, color_blue, x_coord): brushColor(color_red, color_green, color_blue) penColor('black') circle(x_coord + 65, 349, 35) circle(x_coord - 65, 349, 35) brushColor('black') circle(x_coord + 65, 349, 10) circle(x_coord - 65, 349, 10)
def man(a, b): penColor(133, 133, 133) brushColor(133, 133, 133) ellipse(50, 95, a, b + 120) penColor(229, 194, 152) brushColor(229, 194, 152) circle(a, b, 45) penColor(0, 0, 0) # отрисовывает руки : первая строка - правую, а вторая строка - левую; line(a + 40, b + 60, a + 80, b + 140) line(a - 40, b + 60, a - 90, b + 140) # отрисовывает ноги : первые две строки - правую, а вторые две строки - левую; line(a + 25, b + 200, a + 45, b + 330) line(a + 45, b + 330, a + 65, b + 330) line(a - 25, b + 200, a - 65, b + 330) line(a - 65, b + 330, a - 100, b + 330)
def woman(a, b): penColor(233, 99, 233) brushColor(233, 99, 233) polygon([(a, b + 30), (a + 75, b + 220), (a - 75, b + 220), (a, b + 30)]) penColor(229, 194, 152) brushColor(229, 194, 152) circle(a, b, 45) penColor(0, 0, 0) # отрисовывает ноги : первые две строки - правую, а вторые две строки - левую; line(a + 20, b + 220, a + 20, b + 330) line(a + 20, b + 330, a + 40, b + 330) line(a - 20, b + 220, a - 20, b + 330) line(a - 20, b + 330, a - 40, b + 330) # отрисовывает руки : первая строка - правую, а вторая строка - левую; line(a + 12, b + 60, a + 50, b + 100) line(a + 50, b + 100, a + 120, b + 65) line(a - 12, b + 60, a - 82, b + 140)
def updatemouth(): global dm, mouth x, y = g.center(mouth) g.deleteObject(mouth) mouth = g.circle(x, y, dm + 1) dm += 1 if dm > 10: dm = 4 return
def carcass(x, y, deck_lenght, carcass_height): """ Рисует корпус корабля. (x, y) -- координаты правой верхней точки прямоугольника-палубы. deck_lenght, carcass_height -- длина прямоугольника-палубы и высота корпуса. """ graph.brushColor(139, 69, 19) graph.penSize(0) graph.rectangle(x, y, x + deck_lenght, y + carcass_height) graph.brushColor(139, 69, 19) graph.penSize(0) graph.polygon([(x + deck_lenght, y), (x + deck_lenght, y + carcass_height), (x + 1.5*deck_lenght, y), (x + deck_lenght, y)]) graph.brushColor(139, 69, 19) graph.penSize(0) graph.arc(x + carcass_height, y - carcass_height, x - carcass_height, y + carcass_height, -180, -90) graph.brushColor('black') graph.circle(x + 1.1*deck_lenght, y + 0.4*carcass_height, carcass_height/4.5) graph.brushColor('white') graph.circle(x + 1.1 * deck_lenght, y + 0.4 * carcass_height, carcass_height / 6.5)
def ellipse_sr(x1: int, y1: int, x2: int, y2: int, scale: float, reflect: bool): """Draw a scaled and reflected instance of an ellipse""" base = circle(0, 0, 10) if not reflect: changeCoords(base, [(x1 * scale, y1 * scale), (x2 * scale, y2 * scale)]) else: changeCoords(base, [(400 - x1 * scale, y1 * scale), (400 - x2 * scale, y2 * scale)]) return base
def grabla(x1, y1, x2, y2): n = 5 a = int(((x2 - x1)**2)**0.5 // (x2 - x1)) penSize(15) colour = random.randint(-1, 1) penColor(112 + colour // 3, 66, 65) brushColor(112 + colour // 3, 66, 65) penSize(1) for i in range(x1, x2, a): n += random.random() * ((-1)**i) if n > 9: n -= 1 elif n < 3: n += 1 yy1 = (y2 - y1) * (i - x1) / (x2 - x1) + y1 colour += random.randint(-5, 4) penColor(112 + colour, 66, 65) brushColor(112 + colour, 66, 65) circle(i, yy1, n) tan = (yy1 - y1) / (x2 - x1) alpha = 3.14 / 2 + math.atan(tan) bx = int(50 * math.sin(alpha)) by = int(50 * math.cos(alpha)) penSize(10) penColor(53, 50, 51) line(x2 + bx, yy1 + by, x2 - bx, yy1 - by) for i in range(x2 - bx, x2 + bx, 7): penSize(3) y = yy1 + by + by * (i - x2 - bx) / bx penSize(5) penColor(53, 50, 51) line(i, y, i, y - 18) penSize(2) penColor(66, 63, 64) line(i - 2, y, i - 2, y - 17)
def sheep(x, y, n, mod): # making at first a left directed(mod = 1) # or right directed(mod = -1) ship in [0, 3] coordinates # and only after everything making it n-size and at x,y ship_form_coordinates = [] # making the nose of the sheep # but the translator says crazy englishmen call it just a bow for i in range(20): ship_form_coordinates.append([-i * mod / 20, 1 - (i / 20)**2]) # making sure that despite rounding of squares # the bow will be higher than the back of the ship ship_form_coordinates.append([(-1) * mod, -0.05]) # the back of the ship for i in range(20): ship_form_coordinates.append([(3 - i / 20) * mod, (i / 20)**2]) # n-size for i in range(len(ship_form_coordinates)): ship_form_coordinates[i] = [ n * ship_form_coordinates[i][0] + x, n * ship_form_coordinates[i][1] + y ] # the pipe brushColor('red') penColor('black') rectangle(mod * n * (3 / 4) + x, y, mod * n + x, y - (2 / 2) * n) # basic form of the ship brushColor('light grey') rectangle(x, +n / 2 + y, x + n * mod, y - n * (1 / 2)) polygon(ship_form_coordinates) # the window of the ship brushColor('grey') circle(x + mod * n / 4, y - 0.25 * n, n // 7) # steam or smoke or how do u wanna call it brushColor("light grey") penColor("light grey") circle(x + (n + n // 7) * mod, y - 1.5 * n, n // 8) circle(x + (n + n // 2) * mod, y - 2.0 * n, n // 7) circle(x + mod * 2.2 * n, y - 2.5 * n, n // 6)
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 ship(x, y, s): a = [] r = 1 / 30 * d * s h_m = 0.005 * d * s a.append( c.create_arc(x - r, y - r, x + r, y + r, start=180, extent=90, fill='#ba5005')) graph.penColor('#000000') graph.brushColor('#ba5005') a.append(graph.rectangle(x, y, x + 4 * r, y + r)) a.append( graph.polygon([(x + 4 * r, y), (x + 6 * r, y), (x + 4 * r, y + r), (x + 4 * r, y)])) graph.brushColor('#000000') a.append(graph.rectangle(x + 1.5 * r, y, x + 1.5 * r + h_m, y - 3 * r)) graph.brushColor('#ded599') a.append( graph.polygon([(x + 1.5 * r + h_m, y - 3 * r), (x + 2 * r + h_m, y - 1.5 * r), (x + 3 * r + h_m, y - 1.5 * r), (x + 1.5 * r + h_m, y - 3 * r)])) a.append( graph.polygon([(x + 1.5 * r + h_m, y), (x + 2 * r + h_m, y - 1.5 * r), (x + 3 * r + h_m, y - 1.5 * r), (x + 1.5 * r + h_m, y)])) graph.brushColor('#000000') a.append(graph.circle(x + 13 / 3 * r, y + 1 / 3 * r, 1 / 4 * r)) graph.brushColor('#ffffff') a.append(graph.circle(x + 13 / 3 * r, y + 1 / 3 * r, 1 / 5 * r)) return a
def cat_head(x0, y0, size, direction, color): """Drawing cat head with eyes and nose - all variables sam as for body.""" x1 = x0 - direction * size y1 = y0 head_size = size / 3 oval(x1 - direction * head_size * sin(pi / 4), y1 + head_size * cos(pi / 4) / 1.5, size / 4, 3, pi / 2) graph.circle(x1, y1, head_size) if color == 'brown': graph.brushColor(135, 170, 0) else: graph.brushColor(40, 215, 255) graph.circle(x1 - head_size / 2, y1, head_size / 4) graph.circle(x1 + head_size / 2, y1, head_size / 4) graph.brushColor(0, 0, 0) oval(x1 - head_size / 2 + head_size / 10, y1, head_size / 4 - head_size / 30, 4, pi / 2) oval(x1 + head_size / 2 + head_size / 10, y1, head_size / 4 - head_size / 30, 4, pi / 2) graph.penColor(250, 250, 250) graph.brushColor(250, 250, 250) oval(x1 - head_size / 2 - head_size / 14, y1 - head_size / 12, head_size / 4 - head_size / 9, 4, pi / 4) oval(x1 + head_size / 2 - head_size / 14, y1 - head_size / 12, head_size / 4 - head_size / 9, 4, pi / 4) graph.penColor(0, 0, 0) graph.brushColor(225, 170, 135) nose = [(x1 + head_size / 15, y1 + head_size / 3), (x1 - head_size / 15, y1 + head_size / 3), (x1, y1 + head_size / 3 + head_size / 10)] graph.polygon(nose) graph.line(x1, y1 + head_size / 3 + head_size / 10, x1, y1 + head_size / 2) sector(x1 - head_size / 8, y1 + head_size / 2, head_size / 8, 0, pi / 2 + pi / 6, 1) sector(x1 + head_size / 8, y1 + head_size / 2, head_size / 8, pi / 2 - pi / 6, pi, 1) cat_ears(x1, y1, head_size, color) cat_mustache(x1, y1, head_size)
def clew(x0, y0, radius, direction): """Drawing clue with center in (x0, y0), correspondent radius and direction (1 - right, -1 - left).""" if direction == 1: graph.penColor(0, 0, 0) graph.penSize(0.05) graph.brushColor(155, 155, 155) graph.circle(x0, y0, radius) indent = radius / 10 sector(x0 - radius / 5, y0 + radius / 5, radius, (3 / 2) * pi, 2 * pi, 1) sector(x0 - radius / 5 - indent, y0 + radius / 5 + indent, radius, (3 / 2) * pi, 2 * pi, 1) sector(x0 - radius / 5 - 2.5 * indent, y0 + radius / 5 + 2.5 * indent, radius, (3 / 2) * pi, 2 * pi, 1) sector(x0 + radius / 4, y0 + radius / 2, radius, pi, (3 / 2) * pi - pi / 6, 1) sector(x0 + radius / 4 + 2 * indent, y0 + radius / 2 + 2 * indent, radius, pi, (3 / 2) * pi - pi / 6, 1) sector(x0 + radius / 4 + 4 * indent, y0 + radius / 2 + 4 * indent, radius, pi + pi / 10, (3 / 2) * pi - pi / 6, 1) graph.penColor(140, 120, 70) smr = radius / 2 x1 = x0 - radius * sin(pi / 4) - smr * sin(pi / 4) y1 = y0 + radius * sin(pi / 4) - smr * sin(pi / 4) sector(x1, y1, smr, pi / 3, pi, 2) sector(x1 - 2 * smr, y1, smr, pi, 2 * pi, 2) sector(x1 - 2 * smr - (3 / 2) * smr, y1, smr / 2, 0, pi, 2) elif direction == -1: graph.penColor(0, 0, 0) graph.penSize(0.05) graph.brushColor(155, 155, 155) graph.circle(x0, y0, radius) indent = radius / 10 sector(x0 - direction * radius / 5, y0 + radius / 5, radius, pi, (3 / 2) * pi, 1) sector( x0 - direction * (radius / 5 + indent), y0 + radius / 5 + indent, radius, pi, (3 / 2) * pi, 1, ) sector( x0 - direction * (radius / 5 + 2.5 * indent), y0 + radius / 5 + 2.5 * indent, radius, pi, (3 / 2) * pi, 1, ) sector(x0 + direction * radius / 4, y0 + radius / 2, radius, (3 / 2) * pi + pi / 6, 2 * pi, 1) sector(x0 + direction * (radius / 4 + 2 * indent), y0 + radius / 2 + 2 * indent, radius, (3 / 2) * pi + pi / 6, 2 * pi, 1) sector(x0 + direction * (radius / 4 + 4 * indent), y0 + radius / 2 + 4 * indent, radius, (3 / 2) * pi + pi / 6, 2 * pi - pi / 10, 1) graph.penColor(140, 120, 70) smr = radius / 2 x1 = x0 - direction * (radius * sin(pi / 4) + smr * sin(pi / 4)) y1 = y0 + radius * sin(pi / 4) - smr * sin(pi / 4) sector(x1, y1, smr, 0, pi - pi / 3, 2) sector(x1 - direction * 2 * smr, y1, smr, pi, 2 * pi, 2) sector(x1 - direction * (2 * smr + (3 / 2) * smr), y1, smr / 2, 0, pi, 2)
def draw_a_ship(ship_bow_x, ship_size): ship_bow_y = sea_upper_left_point_y + ship_size * ( 225 - sea_upper_left_point_y) #221 ship_keel_x = ship_bow_x - ship_size * 65 ship_keel_y = ship_bow_y + ship_size * 28 ship_stern_top_x = ship_bow_x - ship_size * 209 ship_stern_top_y = ship_bow_y ship_stern_bottom_x = ship_stern_top_x ship_stern_bottom_y = ship_keel_y ship_color = '#df6f0d' g.penColor(ship_color) g.brushColor(ship_color) g.polygon([(ship_bow_x, ship_bow_y), (ship_keel_x, ship_keel_y), (ship_stern_bottom_x, ship_stern_bottom_y), (ship_stern_top_x, ship_stern_top_y)]) ship_stern_radius = ship_stern_bottom_y - ship_stern_top_y g.circle(ship_stern_top_x, ship_stern_top_y, ship_stern_radius) fill_1_top_left_point_x = ship_stern_top_x - ship_stern_radius fill_1_top_left_point_y = sea_upper_left_point_y fill_1_bottom_right_point_x = ship_stern_top_x + ship_stern_radius fill_1_bottom_right_point_y = ship_stern_top_y - 1 g.penColor(sea_color) g.brushColor(sea_color) g.rectangle(fill_1_top_left_point_x, fill_1_top_left_point_y, fill_1_bottom_right_point_x, fill_1_bottom_right_point_y) fill_2_top_left_point_x = ship_stern_top_x - ship_stern_radius fill_2_top_left_point_y = ship_stern_top_y - ship_stern_radius fill_2_bottom_right_point_x = ship_stern_top_x + ship_stern_radius fill_2_bottom_right_point_y = sea_upper_left_point_y - 1 g.penColor(sky_color) g.brushColor(sky_color) g.rectangle(fill_2_top_left_point_x, fill_2_top_left_point_y, fill_2_bottom_right_point_x, fill_2_bottom_right_point_y) g.penColor(sea_color) g.penSize(pen_width_1) g.line(ship_stern_top_x, ship_stern_top_y, ship_stern_bottom_x, ship_stern_bottom_y) g.line(ship_keel_x, ship_bow_y, ship_keel_x, ship_keel_y) ship_porthole_center_x = ship_bow_x - ship_size * 50 ship_porthole_center_y = ship_bow_y + ship_size * 11 ship_porthole_radius = ship_size * 7 porthole_pen_width = ship_size * 3.25 g.penSize(porthole_pen_width) g.penColor('black') portole_color = 'white' g.brushColor(portole_color) g.circle(ship_porthole_center_x, ship_porthole_center_y, ship_porthole_radius) mast_base_x = ship_bow_x - ship_size * 150 mast_base_y = ship_bow_y mast_hight = ship_size * 96 mast_width = ship_size * 6 g.penSize(mast_width) mast_color = 'black' g.penColor(mast_color) g.line(mast_base_x, mast_base_y, mast_base_x, mast_base_y - mast_hight) sail_top_mount_x = mast_base_x sail_top_mount_y = mast_base_y - mast_hight sail_bottom_mount_x = mast_base_x sail_bottom_mount_y = mast_base_y sail_left_edge_x = ship_bow_x - ship_size * 134 sail_left_edge_y = (sail_top_mount_y + sail_bottom_mount_y) / 2 sail_right_edge_x = ship_bow_x - ship_size * 96 sail_right_edge_y = sail_left_edge_y g.penSize(pen_width_1) g.penColor('black') sail_color = '#c9c094' g.brushColor(sail_color) g.polygon([(sail_top_mount_x, sail_top_mount_y), (sail_left_edge_x, sail_left_edge_y), (sail_right_edge_x, sail_right_edge_y)]) g.polygon([(sail_bottom_mount_x, sail_bottom_mount_y), (sail_left_edge_x, sail_left_edge_y), (sail_right_edge_x, sail_right_edge_y)])
def sun(xsun, ysun, rsun): penColor(255, 255, 0) brushColor(255, 255, 0) circle(xsun, ysun, rsun)