Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PIL import Image, ImageDraw
- def picture(file_name, width, height, sky_color='#87CEEB', ocean_color='#017B92',
- boat_color='#874535', sail_color='#FFFFFF', sun_color='#FFDB00'):
- w = width
- h = height
- im = Image.new('RGB', (w, h), sky_color)
- d = ImageDraw.Draw(im)
- d.rectangle([(0, int(0.8 * h)), (w, h)], fill=ocean_color)
- d.ellipse([(int(0.8 * w), -int(0.2 * h)), (int(1.2 * w), int(0.2 * h))], fill=sun_color)
- coords = [(int(0.51 * w), int(0.3 * h)),
- (int(0.51 * w), int(0.6 * h)),
- (int(0.66 * w), int(0.45 * h))]
- d.polygon(coords, fill=sail_color)
- coords = [(int(0.49 * w), int(0.3 * h)),
- (int(0.51 * w), int(0.65 * h))]
- d.rectangle(coords, fill=boat_color)
- coords = [(int(0.25 * w), int(0.65 * h)),
- (int(0.75 * w), int(0.65 * h)),
- (int(0.7 * w), int(0.85 * h)),
- (int(0.3 * w), int(0.85 * h))]
- d.polygon(coords, fill=boat_color)
- im.save(file_name)
- im.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement