From 7a648e6b72ad995296a297582a2d8e1bd0b57a0e Mon Sep 17 00:00:00 2001 From: 24_OskinEA <24_OskinEA@iux.local> Date: Wed, 18 Mar 2026 12:03:28 +0300 Subject: [PATCH 1/5] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20rabit2.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rabit2.py | 132 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 79 insertions(+), 53 deletions(-) diff --git a/rabit2.py b/rabit2.py index 21f1695..8203306 100755 --- a/rabit2.py +++ b/rabit2.py @@ -5,57 +5,83 @@ from pygame.draw import * pygame.init() FPS = 30 -screen = pygame.display.set_mode((400, 400)) +screen = pygame.display.set_mode((600, 600)) +clock = pygame.time.Clock() + +# ================= ORIGINAL FUNCTIONS ================= def draw_body(surface, x, y, width, height, color): ellipse(surface, color, (x - width // 2, y - height // 2, width, height)) + def draw_head(surface, x, y, size, color): circle(surface, color, (x, y), size // 2) + def draw_ear(surface, x, y, width, height, color): ellipse(surface, color, (x - width // 2, y - height // 2, width, height)) + def draw_leg(surface, x, y, width, height, color): ellipse(surface, color, (x - width // 2, y - height // 2, width, height)) + def draw_hare(surface, x, y, width, height, color): + # тело body_width = width // 2 body_height = height // 2 body_y = y + body_height // 2 draw_body(surface, x, body_y, body_width, body_height, color) + # пузико + circle(surface, (255, 255, 255), (x, body_y), body_width // 4) + + # голова head_size = height // 4 head_y = y - head_size // 2 draw_head(surface, x, head_y, head_size, color) + # уши ear_height = height // 3 ear_y = y - height // 2 + ear_height // 2 for ear_x in (x - head_size // 4, x + head_size // 4): draw_ear(surface, ear_x, ear_y, width // 8, ear_height, color) + # задние лапы leg_height = height // 16 leg_y = y + height // 2 - leg_height // 2 for leg_x in (x - width // 4, x + width // 4): draw_leg(surface, leg_x, leg_y, width // 4, leg_height, color) - # Глаза (белки) + # ПЕРЕДНИЕ лапы (перерисовал нормально — как овальные лапки снизу) + front_w = width // 8 + front_h = height // 10 + front_y = y + height // 5 + + # делаем их более «лежащими» и аккуратными + # сначала рисуем лапы + ellipse(surface, color, (x - width // 5 - front_w//2, front_y, front_w, front_h)) + ellipse(surface, color, (x + width // 5 - front_w//2, front_y, front_w, front_h)) + + # затем поверх — ТОЛЬКО розовые подушечки (полностью перекрывают центр) + circle(surface, (255, 220, 220), (x - width // 5, front_y + front_h//2), front_h//3) + circle(surface, (255, 220, 220), (x + width // 5, front_y + front_h//2), front_h//3) + + # небольшие "подушечки" (деталь) + circle(surface, (255, 220, 220), (x - width // 5, front_y + front_h//2), front_h//4) + circle(surface, (255, 220, 220), (x + width // 5, front_y + front_h//2), front_h//4) + + # хвостик + circle(surface, color, (x + body_width // 2, body_y), body_width // 8) + + # глаза eye_y = head_y - head_size // 8 eye_radius = head_size // 8 for eye_x in (x - head_size // 6, x + head_size // 6): circle(surface, (255, 255, 255), (eye_x, eye_y), eye_radius) + circle(surface, (0, 0, 0), (eye_x, eye_y), eye_radius // 2) - # Зрачки - pupil_radius = eye_radius // 2 - for pupil_x in (x - head_size // 6, x + head_size // 6): - circle(surface, (0, 0, 0), (pupil_x, eye_y), pupil_radius) - - # Блики в глазах - spark_radius = pupil_radius // 3 - for spark_x in (x - head_size // 6 - 2, x + head_size // 6 - 2): - circle(surface, (255, 255, 255), (spark_x, eye_y - 2), spark_radius) - - # Носик (розовый треугольник) + # нос nose_y = head_y + head_size // 8 polygon(surface, (255, 150, 150), [ (x, nose_y), @@ -63,55 +89,55 @@ def draw_hare(surface, x, y, width, height, color): (x + head_size // 8, nose_y + head_size // 12) ]) - # Ротик - line(surface, (150, 100, 100), - (x, nose_y + head_size // 16), - (x, nose_y + head_size // 8), 2) - # Немного румянца на щечках - blush_radius = head_size // 10 - for cheek_x in (x - head_size // 4, x + head_size // 4): - circle(surface, (255, 200, 200), (cheek_x, nose_y + head_size // 24), blush_radius) +# ================= EXTRA OBJECTS ================= - # Усики - whisker_y = nose_y + head_size // 24 - whisker_length = head_size // 4 - for i in range(3): - # Левые усики - line(surface, (100, 100, 100), - (x - head_size // 10, whisker_y + i * 2), - (x - whisker_length - head_size // 10, whisker_y - head_size // 10 + i * 2), 1) - # Правые усики - line(surface, (100, 100, 100), - (x + head_size // 10, whisker_y + i * 2), - (x + whisker_length + head_size // 10, whisker_y - head_size // 10 + i * 2), 1) - - # Передние лапки (две маленькие) - с обводкой - front_leg_width = width // 12 - front_leg_height = height // 8 - front_leg_y = y + height // 6 - - # Левая передняя лапка (с обводкой) - ellipse(surface, (0, 0, 0), (x - width // 6 - front_leg_width // 2, - front_leg_y - front_leg_height // 2, - front_leg_width, front_leg_height), 1) - - # Правая передняя лапка (с обводкой) - ellipse(surface, (0, 0, 0), (x + width // 6 - front_leg_width // 2, - front_leg_y - front_leg_height // 2, - front_leg_width, front_leg_height), 1) +def draw_sun(surface): + circle(surface, (255, 220, 0), (520, 80), 40) -draw_hare(screen, 200, 200, 200, 400, (200, 200, 200)) +def draw_cloud(surface, x, y): + circle(surface, (255, 255, 255), (x, y), 20) + circle(surface, (255, 255, 255), (x + 20, y), 25) + circle(surface, (255, 255, 255), (x + 40, y), 20) + + +def draw_house(surface): + rect(surface, (200, 150, 100), (50, 350, 120, 120)) + polygon(surface, (150, 75, 0), [(50, 350), (110, 300), (170, 350)]) + + +def draw_carrot(surface, x, y): + polygon(surface, (255, 120, 0), [(x, y), (x - 10, y + 30), (x + 10, y + 30)]) + line(surface, (0, 200, 0), (x, y), (x, y - 15), 3) + + +def draw_grass(surface): + for i in range(0, 600, 10): + line(surface, (0, 180, 0), (i, 580), (i + 5, 560), 2) + + +# ================= DRAW ================= +screen.fill((255, 255, 255)) + +draw_sun(screen) +draw_cloud(screen, 150, 80) +draw_cloud(screen, 250, 60) +draw_house(screen) +draw_carrot(screen, 450, 500) +draw_grass(screen) + +# один кролик +draw_hare(screen, 300, 300, 200, 400, (200, 200, 200)) pygame.display.update() -clock = pygame.time.Clock() -finished = False -while not finished: +# ================= LOOP ================= +running = True +while running: clock.tick(FPS) for event in pygame.event.get(): if event.type == pygame.QUIT: - finished = True + running = False pygame.quit() -- 2.49.0 From f5d679db689eb0c9dd2aeb205323fa1b2b59d949 Mon Sep 17 00:00:00 2001 From: 24_OskinEA <24_OskinEA@iux.local> Date: Wed, 18 Mar 2026 13:21:32 +0300 Subject: [PATCH 2/5] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20rabit2.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rabit2.py | 133 +++++++++++++++++++++++------------------------------- 1 file changed, 57 insertions(+), 76 deletions(-) diff --git a/rabit2.py b/rabit2.py index 8203306..31ef579 100755 --- a/rabit2.py +++ b/rabit2.py @@ -5,83 +5,59 @@ from pygame.draw import * pygame.init() FPS = 30 -screen = pygame.display.set_mode((600, 600)) -clock = pygame.time.Clock() - -# ================= ORIGINAL FUNCTIONS ================= +screen = pygame.display.set_mode((400, 400)) def draw_body(surface, x, y, width, height, color): ellipse(surface, color, (x - width // 2, y - height // 2, width, height)) - def draw_head(surface, x, y, size, color): circle(surface, color, (x, y), size // 2) - def draw_ear(surface, x, y, width, height, color): ellipse(surface, color, (x - width // 2, y - height // 2, width, height)) - def draw_leg(surface, x, y, width, height, color): ellipse(surface, color, (x - width // 2, y - height // 2, width, height)) - def draw_hare(surface, x, y, width, height, color): - # тело body_width = width // 2 body_height = height // 2 body_y = y + body_height // 2 draw_body(surface, x, body_y, body_width, body_height, color) - # пузико - circle(surface, (255, 255, 255), (x, body_y), body_width // 4) - - # голова head_size = height // 4 head_y = y - head_size // 2 draw_head(surface, x, head_y, head_size, color) - # уши ear_height = height // 3 ear_y = y - height // 2 + ear_height // 2 for ear_x in (x - head_size // 4, x + head_size // 4): draw_ear(surface, ear_x, ear_y, width // 8, ear_height, color) - # задние лапы leg_height = height // 16 leg_y = y + height // 2 - leg_height // 2 for leg_x in (x - width // 4, x + width // 4): draw_leg(surface, leg_x, leg_y, width // 4, leg_height, color) - # ПЕРЕДНИЕ лапы (перерисовал нормально — как овальные лапки снизу) - front_w = width // 8 - front_h = height // 10 - front_y = y + height // 5 + # Добавляем детали - # делаем их более «лежащими» и аккуратными - # сначала рисуем лапы - ellipse(surface, color, (x - width // 5 - front_w//2, front_y, front_w, front_h)) - ellipse(surface, color, (x + width // 5 - front_w//2, front_y, front_w, front_h)) - - # затем поверх — ТОЛЬКО розовые подушечки (полностью перекрывают центр) - circle(surface, (255, 220, 220), (x - width // 5, front_y + front_h//2), front_h//3) - circle(surface, (255, 220, 220), (x + width // 5, front_y + front_h//2), front_h//3) - - # небольшие "подушечки" (деталь) - circle(surface, (255, 220, 220), (x - width // 5, front_y + front_h//2), front_h//4) - circle(surface, (255, 220, 220), (x + width // 5, front_y + front_h//2), front_h//4) - - # хвостик - circle(surface, color, (x + body_width // 2, body_y), body_width // 8) - - # глаза + # Глаза (белки) eye_y = head_y - head_size // 8 eye_radius = head_size // 8 for eye_x in (x - head_size // 6, x + head_size // 6): circle(surface, (255, 255, 255), (eye_x, eye_y), eye_radius) - circle(surface, (0, 0, 0), (eye_x, eye_y), eye_radius // 2) - # нос + # Зрачки + pupil_radius = eye_radius // 2 + for pupil_x in (x - head_size // 6, x + head_size // 6): + circle(surface, (0, 0, 0), (pupil_x, eye_y), pupil_radius) + + # Блики в глазах + spark_radius = pupil_radius // 3 + for spark_x in (x - head_size // 6 - 2, x + head_size // 6 - 2): + circle(surface, (255, 255, 255), (spark_x, eye_y - 2), spark_radius) + + # Носик (розовый треугольник) nose_y = head_y + head_size // 8 polygon(surface, (255, 150, 150), [ (x, nose_y), @@ -89,55 +65,60 @@ def draw_hare(surface, x, y, width, height, color): (x + head_size // 8, nose_y + head_size // 12) ]) + # Ротик + line(surface, (150, 100, 100), + (x, nose_y + head_size // 16), + (x, nose_y + head_size // 8), 2) -# ================= EXTRA OBJECTS ================= + # Немного румянца на щечках + blush_radius = head_size // 10 + for cheek_x in (x - head_size // 4, x + head_size // 4): + circle(surface, (255, 200, 200), (cheek_x, nose_y + head_size // 24), blush_radius) -def draw_sun(surface): - circle(surface, (255, 220, 0), (520, 80), 40) + # Усики (по три с каждой стороны) - теперь после румянца + whisker_y = nose_y + head_size // 24 + whisker_length = head_size // 4 + for i in range(3): + # Левые усики + line(surface, (100, 100, 100), + (x - head_size // 10, whisker_y + i * 2), + (x - whisker_length - head_size // 10, whisker_y - head_size // 10 + i * 2), 1) + # Правые усики + line(surface, (100, 100, 100), + (x + head_size // 10, whisker_y + i * 2), + (x + whisker_length + head_size // 10, whisker_y - head_size // 10 + i * 2), 1) + # Передние лапки (две маленькие) - с обводкой + front_leg_width = width // 12 + front_leg_height = height // 8 + front_leg_y = y + height // 6 -def draw_cloud(surface, x, y): - circle(surface, (255, 255, 255), (x, y), 20) - circle(surface, (255, 255, 255), (x + 20, y), 25) - circle(surface, (255, 255, 255), (x + 40, y), 20) + # Левая передняя лапка (с обводкой) + ellipse(surface, color, (x - width // 6 - front_leg_width // 2, + front_leg_y - front_leg_height // 2, + front_leg_width, front_leg_height)) + ellipse(surface, (0, 0, 0), (x - width // 6 - front_leg_width // 2, + front_leg_y - front_leg_height // 2, + front_leg_width, front_leg_height), 1) + # Правая передняя лапка (с обводкой) + ellipse(surface, color, (x + width // 6 - front_leg_width // 2, + front_leg_y - front_leg_height // 2, + front_leg_width, front_leg_height)) + ellipse(surface, (0, 0, 0), (x + width // 6 - front_leg_width // 2, + front_leg_y - front_leg_height // 2, + front_leg_width, front_leg_height), 1) -def draw_house(surface): - rect(surface, (200, 150, 100), (50, 350, 120, 120)) - polygon(surface, (150, 75, 0), [(50, 350), (110, 300), (170, 350)]) - - -def draw_carrot(surface, x, y): - polygon(surface, (255, 120, 0), [(x, y), (x - 10, y + 30), (x + 10, y + 30)]) - line(surface, (0, 200, 0), (x, y), (x, y - 15), 3) - - -def draw_grass(surface): - for i in range(0, 600, 10): - line(surface, (0, 180, 0), (i, 580), (i + 5, 560), 2) - - -# ================= DRAW ================= -screen.fill((255, 255, 255)) - -draw_sun(screen) -draw_cloud(screen, 150, 80) -draw_cloud(screen, 250, 60) -draw_house(screen) -draw_carrot(screen, 450, 500) -draw_grass(screen) - -# один кролик -draw_hare(screen, 300, 300, 200, 400, (200, 200, 200)) +draw_hare(screen, 200, 200, 200, 400, (200, 200, 200)) pygame.display.update() +clock = pygame.time.Clock() +finished = False -# ================= LOOP ================= -running = True -while running: +while not finished: clock.tick(FPS) for event in pygame.event.get(): if event.type == pygame.QUIT: - running = False + finished = True pygame.quit() -- 2.49.0 From 65c49aaa7befd8b8cb4ba6c252bf9198bfdcdf7e Mon Sep 17 00:00:00 2001 From: 24_OskinEA <24_OskinEA@iux.local> Date: Wed, 18 Mar 2026 13:24:33 +0300 Subject: [PATCH 3/5] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20rabit2.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rabit2.py | 151 ++++++++++++++++++++++++++---------------------------- 1 file changed, 73 insertions(+), 78 deletions(-) diff --git a/rabit2.py b/rabit2.py index 31ef579..7781050 100755 --- a/rabit2.py +++ b/rabit2.py @@ -6,119 +6,114 @@ pygame.init() FPS = 30 screen = pygame.display.set_mode((400, 400)) +clock = pygame.time.Clock() -def draw_body(surface, x, y, width, height, color): - ellipse(surface, color, (x - width // 2, y - height // 2, width, height)) +# COLORS через список +COLORS = [ + (255, 255, 255), # 0 WHITE + (0, 0, 0), # 1 BLACK + (255, 150, 150), # 2 NOSE + (150, 100, 100), # 3 MOUTH + (255, 200, 200), # 4 BLUSH + (100, 100, 100), # 5 WHISKERS + (200, 200, 200) # 6 BODY +] -def draw_head(surface, x, y, size, color): - circle(surface, color, (x, y), size // 2) +WHITE, BLACK, NOSE, MOUTH, BLUSH, WHISKERS, BODY = COLORS -def draw_ear(surface, x, y, width, height, color): - ellipse(surface, color, (x - width // 2, y - height // 2, width, height)) - -def draw_leg(surface, x, y, width, height, color): - ellipse(surface, color, (x - width // 2, y - height // 2, width, height)) def draw_hare(surface, x, y, width, height, color): - body_width = width // 2 - body_height = height // 2 - body_y = y + body_height // 2 - draw_body(surface, x, body_y, body_width, body_height, color) - + # === ОСНОВНЫЕ ЧИСЛА === + body_w = width // 2 + body_h = height // 2 head_size = height // 4 + ear_h = height // 3 + + # === ТЕЛО === + ellipse(surface, color, (x - body_w // 2, y + body_h // 2 - body_h // 2, body_w, body_h)) + + # === ГОЛОВА === head_y = y - head_size // 2 - draw_head(surface, x, head_y, head_size, color) + circle(surface, color, (x, head_y), head_size // 2) - ear_height = height // 3 - ear_y = y - height // 2 + ear_height // 2 - for ear_x in (x - head_size // 4, x + head_size // 4): - draw_ear(surface, ear_x, ear_y, width // 8, ear_height, color) + # === УШИ === + ear_y = y - height // 2 + ear_h // 2 + ellipse(surface, color, (x - head_size // 4 - width // 16, ear_y - ear_h // 2, width // 8, ear_h)) + ellipse(surface, color, (x + head_size // 4 - width // 16, ear_y - ear_h // 2, width // 8, ear_h)) - leg_height = height // 16 - leg_y = y + height // 2 - leg_height // 2 - for leg_x in (x - width // 4, x + width // 4): - draw_leg(surface, leg_x, leg_y, width // 4, leg_height, color) + # === ЛАПЫ (задние) === + leg_h = height // 16 + leg_y = y + height // 2 - leg_h // 2 + ellipse(surface, color, (x - width // 4 - width // 8, leg_y - leg_h // 2, width // 4, leg_h)) + ellipse(surface, color, (x + width // 4 - width // 8, leg_y - leg_h // 2, width // 4, leg_h)) - # Добавляем детали - - # Глаза (белки) + # === ГЛАЗА === eye_y = head_y - head_size // 8 - eye_radius = head_size // 8 - for eye_x in (x - head_size // 6, x + head_size // 6): - circle(surface, (255, 255, 255), (eye_x, eye_y), eye_radius) + eye_r = head_size // 8 - # Зрачки - pupil_radius = eye_radius // 2 - for pupil_x in (x - head_size // 6, x + head_size // 6): - circle(surface, (0, 0, 0), (pupil_x, eye_y), pupil_radius) + circle(surface, WHITE, (x - head_size // 6, eye_y), eye_r) + circle(surface, WHITE, (x + head_size // 6, eye_y), eye_r) - # Блики в глазах - spark_radius = pupil_radius // 3 - for spark_x in (x - head_size // 6 - 2, x + head_size // 6 - 2): - circle(surface, (255, 255, 255), (spark_x, eye_y - 2), spark_radius) + circle(surface, BLACK, (x - head_size // 6, eye_y), eye_r // 2) + circle(surface, BLACK, (x + head_size // 6, eye_y), eye_r // 2) - # Носик (розовый треугольник) + circle(surface, WHITE, (x - head_size // 6 - 2, eye_y - 2), eye_r // 6) + circle(surface, WHITE, (x + head_size // 6 - 2, eye_y - 2), eye_r // 6) + + # === НОС === nose_y = head_y + head_size // 8 - polygon(surface, (255, 150, 150), [ + polygon(surface, NOSE, [ (x, nose_y), (x - head_size // 8, nose_y + head_size // 12), (x + head_size // 8, nose_y + head_size // 12) ]) - # Ротик - line(surface, (150, 100, 100), - (x, nose_y + head_size // 16), + # === РОТ === + line(surface, MOUTH, + (x, nose_y + head_size // 16), (x, nose_y + head_size // 8), 2) - # Немного румянца на щечках - blush_radius = head_size // 10 - for cheek_x in (x - head_size // 4, x + head_size // 4): - circle(surface, (255, 200, 200), (cheek_x, nose_y + head_size // 24), blush_radius) + # === ЩЁКИ === + blush_r = head_size // 10 + circle(surface, BLUSH, (x - head_size // 4, nose_y + head_size // 24), blush_r) + circle(surface, BLUSH, (x + head_size // 4, nose_y + head_size // 24), blush_r) - # Усики (по три с каждой стороны) - теперь после румянца + # === УСЫ === whisker_y = nose_y + head_size // 24 - whisker_length = head_size // 4 + whisker_len = head_size // 4 + for i in range(3): - # Левые усики - line(surface, (100, 100, 100), - (x - head_size // 10, whisker_y + i * 2), - (x - whisker_length - head_size // 10, whisker_y - head_size // 10 + i * 2), 1) - # Правые усики - line(surface, (100, 100, 100), - (x + head_size // 10, whisker_y + i * 2), - (x + whisker_length + head_size // 10, whisker_y - head_size // 10 + i * 2), 1) + line(surface, WHISKERS, + (x - head_size // 10, whisker_y + i * 2), + (x - whisker_len - head_size // 10, whisker_y - head_size // 10 + i * 2), 1) - # Передние лапки (две маленькие) - с обводкой - front_leg_width = width // 12 - front_leg_height = height // 8 - front_leg_y = y + height // 6 + line(surface, WHISKERS, + (x + head_size // 10, whisker_y + i * 2), + (x + whisker_len + head_size // 10, whisker_y - head_size // 10 + i * 2), 1) - # Левая передняя лапка (с обводкой) - ellipse(surface, color, (x - width // 6 - front_leg_width // 2, - front_leg_y - front_leg_height // 2, - front_leg_width, front_leg_height)) - ellipse(surface, (0, 0, 0), (x - width // 6 - front_leg_width // 2, - front_leg_y - front_leg_height // 2, - front_leg_width, front_leg_height), 1) + # === ПЕРЕДНИЕ ЛАПЫ === + fw = width // 12 + fh = height // 8 + fy = y + height // 6 - # Правая передняя лапка (с обводкой) - ellipse(surface, color, (x + width // 6 - front_leg_width // 2, - front_leg_y - front_leg_height // 2, - front_leg_width, front_leg_height)) - ellipse(surface, (0, 0, 0), (x + width // 6 - front_leg_width // 2, - front_leg_y - front_leg_height // 2, - front_leg_width, front_leg_height), 1) + ellipse(surface, color, (x - width // 6 - fw // 2, fy - fh // 2, fw, fh)) + ellipse(surface, BLACK, (x - width // 6 - fw // 2, fy - fh // 2, fw, fh), 1) -draw_hare(screen, 200, 200, 200, 400, (200, 200, 200)) + ellipse(surface, color, (x + width // 6 - fw // 2, fy - fh // 2, fw, fh)) + ellipse(surface, BLACK, (x + width // 6 - fw // 2, fy - fh // 2, fw, fh), 1) + + +# РИСУЕМ +screen.fill(WHITE) +draw_hare(screen, 200, 200, 200, 400, BODY) pygame.display.update() -clock = pygame.time.Clock() -finished = False +finished = False while not finished: clock.tick(FPS) for event in pygame.event.get(): if event.type == pygame.QUIT: finished = True -pygame.quit() +pygame.quit() \ No newline at end of file -- 2.49.0 From 921d41b816755f7eff85713ad66e78b4244a2fec Mon Sep 17 00:00:00 2001 From: 24_OskinEA <24_OskinEA@iux.local> Date: Wed, 18 Mar 2026 14:04:13 +0300 Subject: [PATCH 4/5] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20rabit2.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rabit2.py | 149 +++++++++++++++++++++++++++++------------------------- 1 file changed, 80 insertions(+), 69 deletions(-) diff --git a/rabit2.py b/rabit2.py index 7781050..3629d06 100755 --- a/rabit2.py +++ b/rabit2.py @@ -8,105 +8,116 @@ FPS = 30 screen = pygame.display.set_mode((400, 400)) clock = pygame.time.Clock() -# COLORS через список -COLORS = [ - (255, 255, 255), # 0 WHITE - (0, 0, 0), # 1 BLACK - (255, 150, 150), # 2 NOSE - (150, 100, 100), # 3 MOUTH - (255, 200, 200), # 4 BLUSH - (100, 100, 100), # 5 WHISKERS - (200, 200, 200) # 6 BODY -] +# === 1. Словарь цветов === +COLORS = { + "WHITE": (255, 255, 255), + "BLACK": (0, 0, 0), + "NOSE": (255, 150, 150), + "MOUTH": (150, 100, 100), + "BLUSH": (255, 200, 200), + "WHISKERS": (100, 100, 100), + "BODY": (200, 200, 200) +} -WHITE, BLACK, NOSE, MOUTH, BLUSH, WHISKERS, BODY = COLORS +# === 2. Словарь размеров и пропорций === +SIZES = { + "body_ratio": 0.5, + "head_ratio": 0.25, + "ear_ratio": 1/3, + "leg_ratio": 1/16, + "eye_ratio": 1/8, + "blush_ratio": 1/10, + "front_leg_w_ratio": 1/12, + "front_leg_h_ratio": 1/8 +} +# === 3. Подфункции для частей тела === +def draw_body(surface, x, y, width, height, color=None): + ellipse(surface, color, (x - width // 4, y, width // 2, height // 2)) -def draw_hare(surface, x, y, width, height, color): - # === ОСНОВНЫЕ ЧИСЛА === - body_w = width // 2 - body_h = height // 2 - head_size = height // 4 - ear_h = height // 3 +def draw_head(surface, x, y, width, height, color=None): + head_size = int(height * SIZES["head_ratio"]) + circle(surface, color, (x, y - head_size // 2), head_size // 2) - # === ТЕЛО === - ellipse(surface, color, (x - body_w // 2, y + body_h // 2 - body_h // 2, body_w, body_h)) +def draw_ears(surface, x, y, width, height, color=None): + head_size = int(height * SIZES["head_ratio"]) + ear_h = int(height * SIZES["ear_ratio"]) + ellipse(surface, color, (x - head_size // 4 - width // 16, y - height // 2, width // 8, ear_h)) + ellipse(surface, color, (x + head_size // 4 - width // 16, y - height // 2, width // 8, ear_h)) - # === ГОЛОВА === +def draw_eyes(surface, x, y, width, height, color=None): # color необязательный + head_size = int(height * SIZES["head_ratio"]) + eye_r = int(head_size * SIZES["eye_ratio"]) + eye_y = y - head_size // 2 - head_size // 8 + + circle(surface, COLORS["WHITE"], (x - head_size // 6, eye_y), eye_r) + circle(surface, COLORS["WHITE"], (x + head_size // 6, eye_y), eye_r) + circle(surface, COLORS["BLACK"], (x - head_size // 6, eye_y), eye_r // 2) + circle(surface, COLORS["BLACK"], (x + head_size // 6, eye_y), eye_r // 2) + circle(surface, COLORS["WHITE"], (x - head_size // 6 - 2, eye_y - 2), eye_r // 6) + circle(surface, COLORS["WHITE"], (x + head_size // 6 - 2, eye_y - 2), eye_r // 6) + +def draw_nose_mouth(surface, x, y, width, height, color=None): + head_size = int(height * SIZES["head_ratio"]) head_y = y - head_size // 2 - circle(surface, color, (x, head_y), head_size // 2) - - # === УШИ === - ear_y = y - height // 2 + ear_h // 2 - ellipse(surface, color, (x - head_size // 4 - width // 16, ear_y - ear_h // 2, width // 8, ear_h)) - ellipse(surface, color, (x + head_size // 4 - width // 16, ear_y - ear_h // 2, width // 8, ear_h)) - - # === ЛАПЫ (задние) === - leg_h = height // 16 - leg_y = y + height // 2 - leg_h // 2 - ellipse(surface, color, (x - width // 4 - width // 8, leg_y - leg_h // 2, width // 4, leg_h)) - ellipse(surface, color, (x + width // 4 - width // 8, leg_y - leg_h // 2, width // 4, leg_h)) - - # === ГЛАЗА === - eye_y = head_y - head_size // 8 - eye_r = head_size // 8 - - circle(surface, WHITE, (x - head_size // 6, eye_y), eye_r) - circle(surface, WHITE, (x + head_size // 6, eye_y), eye_r) - - circle(surface, BLACK, (x - head_size // 6, eye_y), eye_r // 2) - circle(surface, BLACK, (x + head_size // 6, eye_y), eye_r // 2) - - circle(surface, WHITE, (x - head_size // 6 - 2, eye_y - 2), eye_r // 6) - circle(surface, WHITE, (x + head_size // 6 - 2, eye_y - 2), eye_r // 6) - - # === НОС === nose_y = head_y + head_size // 8 - polygon(surface, NOSE, [ + + polygon(surface, COLORS["NOSE"], [ (x, nose_y), (x - head_size // 8, nose_y + head_size // 12), (x + head_size // 8, nose_y + head_size // 12) ]) + line(surface, COLORS["MOUTH"], (x, nose_y + head_size // 16), (x, nose_y + head_size // 8), 2) - # === РОТ === - line(surface, MOUTH, - (x, nose_y + head_size // 16), - (x, nose_y + head_size // 8), 2) +def draw_blush_whiskers(surface, x, y, width, height, color=None): + head_size = int(height * SIZES["head_ratio"]) + head_y = y - head_size // 2 + nose_y = head_y + head_size // 8 - # === ЩЁКИ === - blush_r = head_size // 10 - circle(surface, BLUSH, (x - head_size // 4, nose_y + head_size // 24), blush_r) - circle(surface, BLUSH, (x + head_size // 4, nose_y + head_size // 24), blush_r) + blush_r = int(head_size * SIZES["blush_ratio"]) + circle(surface, COLORS["BLUSH"], (x - head_size // 4, nose_y + head_size // 24), blush_r) + circle(surface, COLORS["BLUSH"], (x + head_size // 4, nose_y + head_size // 24), blush_r) - # === УСЫ === whisker_y = nose_y + head_size // 24 whisker_len = head_size // 4 - for i in range(3): - line(surface, WHISKERS, + line(surface, COLORS["WHISKERS"], (x - head_size // 10, whisker_y + i * 2), (x - whisker_len - head_size // 10, whisker_y - head_size // 10 + i * 2), 1) - - line(surface, WHISKERS, + line(surface, COLORS["WHISKERS"], (x + head_size // 10, whisker_y + i * 2), (x + whisker_len + head_size // 10, whisker_y - head_size // 10 + i * 2), 1) - # === ПЕРЕДНИЕ ЛАПЫ === - fw = width // 12 - fh = height // 8 +def draw_front_legs(surface, x, y, width, height, color=None): + fw = int(width * SIZES["front_leg_w_ratio"]) + fh = int(height * SIZES["front_leg_h_ratio"]) fy = y + height // 6 ellipse(surface, color, (x - width // 6 - fw // 2, fy - fh // 2, fw, fh)) - ellipse(surface, BLACK, (x - width // 6 - fw // 2, fy - fh // 2, fw, fh), 1) + ellipse(surface, COLORS["BLACK"], (x - width // 6 - fw // 2, fy - fh // 2, fw, fh), 1) ellipse(surface, color, (x + width // 6 - fw // 2, fy - fh // 2, fw, fh)) - ellipse(surface, BLACK, (x + width // 6 - fw // 2, fy - fh // 2, fw, fh), 1) + ellipse(surface, COLORS["BLACK"], (x + width // 6 - fw // 2, fy - fh // 2, fw, fh), 1) +# === 4. Словарь функций частей тела === +PARTS = { + "body": draw_body, + "head": draw_head, + "ears": draw_ears, + "eyes": draw_eyes, + "nose_mouth": draw_nose_mouth, + "blush_whiskers": draw_blush_whiskers, + "front_legs": draw_front_legs +} -# РИСУЕМ -screen.fill(WHITE) -draw_hare(screen, 200, 200, 200, 400, BODY) +# === 5. Главная функция, объединяющая все части === +def draw_hare(surface, x, y, width, height, color): + for part in ["body", "head", "ears", "eyes", "nose_mouth", "blush_whiskers", "front_legs"]: + PARTS[part](surface, x, y, width, height, color) +# === РИСУЕМ === +screen.fill(COLORS["WHITE"]) +draw_hare(screen, 200, 200, 200, 400, COLORS["BODY"]) pygame.display.update() finished = False -- 2.49.0 From 8e2fc960bfd3181c6daaf7faa3556a6397cc1a8a Mon Sep 17 00:00:00 2001 From: 24_OskinEA <24_OskinEA@iux.local> Date: Thu, 21 May 2026 21:15:09 +0300 Subject: [PATCH 5/5] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20smile.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- smile.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/smile.py b/smile.py index b9845bd..8f0757b 100755 --- a/smile.py +++ b/smile.py @@ -10,8 +10,7 @@ screen=pygame.display.set_mode((500,500)) def smile(screen): rect(screen, (230,200,160), (0, 0, 500, 500)) #фон circle(screen, (255, 255, 0), (250, 250), 230) #основа - rect(screen, (0, 0, 0), (150, 400, 200, 25)) #рот - polygon(screen, (0, 0, 0), [(100, 25), (225, 125), (200, 150), (75, 50)]) #левая бровь + rect(screen, (0, 0, 0), (150, 400, 200, 25)) polygon(screen, (0, 0, 0), [(400, 50), (425, 75), (300, 175), (275, 150)]) #правая бровь def eye(y): -- 2.49.0