4cade/res/notes/transitions/slowripple.py

74 lines
2.1 KiB
Python
Raw Normal View History

2019-10-21 20:00:38 +00:00
#!/usr/bin/env python3
from math import sqrt, sin, cos, pi
radius_x = 280/2
radius_y = 192/2
def f(t):
2019-10-23 13:33:53 +00:00
return (sqrt(t)*cos(2*pi*sqrt(t)), 0.87*sqrt(t)*sin(2*pi*sqrt(t)))
2019-10-21 20:00:38 +00:00
coords = []
for i in range(1000000):
any = False
a, b = f(float(i)/10.0)
x = round(radius_x+a)
y = round(radius_y+b)
if y % 2 != 0:
continue
if x < 0 or x >= radius_x or y < 0 or y >= radius_y:
continue
coords.append((x,y))
d = {}
unique_coords = []
for c in coords:
if not d.get(c):
unique_coords.append(c)
d[c] = 1
unique_vals = []
for x, y in unique_coords:
aval = "$" + hex(y)[2:].rjust(2, "0").upper()
bval = "%" + \
bin(x%7)[2:].rjust(3, "0") + \
bin(x//7)[2:].rjust(5, "0")
unique_vals.append((aval, bval))
2019-10-21 20:00:38 +00:00
with open("../../../src/fx/fx.hgr.iris.data.a", "w") as f:
for aval, bval in unique_vals:
f.write(" !byte %s,%s\n" % (aval, bval))
unique_vals.reverse()
with open("../../../src/fx/fx.hgr.iris.in.data.a", "w") as f:
for aval, bval in unique_vals:
f.write(" !byte %s,%s\n" % (aval, bval))
unique_vals.reverse()
ripple_vals = []
for i, j, k, l in zip(range(1680), range(1680,3360), range(3360,5040), range(5040,6720)):
ripple_vals.append(unique_vals[i])
ripple_vals.append(unique_vals[j])
ripple_vals.append(unique_vals[k])
ripple_vals.append(unique_vals[l])
2019-10-21 23:07:03 +00:00
with open("../../../src/fx/fx.hgr.ripple.data.a", "w") as f:
for aval, bval in ripple_vals:
2019-10-21 20:00:38 +00:00
f.write(" !byte %s,%s\n" % (aval, bval))
2019-10-25 13:14:25 +00:00
corner4_vals = []
for x, y in unique_coords:
x = 139-x
y = 95-y
aval = "$" + hex(y)[2:].rjust(2, "0").upper()
bval = "%" + \
bin(x%7)[2:].rjust(3, "0") + \
bin(x//7)[2:].rjust(5, "0")
corner4_vals.append((aval, bval))
with open("../../../src/fx/fx.hgr.corner4.in.data.a", "w") as f:
for aval, bval in corner4_vals:
f.write(" !byte %s,%s\n" % (aval, bval))
corner4_vals.reverse()
with open("../../../src/fx/fx.hgr.corner4.out.data.a", "w") as f:
for aval, bval in corner4_vals:
f.write(" !byte %s,%s\n" % (aval, bval))