Advertisement
sphinx2001

draw ship

Feb 13th, 2021
729
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.02 KB | None | 0 0
  1. from PIL import Image, ImageDraw
  2.  
  3.  
  4. def picture(file_name, width, height, sky_color='#87CEEB', ocean_color='#017B92',
  5.             boat_color='#874535', sail_color='#FFFFFF', sun_color='#FFDB00'):
  6.     w = width
  7.     h = height
  8.     im = Image.new('RGB', (w, h), sky_color)
  9.     d = ImageDraw.Draw(im)
  10.     d.rectangle([(0, int(0.8 * h)), (w, h)], fill=ocean_color)
  11.     d.ellipse([(int(0.8 * w), -int(0.2 * h)), (int(1.2 * w), int(0.2 * h))], fill=sun_color)
  12.     coords = [(int(0.51 * w), int(0.3 * h)),
  13.               (int(0.51 * w), int(0.6 * h)),
  14.               (int(0.66 * w), int(0.45 * h))]
  15.     d.polygon(coords, fill=sail_color)
  16.     coords = [(int(0.49 * w), int(0.3 * h)),
  17.               (int(0.51 * w), int(0.65 * h))]
  18.     d.rectangle(coords, fill=boat_color)
  19.     coords = [(int(0.25 * w), int(0.65 * h)),
  20.               (int(0.75 * w), int(0.65 * h)),
  21.               (int(0.7 * w), int(0.85 * h)),
  22.               (int(0.3 * w), int(0.85 * h))]
  23.     d.polygon(coords, fill=boat_color)
  24.     im.save(file_name)
  25.     im.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement