Advertisement
yclee126

RePixelator icon generator

Oct 9th, 2021 (edited)
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. import numpy as np
  2. import cv2
  3. import subprocess
  4.  
  5. sizes = (16, 32, 64, 128, 256)
  6. for size in sizes:
  7. x, y = size, size
  8. img = np.zeros((x*y), dtype='uint8')
  9.  
  10. for i in range(y):
  11. for j in range(x):
  12. if j < x/2:
  13. f = i/y
  14. img[i*y+j] = int((4*f**3 if f < 0.5 else 1-(-2*f+2)**3/2)*256) # cubic ease function
  15. else:
  16. img[i*y+j] = 255 if i < y/2 else 0
  17.  
  18. img = np.reshape(img, (x, y))
  19. cv2.imwrite(f'icon-{size}.png', img)
  20.  
  21. icons = [f'icon-{i}.png' for i in sizes]
  22. subprocess.run(['magick'] + icons + ['icon.ico'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement