Guest User

Untitled

a guest
Apr 25th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #-*- coding: utf-8 -*-
  2. #!python
  3. import sys
  4. import codecs
  5. import io
  6. from PIL import Image, ImageFont, ImageDraw
  7. import string
  8. digs = []
  9.  
  10. w = 1000
  11. h = w
  12. background = (255, 255, 255)
  13.  
  14. image = Image.new("RGBA", (w, h), background)
  15. pixels = image.load()
  16.  
  17. def int2base(x, base):
  18. digits = []
  19.  
  20. while x:
  21. digits.append(int(x % base))
  22. x = int(x / base)
  23.  
  24. digits.reverse()
  25.  
  26. return digits
  27.  
  28. def is_base_zeroes_ones_only(i, j):
  29. if i in [0, 1]:
  30. return True
  31. s = int2base(i, j)
  32. #print(s)
  33. for c in s:
  34. if(c != 0 and c!= 1):
  35. return False
  36. return True
  37.  
  38. for i in range(0, w):
  39. for j in range(2, h):
  40. if(is_base_zeroes_ones_only(i, j)):
  41. pixels[i, j] = (0, 0, 0, 255)
  42.  
  43.  
  44. image.save("image.png")
Add Comment
Please, Sign In to add comment