diff --git a/task1.py b/task1.py index 642ba8f..88a572f 100644 --- a/task1.py +++ b/task1.py @@ -28,41 +28,27 @@ def draw_leg(surface, x, y, width, height, color): """Рисует ногу зайца.""" ellipse(surface, color, (x - width // 2, y - height // 2, width, height)) -def draw_hare(surface, center_x, center_y, total_width, total_height, color): - """ - Рисует зайца на экране. +def draw_hare(srf, cx, cy, w, h, clr): + ''' Рисует зайца ''' + bw = w // 2 + bh = h // 2 + by = cy + bh // 2 + draw_body(srf, cx, by, bw, bh, clr) - Параметры: - surface: поверхность для рисования - center_x, center_y: координаты центра изображения - total_width, total_height: ширина и высота изображения - color: цвет зайца - """ - # Тело - body_width = total_width // 2 - body_height = total_height // 2 - body_y = center_y + body_height // 2 - draw_body(surface, center_x, body_y, body_width, body_height, color) - - # Голова - head_size = total_height // 4 - head_y = center_y - head_size // 2 - draw_head(surface, center_x, head_y, head_size, color) + hs = h // 4 + hy = cy - hs // 2 + draw_head(srf, cx, hy, hs, clr) - # Уши - ear_height = total_height // 3 - ear_y = center_y - total_height // 2 + ear_height // 2 - ear_width = total_width // 8 - draw_ear(surface, center_x - head_size // 4, ear_y, ear_width, ear_height, color) - draw_ear(surface, center_x + head_size // 4, ear_y, ear_width, ear_height, color) + eh = h // 3 + ey = cy - h // 2 + eh // 2 + for ex in (cx - hs // 4, cx + hs // 4): + draw_ear(srf, ex, ey, w // 8, eh, clr) - # Ноги - leg_height = total_height // 16 - leg_y = center_y + total_height // 2 - leg_height // 2 - leg_width = total_width // 4 - draw_leg(surface, center_x - total_width // 4, leg_y, leg_width, leg_height, color) - draw_leg(surface, center_x + total_width // 4, leg_y, leg_width, leg_height, color) - + lh = h // 16 + ly = cy + h // 2 - lh // 2 + coords = [cx - w // 4, cx + w // 4] + for lx in coords: + draw_leg(srf, lx, ly, w // 4, lh, clr) # Рисуем зайца draw_hare(screen, 200, 200, 200, 400, BROWN)