forked from 24_LitvintsevaVD/YP_2026_litvintseva
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4e91375bae | |||
| 8fb6a5d4c7 | |||
| 53750760cd |
163
egr.py
Executable file
163
egr.py
Executable file
@@ -0,0 +1,163 @@
|
||||
#!/usr/bin/env python3
|
||||
import pygame
|
||||
from pygame.draw import *
|
||||
import math
|
||||
|
||||
pygame.init()
|
||||
|
||||
FPS = 30
|
||||
screen = pygame.display.set_mode((900, 900))
|
||||
|
||||
# 1) Цвета
|
||||
WHITE = (255, 255, 255)
|
||||
GRAY = (230, 230, 230)
|
||||
DARK_GRAY = (180, 180, 180)
|
||||
PINK = (255, 210, 210)
|
||||
NOSE = (255, 120, 120)
|
||||
BLACK = (0, 0, 0)
|
||||
|
||||
# 2) Координаты центра
|
||||
cx = 450
|
||||
cy = 420
|
||||
|
||||
def draw_body(surface, x, y):
|
||||
"""Рисует тело зайца"""
|
||||
ellipse(surface, GRAY, (x - 150, y, 300, 220))
|
||||
ellipse(surface, DARK_GRAY, (x - 80, y + 80, 160, 100))
|
||||
|
||||
def draw_head(surface, x, y):
|
||||
"""Рисует голову зайца"""
|
||||
circle(surface, GRAY, (x, y - 120), 120)
|
||||
|
||||
def draw_left_ear(surface, x, y):
|
||||
"""Рисует левое ухо"""
|
||||
ellipse(surface, GRAY, (x - 90, y - 420, 70, 260))
|
||||
ellipse(surface, PINK, (x - 70, y - 400, 30, 200))
|
||||
|
||||
def draw_right_ear(surface, x, y):
|
||||
"""Рисует правое ухо"""
|
||||
ellipse(surface, GRAY, (x + 20, y - 420, 70, 260))
|
||||
ellipse(surface, PINK, (x + 40, y - 400, 30, 200))
|
||||
|
||||
def draw_left_eye(surface, x, y):
|
||||
"""Рисует левый глаз"""
|
||||
eye_y = y - 150
|
||||
circle(surface, BLACK, (x - 45, eye_y), 12)
|
||||
circle(surface, WHITE, (x - 50, eye_y - 5), 4)
|
||||
|
||||
def draw_right_eye(surface, x, y):
|
||||
"""Рисует правый глаз"""
|
||||
eye_y = y - 150
|
||||
circle(surface, BLACK, (x + 45, eye_y), 12)
|
||||
circle(surface, WHITE, (x + 40, eye_y - 5), 4)
|
||||
|
||||
def draw_nose(surface, x, y):
|
||||
"""Рисует нос и возвращает его координату y"""
|
||||
ny = y - 90
|
||||
polygon(surface, NOSE, [
|
||||
(x, ny),
|
||||
(x - 12, ny + 14),
|
||||
(x + 12, ny + 14)
|
||||
])
|
||||
return ny
|
||||
|
||||
def draw_mouth(surface, x, ny):
|
||||
"""Рисует рот"""
|
||||
line(surface, BLACK, (x, ny + 14), (x, ny + 28), 2)
|
||||
arc(surface, BLACK, (x - 30, ny + 20, 30, 20), math.pi, 2 * math.pi, 2)
|
||||
arc(surface, BLACK, (x, ny + 20, 30, 20), math.pi, 2 * math.pi, 2)
|
||||
|
||||
def draw_left_whiskers(surface, x, ny):
|
||||
"""Рисует левые усы"""
|
||||
for angle in [-10, 0, 10]:
|
||||
rad = math.radians(angle)
|
||||
x1 = x - 10
|
||||
y1 = ny + 10
|
||||
x2 = x - (10 + 120 * math.cos(rad))
|
||||
y2 = ny + 10 + 40 * math.sin(rad)
|
||||
line(surface, BLACK, (x1, y1), (x2, y2), 2)
|
||||
|
||||
def draw_right_whiskers(surface, x, ny):
|
||||
"""Рисует правые усы"""
|
||||
for angle in [-10, 0, 10]:
|
||||
rad = math.radians(angle)
|
||||
x1 = x + 10
|
||||
y1 = ny + 10
|
||||
x2 = x + (10 + 120 * math.cos(rad))
|
||||
y2 = ny + 10 + 40 * math.sin(rad)
|
||||
line(surface, BLACK, (x1, y1), (x2, y2), 2)
|
||||
|
||||
def draw_left_front_paw(surface, x, y):
|
||||
"""Рисует левую переднюю лапу"""
|
||||
ellipse(surface, GRAY, (x - 120, y + 160, 90, 50))
|
||||
|
||||
def draw_right_front_paw(surface, x, y):
|
||||
"""Рисует правую переднюю лапу"""
|
||||
ellipse(surface, GRAY, (x + 30, y + 160, 90, 50))
|
||||
|
||||
def draw_left_hind_paw(surface, x, y):
|
||||
"""Рисует левую заднюю лапу"""
|
||||
ellipse(surface, GRAY, (x - 180, y + 200, 120, 70))
|
||||
|
||||
def draw_right_hind_paw(surface, x, y):
|
||||
"""Рисует правую заднюю лапу"""
|
||||
ellipse(surface, GRAY, (x + 60, y + 200, 120, 70))
|
||||
|
||||
def draw_tail(surface, x, y):
|
||||
"""Рисует хвост"""
|
||||
circle(surface, GRAY, (x + 160, y + 80), 30)
|
||||
|
||||
def draw_shadow(surface, x, y):
|
||||
"""Рисует тень"""
|
||||
ellipse(surface, (200, 200, 200), (x - 200, y + 220, 400, 60))
|
||||
|
||||
def draw_hare(surface, x, y):
|
||||
"""Основная функция, рисующая всего зайца"""
|
||||
# Сначала тень (на заднем плане)
|
||||
draw_shadow(surface, x, y)
|
||||
|
||||
# Тело и голова
|
||||
draw_body(surface, x, y)
|
||||
draw_head(surface, x, y)
|
||||
|
||||
# Уши
|
||||
draw_left_ear(surface, x, y)
|
||||
draw_right_ear(surface, x, y)
|
||||
|
||||
# Глаза
|
||||
draw_left_eye(surface, x, y)
|
||||
draw_right_eye(surface, x, y)
|
||||
|
||||
# Нос и рот
|
||||
ny = draw_nose(surface, x, y)
|
||||
draw_mouth(surface, x, ny)
|
||||
|
||||
# Усы
|
||||
draw_left_whiskers(surface, x, ny)
|
||||
draw_right_whiskers(surface, x, ny)
|
||||
|
||||
# Лапы
|
||||
draw_left_front_paw(surface, x, y)
|
||||
draw_right_front_paw(surface, x, y)
|
||||
draw_left_hind_paw(surface, x, y)
|
||||
draw_right_hind_paw(surface, x, y)
|
||||
|
||||
# Хвост
|
||||
draw_tail(surface, x, y)
|
||||
|
||||
|
||||
# Рисуем зайца
|
||||
screen.fill(WHITE)
|
||||
draw_hare(screen, cx, cy)
|
||||
|
||||
pygame.display.update()
|
||||
clock = pygame.time.Clock()
|
||||
finished = False
|
||||
|
||||
while not finished:
|
||||
clock.tick(FPS)
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT:
|
||||
finished = True
|
||||
|
||||
pygame.quit()
|
||||
64
rabit2.py
64
rabit2.py
@@ -31,31 +31,27 @@ def draw_hare(surface, x, y, width, height, 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)
|
||||
draw_ear(surface, x - head_size // 4, ear_y, width // 8, ear_height, color)
|
||||
draw_ear(surface, x + head_size // 4, 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)
|
||||
draw_leg(surface, x - width // 4, leg_y, width // 4, leg_height, color)
|
||||
draw_leg(surface, x + width // 4, leg_y, width // 4, leg_height, color)
|
||||
|
||||
# Глаза (белки)
|
||||
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, (255, 255, 255), (x - head_size // 6, eye_y), eye_radius)
|
||||
circle(surface, (255, 255, 255), (x + head_size // 6, eye_y), eye_radius)
|
||||
|
||||
# Зрачки
|
||||
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, (0, 0, 0), (x - head_size // 6, eye_y), pupil_radius)
|
||||
circle(surface, (0, 0, 0), (x + head_size // 6, 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)
|
||||
circle(surface, (255, 255, 255), (x - head_size // 6 - 2, eye_y - 2), spark_radius)
|
||||
circle(surface, (255, 255, 255), (x + head_size // 6 - 2, eye_y - 2), spark_radius)
|
||||
|
||||
# Носик (розовый треугольник)
|
||||
nose_y = head_y + head_size // 8
|
||||
polygon(surface, (255, 150, 150), [
|
||||
(x, nose_y),
|
||||
@@ -63,40 +59,44 @@ 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)
|
||||
circle(surface, (255, 200, 200), (x - head_size // 4, nose_y + head_size // 24), blush_radius)
|
||||
circle(surface, (255, 200, 200), (x + head_size // 4, nose_y + head_size // 24), blush_radius)
|
||||
|
||||
# Усики
|
||||
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)
|
||||
|
||||
line(surface, (100, 100, 100),
|
||||
(x - head_size // 10, whisker_y),
|
||||
(x - whisker_length - head_size // 10, whisker_y - head_size // 10), 1)
|
||||
line(surface, (100, 100, 100),
|
||||
(x - head_size // 10, whisker_y + 2),
|
||||
(x - whisker_length - head_size // 10, whisker_y - head_size // 10 + 2), 1)
|
||||
line(surface, (100, 100, 100),
|
||||
(x - head_size // 10, whisker_y + 4),
|
||||
(x - whisker_length - head_size // 10, whisker_y - head_size // 10 + 4), 1)
|
||||
|
||||
line(surface, (100, 100, 100),
|
||||
(x + head_size // 10, whisker_y),
|
||||
(x + whisker_length + head_size // 10, whisker_y - head_size // 10), 1)
|
||||
line(surface, (100, 100, 100),
|
||||
(x + head_size // 10, whisker_y + 2),
|
||||
(x + whisker_length + head_size // 10, whisker_y - head_size // 10 + 2), 1)
|
||||
line(surface, (100, 100, 100),
|
||||
(x + head_size // 10, whisker_y + 4),
|
||||
(x + whisker_length + head_size // 10, whisker_y - head_size // 10 + 4), 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)
|
||||
|
||||
124
rabit3.py
Executable file
124
rabit3.py
Executable file
@@ -0,0 +1,124 @@
|
||||
#!/usr/bin/env python3
|
||||
import pygame
|
||||
from pygame.draw import *
|
||||
|
||||
pygame.init()
|
||||
|
||||
FPS = 30
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
# Добавляем детали
|
||||
|
||||
# Глаза (белки)
|
||||
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)
|
||||
|
||||
# Зрачки
|
||||
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),
|
||||
(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),
|
||||
(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)
|
||||
|
||||
# Усики (по три с каждой стороны) - теперь после румянца
|
||||
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, 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)
|
||||
|
||||
draw_hare(screen, 200, 200, 200, 400, (200, 200, 200))
|
||||
|
||||
pygame.display.update()
|
||||
clock = pygame.time.Clock()
|
||||
finished = False
|
||||
|
||||
while not finished:
|
||||
clock.tick(FPS)
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT:
|
||||
finished = True
|
||||
|
||||
pygame.quit()
|
||||
Reference in New Issue
Block a user