"Crappy whatever I hate it" edition of Sierpinski triangle

This commit is contained in:
Steven Robertson
2011-04-29 17:25:51 -04:00
parent fe6367821f
commit 1302f31ec7
4 changed files with 140 additions and 29 deletions

47
main.py
View File

@ -25,44 +25,45 @@ import pycuda.autoinit
from cuburn.render import *
from cuburn.code.mwc import test_mwc
from cuburn.code.iter import silly
def main(args):
test_mwc()
return
with open(args[-1]) as fp:
genomes, ngenomes = Genome.from_string(fp.read())
anim = Animation(genomes, ngenomes)
anim.compile()
bins = anim.render_frame()
w, h = anim.features.hist_width, anim.features.hist_height
bins = bins[:,:w]
alpha = bins[...,3]
k2ish = (256./(np.mean(alpha)+1e-9))
lses = 20 * np.log2(1.0 + alpha * k2ish) / (alpha+1e-6)
bins *= lses.reshape(h,w,1).repeat(4,2)
bins = np.minimum(bins, 255)
bins = bins.astype(np.uint8)
genomes = Genome.from_string(fp.read())
anim = Animation(genomes)
if '-g' not in args:
return
accum, den = silly()
if False:
bins = anim.render_frame()
w, h = anim.features.hist_width, anim.features.hist_height
bins = bins[:,:w]
alpha = bins[...,3]
k2ish = (256./(np.mean(alpha)+1e-9))
lses = 20 * np.log2(1.0 + alpha * k2ish) / (alpha+1e-6)
bins *= lses.reshape(h,w,1).repeat(4,2)
bins = np.minimum(bins, 255)
bins = bins.astype(np.uint8)
#if '-g' not in args:
# return
imgbuf = (accum * 255).astype(np.uint8)
window = pyglet.window.Window(1600, 900)
image = pyglet.image.ImageData(anim.features.hist_width,
anim.features.hist_height,
'RGBA',
bins.tostring())
image = pyglet.image.ImageData(512, 512, 'RGBA', imgbuf.tostring())
#-anim.features.hist_stride*4)
tex = image.texture
pal = (anim.ctx.ptx.instances[PaletteLookup].pal * 255.).astype(np.uint8)
image2 = pyglet.image.ImageData(256, 16, 'RGBA', pal.tostring())
#pal = (anim.ctx.ptx.instances[PaletteLookup].pal * 255.).astype(np.uint8)
#image2 = pyglet.image.ImageData(256, 16, 'RGBA', pal.tostring())
@window.event
def on_draw():
window.clear()
tex.blit(0, 0)
image2.blit(0, 0)
#image2.blit(0, 0)
@window.event
def on_key_press(sym, mod):