Guest User

Untitled

a guest
Dec 18th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. from collections import defaultdict
  2. import sys
  3.  
  4. picture = defaultdict(lambda: [0,0,0])
  5.  
  6. def xytoij(xy):
  7. x = xy.real
  8. y = xy.imag
  9. return int((x + 2)/3.0 * 1024), int((y + 1) / 2.0 * 768)
  10.  
  11. i = 0+1j
  12. x = -3
  13. while x < 1:
  14. x += .001
  15. y = -1
  16. while y < 1:
  17. y += .001
  18. c = x + y * i
  19. if abs(c) > 2:
  20. picture[xytoij(c)][2] += 127
  21. z = 0
  22. for _ in range(256):
  23. z = z*z + c
  24. #print >>sys.stderr, z, xytoij(z)
  25. picture[xytoij(z)][0] += 1
  26. if abs(z) >= 2:
  27. picture[xytoij(c)][1] += 100
  28. picture[xytoij(c)][2] += 100
  29. break
  30.  
  31.  
  32.  
  33. print "P3"
  34. print "1024 768"
  35. print "255"
  36. for j in range(768):
  37. for i in range(1024):
  38. r = min(255, int(picture[i,j][0]))
  39. g = int(picture[i,j][1])
  40. b = int(picture[i,j][2])
  41. print r,g,b,
  42. print
Add Comment
Please, Sign In to add comment