Advertisement
biswasrohit20

3p

Jun 17th, 2021
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. from PIL import Image, ImageDraw
  2. import math
  3. def create_background(size, color):
  4. r = color[0]
  5. g = color[1]
  6. b = color[2]
  7.  
  8. ri = math.floor((255-r)/size[0])
  9. gi = math.floor((255 - g) / size[0])
  10. bi = math.floor((255 - b) / size[0])
  11. img = Image.new("RGB", size)
  12. pixels = img.load()
  13. for i in range(size[0]):
  14. for j in range(size[1]):
  15. pixels[i,j] = (r,g,b)
  16. r += ri
  17. g += gi
  18. b += bi
  19. return img
  20.  
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement