#!/usr/bin/env python3 import pygame from pygame.draw import * pygame.init() 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 ] WHITE, BLACK, NOSE, MOUTH, BLUSH, WHISKERS, BODY = COLORS 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 # === ТЕЛО === ellipse(surface, color, (x - body_w // 2, y + body_h // 2 - body_h // 2, body_w, body_h)) # === ГОЛОВА === 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, [ (x, nose_y), (x - head_size // 8, nose_y + head_size // 12), (x + head_size // 8, nose_y + head_size // 12) ]) # === РОТ === line(surface, MOUTH, (x, nose_y + head_size // 16), (x, nose_y + head_size // 8), 2) # === ЩЁКИ === 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_len = head_size // 4 for i in range(3): 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) 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) # === ПЕРЕДНИЕ ЛАПЫ === fw = width // 12 fh = height // 8 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, 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() finished = False while not finished: clock.tick(FPS) for event in pygame.event.get(): if event.type == pygame.QUIT: finished = True pygame.quit()