сделал код немного хуже
This commit is contained in:
32
task1.py
32
task1.py
@@ -24,25 +24,27 @@ def draw_ear(surface, x, y, width, height, color):
|
|||||||
def draw_leg(surface, x, y, width, height, color):
|
def draw_leg(surface, x, y, width, height, color):
|
||||||
''' Рисует ногу '''
|
''' Рисует ногу '''
|
||||||
ellipse(surface, color, (x - width // 2, y - height // 2, width, height))
|
ellipse(surface, color, (x - width // 2, y - height // 2, width, height))
|
||||||
def draw_hare( surface, x, y, width, height, color):
|
def draw_hare(srf, cx, cy, w, h, clr):
|
||||||
''' Рисует зайца '''
|
''' Рисует зайца '''
|
||||||
body_width = width // 2
|
bw = w // 2
|
||||||
body_height = height // 2
|
bh = h // 2
|
||||||
body_y = y + body_height // 2
|
by = cy + bh // 2
|
||||||
draw_body(surface, x, body_y, body_width, body_height, color)
|
draw_body(srf, cx, by, bw, bh, clr)
|
||||||
|
|
||||||
head_size = height // 4
|
hs = h // 4
|
||||||
draw_head(surface, x, y-head_size // 2, head_size, color)
|
hy = cy - hs // 2
|
||||||
|
draw_head(srf, cx, hy, hs, clr)
|
||||||
|
|
||||||
ear_height = height // 3
|
eh = h // 3
|
||||||
ear_y = y - height // 2 + ear_height // 2
|
ey = cy - h // 2 + eh // 2
|
||||||
for ear_x in (x-head_size // 4, x + head_size // 4):
|
for ex in (cx - hs // 4, cx + hs // 4):
|
||||||
draw_ear (surface, ear_x, ear_y, width // 8, ear_height, color)
|
draw_ear(srf, ex, ey, w // 8, eh, clr)
|
||||||
|
|
||||||
leg_height = height // 16
|
lh = h // 16
|
||||||
leg_y =y + height // 2 - leg_height // 2
|
ly = cy + h // 2 - lh // 2
|
||||||
for leg_x in (x - width // 4, x + width // 4):
|
coords = [cx - w // 4, cx + w // 4]
|
||||||
draw_leg(surface, leg_x, leg_y, width // 4, leg_height, color)
|
for lx in coords:
|
||||||
|
draw_leg(srf, lx, ly, w // 4, lh, clr)
|
||||||
|
|
||||||
draw_hare(screen, 200, 200, 200, 400, BROWN)
|
draw_hare(screen, 200, 200, 200, 400, BROWN)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user