Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # -*- coding: utf-8 -*-
- # To launch the file : python <thisfile>.py
- # or ./<thisfile>.py with exec rigths given to the script
- from PIL import Image
- import sys, math
- DEBUG = True # False or True
- # Thanks to C-sharp anon, i didnt have to write them by hand :D
- RSA100c = 1522605027922533360535618378132637429718068114961380688657908494580122963258952897654000350692006139
- RSA100a = 37975227936943673922808872755445627854565536638199
- RSA100b = 40094690950920881030683735292761468389214899724061
- RSA100d = 39020571855401265512289573339484371018905006900194
- RSA100e = 61218444075812733697456051513875809617598014768503
- RSA100f = 16822699634989797327123095165092932420211999031886
- RSA100n = 14387588531011964456730684619177102985211280936
- RSA100x = 1045343918457591589480700584038743164339470261995
- RSA100x_plus_n = 1059731506988603553937431268657920267324681542931
- # Not used. Using d=int(math.floor(math.sqrt(c))) instead
- # Maybe check later if python not able to handle big number
- # But no reason so far
- def bigIntegerSqrt(bigint):
- n = 0; p = 0
- if bigint == 0 : return 0
- high = bigint >> 1; low = 0
- while high > (low + 1):
- n = (high + low) >> 1
- p = n * n
- if bigint < p:
- high = n
- elif bigint > p:
- low = n
- else:
- break
- if bigint == p:
- return n
- else:
- return low
- def createTheEnd(path, theend, i_max=256, x_min=0, y_min=0, x_max=128, y_max=128):
- global DEBUG
- # Thanks to the other Anon, you saved me a lot of time :)
- if DEBUG: print "Starting constructing TheEnd"
- for i in range(0,i_max):
- if DEBUG : print "Constructing for i=",i
- for j in range(0,i):
- # Variable computation
- # using ; to compress the code
- a = i - j ; b = i + j ; c = a * b ; odd = True if (c%2) == 1 else False
- d = int(math.floor(math.sqrt(c))) ; e = c - (d**2) ; f = e - ((2 * d) + 1)
- n = i - d ; x = d - a
- if odd :
- t = (x +2) / 2
- else:
- t = (x +1) / 2
- # TheEnd entry adding
- if e not in theend.keys(): theend[e] = {}
- if n not in theend[e].keys():
- theend[e][n] = []
- # Basic white coloring
- # pixels[e,n] = (255,255,255)
- if f not in theend.keys(): theend[f] = {}
- if n-1 not in theend[f].keys(): theend[f][n-1] = []
- # CSV entry adding
- theend[e][n].append("{"+str(e)+":"+str(t)+":"+str(n)+":"+str(d)+":"+str(x)+":"+str(a)+":"+str(b)+"}")
- theend[f][n-1].append("{"+str(f)+":"+str(n-1)+":"+str(t)+":"+str(d+1)+":"+str(x+1)+":"+str(a,)+":"+str(b)+"}")
- if DEBUG: print "TheEnd has been constructed"
- def outputTheEnd(path, theend, i_max=256, x_min=-128, y_min=0, set_size=12, x_max=128, y_max=128):
- global DEBUG
- f = open(path+"output.csv", 'w')
- img = Image.new('RGB', (300, 300), "black")
- pixels = img.load() # create the pixel map
- if DEBUG: print ".csv file opened & image base created"
- for y in range(y_min, y_max):
- for z in range(0, set_size):
- for x in range(x_min, x_max):
- if (x in theend.keys()) and (y in theend[x].keys()) and len(theend[x][y]) > z:
- f.write(theend[x][y][z]+",")
- values = theend[x][y][z][1:-1].split(":")
- xx = int(values[3])
- a = int(values[4])
- b = int(values[5])
- pixels[x + x_max, y] = (xx * 255 / i_max, a * 255 / (i_max * 2), b * 255 / (i_max * 4))
- else:
- f.write("{},")
- pass
- f.write('\n')
- if DEBUG: print "Image & .csv generation done"
- f.close()
- #img.show()
- img.save(path+"output.bmp")
- if __name__ == '__main__':
- theend = {}
- # To change accordingly to he folder where you want to save stuff
- path = "~/"
- createTheEnd(path, theend)
- outputTheEnd(path, theend)
- if DEBUG : print "Done!!"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement