Advertisement
plarmi

hw_11_1

Oct 25th, 2023 (edited)
817
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. from PIL import Image, ImageDraw
  2. from random import randint, choice
  3.  
  4. WIDTH = randint(500, 1500)
  5. HEIGHT = randint(300, 1300)
  6. WHITE = (255, 255, 255)
  7. COLORS = [(255, 0, 0), (0, 255, 0), (0, 0, 255), (255, 255, 0), (0, 255, 255)]
  8. CIRCLES = randint(1, 20)
  9.  
  10. image = Image.new("RGB", (WIDTH, HEIGHT), WHITE)
  11.  
  12. draw = ImageDraw.Draw(image)
  13.  
  14. for i in range(CIRCLES):
  15.     radius = randint(20, 100)
  16.     x = randint(radius, WIDTH - radius)
  17.     y = randint(radius, HEIGHT - radius)
  18.     draw.ellipse([(x - radius, y - radius), (x + radius, y + radius)], fill=choice(COLORS))
  19.  
  20. image.save("1.png")
  21.  
  22. image.show()
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement