Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. """
  4. Created on Tue Jul 9 09:17:05 2019
  5. @author: timallan
  6. """
  7.  
  8.  
  9. from PIL import Image, ImageDraw
  10. import random
  11.  
  12. im = Image.open('/Users/timallan/Desktop/whiteFang/01_ASSETS/__IMAGES/_DL/northernLights_1920x1080.png')
  13. #im = Image.new('RGB', (640, 480), (255, 255, 255))
  14.  
  15.  
  16. w, h = im.size
  17.  
  18. pixelTotal = w * h
  19. pixelTarget = int(pixelTotal * 0.41)
  20.  
  21.  
  22. pointTotal = 1
  23. x_pos = 0
  24. width_adjust = 184
  25.  
  26. flip = False
  27.  
  28. draw = ImageDraw.Draw(im)
  29.  
  30. while pointTotal <= pixelTarget:
  31. y_length = random.randrange(0, h - width_adjust)
  32.  
  33. for y in range(y_length):
  34.  
  35. if pointTotal <= pixelTarget:
  36.  
  37. if flip:
  38. draw.point((x_pos, y), fill = ('white'))
  39. pointTotal += 1
  40.  
  41. else:
  42. draw.point((x_pos, h - y), fill = ('white'))
  43. pointTotal += 1
  44.  
  45. x_pos += 1
  46. flip = not flip
  47.  
  48.  
  49. print(pointTotal, pixelTarget, pixelTotal)
  50.  
  51.  
  52. del draw
  53.  
  54.  
  55. im.save('/Users/timallan/Desktop/whiteFang/01_ASSETS/__IMAGES/_DL/northernLights_1920x1080_VERT_ALTERNATE_01.png', 'PNG')
  56. im.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement