Python
1. напишите программу которая рисует снеговика.
2. напишите программу которая рисует смайлик.
alinaarsenuk0:
в скреичк
Ответы
Ответ дал:
1
1:
from PIL import Image, ImageDraw
def picture(file_name, width, height, sky_color="#75BBFD", snow_color="#FFFAFA", snowman_color="#EEE9E9", sun_color="#FFF917"):
im = Image.new("RGB", (width, height))
drawer = ImageDraw.Draw(im)
# nebo
drawer.rectangle(((0, 0), (width, int(height * 0.8))), sky_color)
# sneg
drawer.rectangle(((0, int(height * 0.8)), (width, height)),
snow_color)
# solnce
drawer.ellipse((
(int(0.8 * width), -int(0.2 * height)),
(int(1.2 * width), int(0.2 * height))),
sun_color)
# bolshoy_shar
drawer.ellipse((
(int(0.3 * width), int(0.55 * height)),
(int(0.7 * width), int(0.95 * height))),
snowman_color)
# srednii_shar
drawer.ellipse((
(int(0.35 * width), int(0.35 * height)),
(int(0.65 * width), int(0.65 * height))),
snowman_color)
# levui_shar
drawer.ellipse((
(int(0.30 * width), int(0.45 * height)),
(int(0.40 * width), int(0.55 * height))),
snowman_color)
# pravui_shar
drawer.ellipse((
(int(0.60 * width), int(0.45 * height)),
(int(0.70 * width), int(0.55 * height))),
snowman_color)
# maluy_shar
drawer.ellipse((
(int(0.4 * width), int(0.2 * height)),
(int(0.6 * width), int(0.4 * height))),
snowman_color)
im.save(file_name)
picture('res.jpg', 1000, 1000)
2. print(':)')
from PIL import Image, ImageDraw
def picture(file_name, width, height, sky_color="#75BBFD", snow_color="#FFFAFA", snowman_color="#EEE9E9", sun_color="#FFF917"):
im = Image.new("RGB", (width, height))
drawer = ImageDraw.Draw(im)
# nebo
drawer.rectangle(((0, 0), (width, int(height * 0.8))), sky_color)
# sneg
drawer.rectangle(((0, int(height * 0.8)), (width, height)),
snow_color)
# solnce
drawer.ellipse((
(int(0.8 * width), -int(0.2 * height)),
(int(1.2 * width), int(0.2 * height))),
sun_color)
# bolshoy_shar
drawer.ellipse((
(int(0.3 * width), int(0.55 * height)),
(int(0.7 * width), int(0.95 * height))),
snowman_color)
# srednii_shar
drawer.ellipse((
(int(0.35 * width), int(0.35 * height)),
(int(0.65 * width), int(0.65 * height))),
snowman_color)
# levui_shar
drawer.ellipse((
(int(0.30 * width), int(0.45 * height)),
(int(0.40 * width), int(0.55 * height))),
snowman_color)
# pravui_shar
drawer.ellipse((
(int(0.60 * width), int(0.45 * height)),
(int(0.70 * width), int(0.55 * height))),
snowman_color)
# maluy_shar
drawer.ellipse((
(int(0.4 * width), int(0.2 * height)),
(int(0.6 * width), int(0.4 * height))),
snowman_color)
im.save(file_name)
picture('res.jpg', 1000, 1000)
2. print(':)')
Вас заинтересует
2 года назад
2 года назад
2 года назад
8 лет назад