2 from math import sin, cos, pi
8 elif os.name == ('ce', 'nt', 'dos'):
13 image_l = image.load()
17 initial_angle = (pi / 4) + (dt / 2)
19 matrix = [[0]*size[1] for _ in xrange(size[0])]
21 for x in xrange(size[0]):
23 print "{0}/{1}".format(x + 1, size[0])
24 for y in xrange(size[1]):
27 for a in xrange(size[1]):
29 # distance is the dot product of vector (x, y) - centerpoint
30 # and a unit vector orthogonal to the angle
31 distance = (((x - (size[0] / 2)) * sin((dt * a) + initial_angle)) +
32 ((y - (size[1] / 2)) * -cos((dt * a) + initial_angle)) +
34 column = int(round(distance)) # column of the matrix closest to the distance
35 if column >= 0 and column < size[0]:
36 matrix[column][a] += 1
38 new_image = Image.new('L', size)
39 new_image_l = new_image.load()
41 minimum = min([min(m) for m in matrix])
43 maximum = max([max(m) for m in matrix]) - minimum
45 for y in xrange(size[1]):
46 for x in xrange(size[0]):
47 new_image_l[x, y] = (float(matrix[x][y] - minimum) / maximum) * 255