yazdmich

Untitled

Oct 10th, 2014
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.39 KB | None | 0 0
  1. from PIL import Image
  2. from math import radians, degrees, cos, sin
  3. from IPython.core import display
  4. from io import BytesIO
  5. from os import chdir
  6.  
  7. img = Image.new( 'RGB', (721,721), "white") # create a new white image
  8. pixels = img.load() # create the pixel map
  9.  
  10. class cart:
  11.     def __init__(self, x, y, z):
  12.         self.x = zeros(x, dtype = int16)
  13.         self.y = zeros(y, dtype = int16)
  14.         self.z = zeros(z, dtype = int16)
  15.  
  16. maps = array([cart(721, 721, 721) for x in range(720)])
  17.  
  18. midx, midy = 360, 360
  19. for q in range(1,721):
  20.     for s in range(1,361):
  21.         for t in range(1,361):
  22.             #print(s,t,q)
  23.             maps[q].x[t] = (cos(radians(s)) * t) + 350
  24.             maps[q].y[t] = (sin(radians(t)) * s) + 350
  25.             maps[q].z[t] = s
  26.            
  27.             x = maps[q].x[t] - 350
  28.             z = maps[q].z[t]
  29.             x = round(cos(radians(q/2)) * x - sin(radians(q/2)) * z)
  30.            
  31.             maps[q].x[t] = x + midx
  32.             maps[q].x[t] = min(max(maps[q].x[t], 0), 720)
  33.             maps[q].y[t] = min(max(maps[q].y[t], 0), 720)
  34.            
  35.             #print(int(maps[q].x[t]), int(maps[q].y[t]))
  36.             pixels[abs(int(maps[q].x[t])), abs(int(maps[q].y[t]))] = (t%s, s%t, s^t)
  37.    
  38.     print(q)
  39.     img = img.rotate(180)
  40.     img.save('image{0}.png'.format(q), 'png')
  41.     img = Image.new( 'RGB', (721,721), "white")
  42.     pixels = img.load()
Advertisement
Add Comment
Please, Sign In to add comment