def main(): points = [Point(x=230, y=450), Point(x=240, y=460), Point(x=230, y=470), Point(x=240, y=480)] polygon(point_list=points) points2 = [Point(p.x + 20, p.y + 20) for p in points] lines(point_list=points2, color=COLOR_DARK_ORANGE) line(start_point=Point(x=20, y=20), end_point=Point(x=40, y=300)) square(left_bottom=Point(400, 300, ), side=100) rectangle( left_bottom=Point(x=200, y=200), right_top=Point(x=300, y=300), color=COLOR_DARK_GREEN ) rectangle( left_bottom=Point(x=400, y=300), right_top=Point(x=300, y=400), color=COLOR_DARK_GREEN ) sleep(2) clear_screen() vector(start=Point(x=230, y=260), angle=70, length=200, color=COLOR_PURPLE) for i in range(10): point = random_point() color = random_color() radius = random_number(20, 60) circle(center_position=point, radius=radius, color=color, width=0) sleep(2) clear_screen() for i in range(10): point = random_point() color = random_color() dx = random_number(30, 100) dy = random_number(30, 100) right_top = Point(x=point.x + dx, y=point.y + dy) ellipse(left_bottom=point, right_top=right_top, color=color) v3 = Vector(start_point=Point(0, 0), direction=45, length=50) for direction in range(0, 181, 20): v = Vector(start_point=Point(x=300, y=300), direction=direction, length=100) v.draw() v2 = Vector(start_point=v.end_point, direction=direction + 30, length=50) v2.draw(color=COLOR_GREEN) v2.add(v3) v2.draw(color=COLOR_ORANGE) snowflake(center=Point(), length=60, factor_b=0.2, factor_c=100) sleep(2) for k in range(2): y = 500 for i in range(10): clear_screen() y -= 30 for x in [100, 200, 300, 400, 500]: radius = random_number(30, 50) point = Point(x=x, y=y) snowflake(center=point, length=radius) mouse_point, mouse_buttons = get_mouse_state() print("mouse_state is {} + {}".format(mouse_point, mouse_buttons)) if user_want_exit(sleep_time=0.1): break if user_want_exit(0): break
def draw_smile(x, y, color): sd.ellipse(sd.get_point(y - 50, x - 50), sd.get_point(y + 50, x + 20), color, 2) sd.line(sd.get_point(y - 10, x - 30), sd.get_point(y + 10, x - 30), color, 2) sd.line(sd.get_point(y - 10, x - 30), sd.get_point(y - 20, x - 20), color, 2) sd.line(sd.get_point(y + 20, x - 20), sd.get_point(y + 10, x - 30), color, 2) sd.circle(sd.get_point(y + 15, x), 7, color, 1) sd.circle(sd.get_point(y - 15, x), 7, color, 1)
def draw_smile(x, y, color): point_left = sd.get_point(x - 120, y - 100) point_right = sd.get_point(x, y) sd.ellipse(point_left, point_right, color) circle_point = sd.get_point(x - 35, y - 35) sd.circle(circle_point, 8, sd.invert_color(color)) circle_point = sd.get_point(x - 85, y - 35) sd.circle(circle_point, 8, sd.invert_color(color)) points = [ sd.get_point(x - 85, y - 65), sd.get_point(x - 80, y - 70), sd.get_point(x - 75, y - 72), sd.get_point(x - 65, y - 74), sd.get_point(x - 61, y - 74), sd.get_point(x - 57, y - 74), sd.get_point(x - 47, y - 72), sd.get_point(x - 42, y - 70), sd.get_point(x - 37, y - 65), sd.get_point(x - 42, y - 75), sd.get_point(x - 47, y - 79), sd.get_point(x - 50, y - 81), sd.get_point(x - 57, y - 82), sd.get_point(x - 61, y - 82), sd.get_point(x - 65, y - 82), sd.get_point(x - 72, y - 80), sd.get_point(x - 75, y - 78), sd.get_point(x - 80, y - 75), sd.get_point(x - 85, y - 65), ] sd.lines(points, sd.invert_color(color))
def leaves_fall(x_coordinates, y_coordinates, endpoint_of_laves_fall): sd.start_drawing() for index, x in enumerate(x_coordinates): if y_coordinates[index] > endpoint_of_laves_fall: # Назначаю рандомное значение падения и отклонения на каждом шагу random_step_x = sd.random_number(-30, 30) random_step_y = sd.random_number(5, 15) # Создаю точку и рисую снежинку цветом фона left_bottom_point = sd.get_point(x_coordinates[index], y_coordinates[index]) right_top_point = sd.get_point(x_coordinates[index] + 3, y_coordinates[index] + 3) sd.ellipse(left_bottom=left_bottom_point, right_top=right_top_point, color=sd.background_color) # Изменяю координаты x_coordinates[index] += random_step_x y_coordinates[index] -= random_step_y # Создаю точку и рисую лист left_bottom_point = sd.get_point(x_coordinates[index], y_coordinates[index]) right_top_point = sd.get_point(x_coordinates[index] + 3, y_coordinates[index] + 3) sd.ellipse(left_bottom=left_bottom_point, right_top=right_top_point, color=sd.COLOR_DARK_RED) sd.finish_drawing()
def smile(x, y, color): radius = 30 _point = sd.get_point(x=x, y=y) sd.circle(center_position=_point, radius=radius, width=3, color=sd.COLOR_BLACK) sd.circle(center_position=_point, radius=radius - 2, width=0, color=color) left_point = sd.get_point(x=x - radius // 3, y=y + radius // 3) right_point = sd.get_point(x=x - radius // 5, y=y + 2 * radius // 3) sd.ellipse(left_bottom=left_point, right_top=right_point, color=sd.COLOR_BLACK) left_point = sd.get_point(x=x + radius // 5, y=y + radius // 3) right_point = sd.get_point(x=x + radius // 3, y=y + 2 * radius // 3) sd.ellipse(left_bottom=left_point, right_top=right_point, color=sd.COLOR_BLACK) mouth = [ sd.Point(x=x - radius // 2, y=y - radius // 3), sd.Point(x=x - radius // 4, y=y - radius // 2), sd.Point(x=x + radius // 4, y=y - radius // 2), sd.Point(x=x + radius // 2, y=y - radius // 3), ] sd.lines(point_list=mouth, width=3, color=sd.COLOR_BLACK)
def smile(coordinate_x, coordinate_y, color): sd.circle(center_position=point, radius=radius, color=color, width=2) sd.ellipse(left_bottom=coordinate_x, right_top=coordinate_y, color=color, width=0) sd.ellipse(left_bottom=x, right_top=y, color=color, width=0) sd.line(start_point=q, end_point=w, color=color, width=1)
def sun(x, y, blink=True, galo_count=0): sd.circle(sd.get_point(x, y), radius=50, color=sd.COLOR_YELLOW, width=0) face_color = sd.COLOR_RED if blink: sd.line(start_point=sd.get_point(x + 4, y + 12), end_point=sd.get_point(x + 24, y + 12), color=face_color, width=2) sd.line(start_point=sd.get_point(x - 23, y + 12), end_point=sd.get_point(x - 3, y + 12), color=face_color, width=2) else: sd.ellipse(left_bottom=sd.get_point(x + 4, y + 6), right_top=sd.get_point(x + 24, y + 18), color=face_color, width=2) sd.ellipse(left_bottom=sd.get_point(x - 23, y + 6), right_top=sd.get_point(x - 3, y + 18), color=face_color, width=2) sd.circle(sd.get_point(x + 13, y + 12), radius=2, color=face_color) sd.circle(sd.get_point(x - 13, y + 12), radius=2, color=face_color) sd.line(start_point=sd.get_point(x, y - 12), end_point=sd.get_point(x, y + 8), color=face_color, width=3) sd.line(start_point=sd.get_point(x - 4, y - 12), end_point=sd.get_point(x + 5, y - 12), color=face_color, width=3) sd.line(start_point=sd.get_point(x - 10, y - 23), end_point=sd.get_point(x + 11, y - 23), color=face_color, width=3) sd.line(start_point=sd.get_point(x + 11, y - 23), end_point=sd.get_point(x + 16, y - 18), color=face_color, width=3) sd.line(start_point=sd.get_point(x - 10, y - 23), end_point=sd.get_point(x - 15, y - 18), color=face_color, width=3) sd.circle(sd.get_point(x, y), radius=50 + galo_count * 6, color=sd.COLOR_YELLOW, width=2) sd.circle(sd.get_point(x, y), radius=50 + (galo_count - 1) * 6, color=sd.background_color, width=2) if galo_count == 0: sd.circle(sd.get_point(x, y), radius=50 + (galo_count + 9) * 6, color=sd.background_color, width=2)
def smile(x, y, color): mouth_point_list = [sd.get_point(x-25, y), sd.get_point(x-7, y-15), sd.get_point(x+7, y-15), sd.get_point(x+25, y)] left_bottom_point = sd.get_point(x-35, y-30) right_top_point = sd.get_point(x+35, y+30) sd.ellipse(left_bottom=left_bottom_point, right_top=right_top_point, color=color, width=2) sd.lines(point_list=mouth_point_list, color=sd.COLOR_ORANGE, closed=False, width=2) left_eye_point =sd.get_point(x-15, y+5) right_eye_point= sd.get_point(x+15,y+5) sd.circle(center_position=left_eye_point, radius=3, color=sd.COLOR_YELLOW,width=0) sd.circle(center_position=right_eye_point, radius=3, color=sd.COLOR_YELLOW, width=0)
def draw_smile(x, y, color): sd.ellipse(sd.get_point(x - 50, y - 50), sd.get_point(x + 50, y + 20), color, 2) sd.line(sd.get_point(x - 10, y - 30), sd.get_point(x + 10, y - 30), color, 2) sd.line(sd.get_point(x - 10, y - 30), sd.get_point(x - 20, y - 20), color, 2) sd.line(sd.get_point(x + 20, y - 20), sd.get_point(x + 10, y - 30), color, 2) sd.circle(sd.get_point(x + 15, y), 9, color, 1) sd.circle(sd.get_point(x - 15, y), 9, color, 1)
def draw_smile(x, y, col): coor1 = sd.get_point(x, y) coor2 = sd.get_point(x + 150, y + 100) eye1 = sd.get_point(x + 40, y + 60) eye2 = sd.get_point(x + 100, y + 60) mouth_line1 = sd.get_point(x + 40, y + 20) mouth_line2 = sd.get_point(x + 70, y + 15) mouth_line3 = sd.get_point(x + 100, y + 20) sd.ellipse(coor1, coor2, col, 2) sd.circle(eye1, 10, col, 2) sd.circle(eye2, 10, col, 2) sd.line(mouth_line1, mouth_line2, col, 2) sd.line(mouth_line2, mouth_line3, col, 2)
def draw_face(x, y, color): left_point = sd.get_point(x, y) right_point = sd.get_point(x + 150, y + 120) sd.ellipse(left_point, right_point, color, 2) sd.circle(sd.get_point(x + 40, y + 70), 10, color, 2) sd.circle(sd.get_point(x + 110, y + 70), 10, color, 2) points = [ sd.get_point(x + 30, y + 40), sd.get_point(x + 60, y + 30), sd.get_point(x + 90, y + 30), sd.get_point(x + 120, y + 40) ] sd.lines(points, color)
def smile(position_x=300, position_y=300, radius=50, color=sd.COLOR_GREEN): ''' Функция отрисовки смайлика ''' if radius < 10: radius = 10 center = sd.get_point(position_x, position_y) mesh_size = radius//10 right_eye_bottom = sd.get_point( position_x - mesh_size * 5, position_y + mesh_size * 2) right_eye_top = sd.get_point( position_x - mesh_size * 3, position_y + mesh_size * 6) right_eye_center = sd.get_point( position_x - mesh_size * 4, position_y + mesh_size * 4) left_eye_bottom = sd.get_point( position_x + mesh_size * 3, position_y + mesh_size * 2) left_eye_top = sd.get_point( position_x + mesh_size * 5, position_y + mesh_size * 6) left_eye_center = sd.get_point( position_x + mesh_size * 4, position_y + mesh_size * 4) eye_apple_radius = radius // 20 if radius // 20 > 0 else 1 mouth = [ sd.get_point( position_x - mesh_size * 6, position_y - mesh_size * 4), sd.get_point( position_x - mesh_size * 4, position_y - mesh_size * 5), sd.get_point( position_x - mesh_size * 2, position_y - mesh_size * 6), sd.get_point( position_x + mesh_size * 2, position_y - mesh_size * 6), sd.get_point( position_x + mesh_size * 4, position_y - mesh_size * 5), sd.get_point( position_x + mesh_size * 6, position_y - mesh_size * 4), ] sd.circle(center_position=center, radius=radius, color=color) sd.ellipse(left_bottom=right_eye_bottom, right_top=right_eye_top, color=color, width=1) sd.circle(center_position=right_eye_center, radius=eye_apple_radius, color=color, width=0) sd.ellipse(left_bottom=left_eye_bottom, right_top=left_eye_top, color=color, width=1) sd.circle(center_position=left_eye_center, radius=eye_apple_radius, color=color, width=0) sd.lines(point_list=mouth, color=color, closed=True)
def smile(x, y, color): radius = 50 point = sd.get_point(x=x, y=y) sd.circle(center_position=point, radius=radius, width=3, color=sd.COLOR_BLACK) sd.circle(center_position=point, radius=radius-2, width=0, color=color) left_point = sd.get_point(x=x - radius // 3, y=y + radius // 3) right_point = sd.get_point(x=x - radius // 5, y=y + 2 * radius // 3) sd.ellipse(left_bottom=left_point, right_top=right_point, color=sd.COLOR_BLACK) left_point = sd.get_point(x=x + radius // 5, y=y + radius // 3) right_point = sd.get_point(x=x + radius // 3, y=y + 2 * radius // 3) sd.ellipse(left_bottom=left_point, right_top=right_point, color=sd.COLOR_BLACK) left_point = sd.get_point(x=x - radius // 2, y=y - radius // 3) right_point = sd.get_point(x=x + radius // 2, y=y - radius // 3) sd.line(start_point=left_point, end_point=right_point, width=3, color=sd.COLOR_BLACK)
def smile(cord_x, cord_y, color): point_x = sd.get_point(cord_x + 10, cord_y + 50) point_y = sd.get_point(cord_x + 150, cord_y + 150) sd.ellipse(left_bottom=point_x, right_top=point_y, color=color, width=2) for x in range(55, 110, 50): point = sd.get_point(cord_x + x, cord_y + 125) sd.circle(center_position=point, radius=6, color=color, width=1) x = sd.get_point(cord_x + 40, cord_y + 85) y = sd.get_point(cord_x + 60, cord_y + 70) z = sd.get_point(cord_x + 100, cord_y + 70) z_1 = sd.get_point(cord_x + 120, cord_y + 85) point_list = (x, y, z, z_1) sd.lines(point_list=point_list, color=color, closed=False, width=3)
def smile(x, y, color): point1 = sd.get_point(x=x, y=y) point2 = sd.get_point(x=x + 100, y=y + 70) sd.ellipse(point1, point2, width=0, color=sd.COLOR_YELLOW) point3 = sd.get_point(x=x + 33, y=y + 45) sd.circle(point3, radius=5, color=color) point4 = sd.get_point(x=x + 66, y=y + 45) sd.circle(point4, radius=5, color=color) p5 = sd.get_point(x + 40, y + 20) p6 = sd.get_point(x + 60, y + 20) sd.line(p5, p6, color=color) p7 = sd.get_point(x + 20, y + 30) sd.line(p7, p5, color=color) p8 = sd.get_point(x + 80, y + 30) sd.line(p6, p8, color=color)
def smile(x, y, color): point = sd.get_point(x, y) coord_1_eye = sd.get_point(x - 30, y) coord_2_eye = sd.get_point(x - 10, y + 20) coord_3_eye = sd.get_point(x + 10, y) coord_4_eye = sd.get_point(x + 30, y + 20) face = sd.circle(point, color=color, width=4) eye1 = sd.ellipse(coord_1_eye, coord_2_eye, color=color) eye2 = sd.ellipse(coord_3_eye, coord_4_eye, color=color) s1 = sd.get_point(x - 25, y - 20) s2 = sd.get_point(x - 10, y - 35) s3 = sd.get_point(x + 10, y - 35) s4 = sd.get_point(x + 25, y - 20) smile_list = [s1, s2, s3, s4] sd.lines(point_list=smile_list, width=4, color=color)
def smile(x=sd.randint(0, 1200), y=sd.randint(0, 600), color=sd.random_color()): smile_cencer = sd.get_point(x, y) left_bottom = sd.get_point(x - 100, y - 75) right_top = sd.get_point(x + 100, y + 75) sd.ellipse(left_bottom, right_top, width=1, color=color) left_eye_center = sd.get_point(x - 40, y + 25) sd.circle(left_eye_center, 20, color=color) right_eye_center = sd.get_point(x + 40, y + 25) sd.circle(right_eye_center, 25, color=color) point_1 = sd.get_point(x - 50, y - 25) point_2 = sd.get_point(x - 25, y - 35) point_3 = sd.get_point(x + 25, y - 35) point_4 = sd.get_point(x + 50, y - 25) point_list = [point_1, point_2, point_3, point_4] sd.lines(point_list, color=color)
def draw_smile(x, y, color=sd.COLOR_YELLOW): """Draw smile in point (x,y)""" point = sd.get_point(x, y) sd.circle(point, color=color) sd.line(sd.get_point(x-40, y+30), sd.get_point(x-20, y+70)) sd.line(sd.get_point(x - 20, y + 70), sd.get_point(x, y + 50)) sd.line(sd.get_point(x+5, y+50), sd.get_point(x+25, y+70)) sd.line(sd.get_point(x+25, y+70), sd.get_point(x+40, y+30)) sd.ellipse(sd.get_point(x-30, y-30), sd.get_point(x+30, y), width=1) sd.rectangle(sd.get_point(x - 30, y - 15), sd.get_point(x + 30, y+15), width=0, color=sd.background_color) sd.line(sd.get_point(x, y), sd.get_point(x, y - 10)) sd.circle(sd.get_point(x-15, y+15), radius=7) sd.circle(sd.get_point(x + 15, y + 15), radius=7) sd.line(sd.get_point(x - 8, y + 15), sd.get_point(x + 8, y + 15)) sd.line(sd.get_point(x - 22, y + 15), sd.get_point(x - 40, y + 30)) sd.line(sd.get_point(x + 22, y + 15), sd.get_point(x+40, y+30))
def smile(cord_1, cord_2, color): cord_x, cord_y = 440, 40 point_x = sd.get_point(cord_x + 30, cord_y + 50) point_y = sd.get_point(cord_x + 125, cord_y + 125) sd.ellipse(left_bottom=point_x, right_top=point_y, color=color, width=2) for x in range(55, 110, 30): point = sd.get_point(cord_x + x, cord_y + 100) sd.circle(center_position=point, radius=2, color=color, width=1) x = sd.get_point(cord_x + 40, cord_y + 85) y = sd.get_point(cord_x + 60, cord_y + 70) z = sd.get_point(cord_x + 90, cord_y + 70) z_1 = sd.get_point(cord_x + 110, cord_y + 85) point_list = (x, y, z, z_1) sd.lines(point_list=point_list, color=color, width=3)
def smile(): delta_x = 370 delta_y = -40 x_in_def = 50 y_in_def = 50 color_in_def = sd.COLOR_WHITE left_start_point_x = 0 + x_in_def + delta_x left_start_point_y = 0 + y_in_def + delta_y right_start_point_x = 70 + x_in_def + delta_x right_start_point_y = 50 + y_in_def + delta_y center_position_left_eye = sd.get_point(left_start_point_x + 20 + x_in_def, left_start_point_y + 30 + y_in_def) center_position_right_eye = sd.get_point( left_start_point_x + 50 + x_in_def, left_start_point_y + 30 + y_in_def) left_bottom = sd.get_point(left_start_point_x + x_in_def, left_start_point_y + y_in_def) right_top = sd.get_point(right_start_point_x + x_in_def, right_start_point_y + y_in_def) point_1 = sd.get_point(left_start_point_x + x_in_def + 20, left_start_point_y + 20 + y_in_def) point_2 = sd.get_point(left_start_point_x + x_in_def + 25, left_start_point_y + 15 + y_in_def) point_3 = sd.get_point(left_start_point_x + x_in_def + 45, left_start_point_y + 15 + y_in_def) point_4 = sd.get_point(left_start_point_x + x_in_def + 50, left_start_point_y + 20 + y_in_def) point_list = (point_1, point_2, point_3, point_4) sd.ellipse(left_bottom=left_bottom, right_top=right_top, color=color_in_def, width=1) sd.circle(center_position=center_position_left_eye, radius=5, color=color_in_def, width=1) sd.circle(center_position=center_position_right_eye, radius=5, color=color_in_def, width=1) sd.lines(point_list=point_list, color=color_in_def, closed=False, width=1)
def draw_face(x, y, color, blink=False): left_point = sd.get_point(x, y) right_point = sd.get_point(x + 110, y + 90) sd.ellipse(left_point, right_point, color, 2) sd.circle(sd.get_point(x + 30, y + 60), 8, color, 2) if blink: sd.circle(sd.get_point(x + 80, y + 60), 8, sd.COLOR_WHITE, 2) sd.line(sd.get_point(x + 70, y + 60), sd.get_point(x + 90, y + 60), color, 2) else: sd.line(sd.get_point(x + 70, y + 60), sd.get_point(x + 90, y + 60), sd.COLOR_WHITE, 2) sd.circle(sd.get_point(x + 80, y + 60), 8, color, 2) points = [ sd.get_point(x + 20, y + 30), sd.get_point(x + 45, y + 20), sd.get_point(x + 65, y + 20), sd.get_point(x + 90, y + 30) ] sd.lines(points, color)
def cat(x, y): sd.ellipse(left_bottom=sd.get_point(x - 40, y - 12), right_top=sd.get_point(x + 40, y + 16), color=sd.COLOR_BLACK) sd.ellipse(left_bottom=sd.get_point(x + 30, y - 50), right_top=sd.get_point(x + 40, y), color=sd.COLOR_BLACK) sd.circle(sd.get_point(x - 40, y + 12), radius=16, color=sd.COLOR_WHITE) sd.circle(sd.get_point(x - 40, y + 12), radius=15, color=sd.COLOR_BLACK, width=0) cat_ear = [] cat_ear.append(sd.get_point(x - 43, y + 23)) cat_ear.append(sd.get_point(x - 53, y + 23)) cat_ear.append(sd.get_point(x - 47, y + 33)) sd.polygon(cat_ear, color=sd.COLOR_BLACK, width=0) cat_ear = [] cat_ear.append(sd.get_point(x - 30, y + 23)) cat_ear.append(sd.get_point(x - 40, y + 23)) cat_ear.append(sd.get_point(x - 35, y + 33)) sd.polygon(cat_ear, color=sd.COLOR_BLACK, width=0) sd.circle(sd.get_point(x - 40, y + 12), radius=1, color=sd.COLOR_WHITE) sd.circle(sd.get_point(x - 45, y + 17), radius=2, color=sd.COLOR_BLUE) sd.circle(sd.get_point(x - 35, y + 18), radius=2, color=sd.COLOR_BLUE) sd.line(sd.get_point(x - 42, y + 6), sd.get_point(x - 38, y + 6))
def draw_smile(x, y, color): sd.ellipse(left_bottom=sd.get_point(x, y), right_top=sd.get_point(x + 150, y + 100), color=color, width=2) sd.circle(center_position=sd.get_point(x + 40, y + 70), radius=8, color=color, width=1) sd.circle(center_position=sd.get_point(x + 110, y + 70), radius=8, color=color, width=1) sd.lines(point_list=[ sd.get_point(x + 20, y + 50), sd.get_point(x + 50, y + 25), sd.get_point(x + 100, y + 25), sd.get_point(x + 130, y + 50) ], color=color, width=1)
def third_screen(): for i in range(10): point = sd.random_point() color = sd.random_color() dx = sd.random_number(30, 100) dy = sd.random_number(30, 100) right_top = sd.Point(x=point.x + dx, y=point.y + dy) sd.ellipse(left_bottom=point, right_top=right_top, color=color) v3 = sd.Vector(start_point=sd.Point(0, 0), direction=90, length=50) for direction in range(0, 181, 20): v = sd.Vector(start_point=sd.Point(x=300, y=300), direction=direction, length=100) v.draw(width=3) v2 = sd.Vector(start_point=v.end_point, direction=direction + 30, length=50) v2.draw(color=sd.COLOR_GREEN, width=2) v2.add(v3) v2.draw(color=sd.COLOR_ORANGE) sd.snowflake(center=sd.Point(), length=60, factor_b=0.2, factor_c=100) if TAKE_SNAPSHOTS: sd.take_snapshot(path=SNAPSHOTS_PATH)
def smile(x=100, y=100, color=sd.COLOR_DARK_ORANGE): """ :rtype: object """ left_bottom = sd.get_point(x - 50, y - 40) right_top = sd.get_point(x + 50, y + 40) sd.ellipse(left_bottom, right_top, color, width=2) sd.circle(center_position=sd.get_point(x - 15, y + 15), radius=5, color=sd.COLOR_DARK_ORANGE, width=2) sd.circle(center_position=sd.get_point(x + 15, y + 15), radius=5, color=sd.COLOR_DARK_ORANGE, width=2) point_list = [ sd.get_point(x - 15, y - 10), sd.get_point(x - 5, y - 20), sd.get_point(x + 5, y - 20), sd.get_point(x + 15, y - 10) ] sd.lines(point_list, color=sd.COLOR_DARK_ORANGE, closed=False, width=2)
def draw_smile(color=sd.COLOR_DARK_GREEN, open_eye=1): bottom_left = sd.get_point(421, 70) top_right = sd.get_point(479, 120) left_eye = sd.get_point(437, 100) right_eye = sd.get_point(463, 100) smile_left_corner_center = sd.get_point(442, 85) smile_right_corner_center = sd.get_point(458, 85) smile_left_corner_left_part = sd.get_point(432, 90) smile_right_corner_left_part = sd.get_point(442, 85) smile_left_corner_right_part = sd.get_point(458, 85) smile_right_corner_right_part = sd.get_point(468, 90) sd.line(smile_left_corner_center, smile_right_corner_center, color=color, width=2) sd.line(smile_left_corner_left_part, smile_right_corner_left_part, color=color, width=2) sd.line(smile_left_corner_right_part, smile_right_corner_right_part, color=color, width=2) sd.ellipse(bottom_left, top_right, color=color, width=3) sd.circle(left_eye, radius=6, width=1, color=color) if open_eye == 1: sd.circle(right_eye, radius=6, width=0, color=sd.COLOR_YELLOW) sd.circle(right_eye, radius=6, width=open_eye, color=color) else: sd.circle(right_eye, radius=6, width=open_eye, color=color)
def smile(x, y, color=(255, 200, 0), radius=200): center = sd.get_point(x, y) detalization = 50 # radius = 100 # color = (255, 200, 0) # body step = radius // detalization body_radius = radius for _ in range(detalization): sd.circle(center, radius=body_radius, color=color, width=step) body_radius -= step color = full_gradient(color, detalization) sd.circle(center, radius=body_radius, color=color, width=0) # eyes # ellipse(left_bottom, right_top, color=COLOR_YELLOW, width=0) left_bottom = sd.get_point(x - radius * 0.30, y + radius * 0.20) right_top = sd.get_point(x - radius * 0.1, y + radius * 0.60) sd.ellipse(left_bottom, right_top, color=sd.COLOR_BLACK, width=0) left_bottom = sd.get_point(x + radius * 0.10, y + radius * 0.20) right_top = sd.get_point(x + radius * 0.3, y + radius * 0.60) sd.ellipse(left_bottom, right_top, color=sd.COLOR_BLACK, width=0) # mouth используем параболу point_list = [] mouth_step = int(radius * 1.2 // detalization) for x_mouth in range(int(-radius * 0.6), int(radius * 0.6) + mouth_step, mouth_step): y_mouth = x_mouth**2 / (radius * 1.2) - radius / 2 point_list.append(sd.get_point((x_mouth + x), (y_mouth + y))) print(sd.get_point(x_mouth, y_mouth)) sd.lines(point_list, color=sd.COLOR_BLACK, closed=False, width=int(radius * 0.05))
def smile(x, y): sd.ellipse(left_bottom=sd.get_point(x - 40, y - 45), right_top=sd.get_point(x + 40, y + 45), color=sd.random_color()) face_color = sd.random_color() sd.ellipse(left_bottom=sd.get_point(x + 10, y + 8), right_top=sd.get_point(x + 30, y + 20), color=face_color, width=2) sd.ellipse(left_bottom=sd.get_point(x - 27, y + 8), right_top=sd.get_point(x - 7, y + 20), color=face_color, width=2) sd.circle(sd.get_point(x + 18, y + 14), radius=2, color=face_color) sd.circle(sd.get_point(x - 19, y + 14), radius=2, color=face_color) sd.line(start_point=sd.get_point(x, y - 8), end_point=sd.get_point(x, y + 13), color=face_color, width=4) sd.line(start_point=sd.get_point(x - 4, y - 8), end_point=sd.get_point(x + 5, y - 8), color=face_color, width=4) sd.line(start_point=sd.get_point(x - 10, y - 18), end_point=sd.get_point(x + 11, y - 18), color=face_color, width=4) sd.line(start_point=sd.get_point(x + 11, y - 18), end_point=sd.get_point(x + 16, y - 15), color=face_color, width=4) sd.line(start_point=sd.get_point(x - 10, y - 18), end_point=sd.get_point(x - 15, y - 15), color=face_color, width=4)
def smile(x, y, blink=True): sd.ellipse(left_bottom=sd.get_point(x - 30, y - 35), right_top=sd.get_point(x + 30, y + 35), color=sd.COLOR_PURPLE) face_color = sd.COLOR_DARK_BLUE if blink: sd.line(start_point=sd.get_point(x + 4, y + 12), end_point=sd.get_point(x + 24, y + 12), color=face_color, width=2) sd.line(start_point=sd.get_point(x - 23, y + 12), end_point=sd.get_point(x - 3, y + 12), color=face_color, width=2) else: sd.ellipse(left_bottom=sd.get_point(x + 4, y + 6), right_top=sd.get_point(x + 24, y + 18), color=face_color, width=2) sd.ellipse(left_bottom=sd.get_point(x - 23, y + 6), right_top=sd.get_point(x - 3, y + 18), color=face_color, width=2) sd.circle(sd.get_point(x + 12, y + 12), radius=2, color=face_color) sd.circle(sd.get_point(x - 15, y + 12), radius=2, color=face_color) sd.line(start_point=sd.get_point(x, y - 8), end_point=sd.get_point(x, y + 8), color=face_color, width=3) sd.line(start_point=sd.get_point(x - 4, y - 8), end_point=sd.get_point(x + 5, y - 8), color=face_color, width=3) sd.line(start_point=sd.get_point(x - 10, y - 18), end_point=sd.get_point(x + 11, y - 18), color=face_color, width=3) sd.line(start_point=sd.get_point(x + 11, y - 18), end_point=sd.get_point(x + 16, y - 15), color=face_color, width=3) sd.line(start_point=sd.get_point(x - 10, y - 18), end_point=sd.get_point(x - 15, y - 15), color=face_color, width=3)
def draw_rainbow(x_left, x_right, y_left, y_right, colors=rainbow_colors): for color in colors: sd.ellipse(sd.get_point(x_left, y_left), sd.get_point(x_right, y_right), color, 20) x_left += 15 y_right -= 15
def smile(point, color): # голова смайла x = point.x y = point.y if x < 90: x = 90 elif point.x > 1110: x = 1110 if y < 80: y = 80 elif y > 520: y = 520 # point = sd.get_point(x, y) random_delta_x = sd.random_number(50, 90) random_delta_y = sd.random_number(40, random_delta_x - 10) x_left = x - random_delta_x if x_left < 0: x_left = 0 x_right = x + random_delta_x if x_right > 1200: x_right = 1200 y_top = y + random_delta_y if y_top > 600: y_top = 600 y_bottom = y - random_delta_y if y_bottom < 0: y_bottom = 0 left_bottom = sd.get_point(x=x_left, y=y_bottom) right_top = sd.get_point(x=x_right, y=y_top) color = sd.random_color() # отрисовка с условием чтоб смайлы не накладывались друг на друга if not dict_used_points: dict_used_points.setdefault((0, 0), (0, 0)) for key, value in dict_used_points.items(): if0 = (key[0] < left_bottom.x < value[0]) & (key[1] < left_bottom.y < value[1]) if1 = (left_bottom.x >= value[0]) or (left_bottom.y >= value[1]) if2 = (right_top.x <= key[0]) or (right_top.y <= key[1]) if if0 or all([not if1, not if2]): return smile(point=sd.random_point(), color=None) sd.ellipse(left_bottom, right_top, color=color, width=2) dict_used_points.setdefault((left_bottom.x, left_bottom.y), (right_top.x, right_top.y)) # глаза center_left_eye = sd.get_point(x=x_left + sd.random_number(30, 40), y=y_top - sd.random_number(30, 35)) radius_left_eye = sd.random_number(7, 10) # width_left_eye = sd.random_number(2, 4) * sd.random_number(0, 1) center_right_eye = sd.get_point(x=x_right - sd.random_number(30, 40), y=y_top - sd.random_number(30, 35)) radius_right_eye = sd.random_number(7, 10) # widht_right_eye = sd.random_number(2, 4) * sd.random_number(0, 1) sd.circle(center_position=center_left_eye, radius=radius_left_eye, color=color, width=sd.random_number(0, 2)) sd.circle(center_position=center_right_eye, radius=radius_right_eye, color=color, width=sd.random_number(0, 2)) # рот point1 = sd.get_point(x=x_left + sd.random_number(20, 40), y=y_bottom + sd.random_number(30, 40)) point2 = sd.get_point(x=x_left + sd.random_number(40, 50), y=y - random_delta_y + sd.random_number(15, 25)) point3 = sd.get_point(x=x + sd.random_number(-10, 10), y=y_bottom + sd.random_number(20, 30)) point4 = sd.get_point(x=x_right - sd.random_number(40, 50), y=y_bottom + sd.random_number(15, 25)) point5 = sd.get_point(x=x_right - sd.random_number(20, 40), y=y_bottom + sd.random_number(30, 45)) points = [point1, point2, point3, point4, point5] random_points_list1 = points[0:sd.random_number(2, 5)] random_points_list2 = points[sd.random_number(0, 3):5] random_points_list3 = points[::2] random_points_list4 = points[1::2] random_points_list = sd.choice([ random_points_list1, random_points_list2, random_points_list3, random_points_list4 ]) closed = sd.choice([True, False]) sd.lines(point_list=random_points_list, color=color, closed=closed, width=sd.random_number(1, 4))