#!/usr/bin/env python # #Copyright (c) 2007 Andrew Walkingshaw # #Permission is hereby granted, free of charge, to any person #obtaining a copy of this software and associated documentation #files (the "Software"), to deal in the Software without #restriction, including without limitation the rights to use, #copy, modify, merge, publish, distribute, sublicense, and/or sell #copies of the Software, and to permit persons to whom the #Software is furnished to do so, subject to the following #conditions: # #The above copyright notice and this permission notice shall be #included in all copies or substantial portions of the Software. # #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, #EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES #OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND #NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT #HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, #WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR #OTHER DEALINGS IN THE SOFTWARE. # #Compilation instructions: #..\Desktop\MPlayer-mingw32-1.0rc1\mplayer\mencoder.exe -ovc x264 -x264encopts pass=1 -nosound -o faust.avi "mf://*.png" #and #..\Desktop\MPlayer-mingw32-1.0rc1\mplayer\mencoder.exe -ovc x264 -x264encopts pass=2:bitrate=1000 -oac copy -audiofile "C:\Documents and Settings\Andrew Walkingshaw\Desktop\inrainbows\Radiohead - In Rainbows\09 - Radiohead - Jigsaw Falling Into Place.MP3" -o faust.avi "mf://*.png" import Image, ImageDraw import inrgen import modifier9 def main(): division = 0 nframes = int(25 * 8.5)+1 img1 = Image.open( "c:\Documents and Settings\Andrew Walkingshaw\Desktop\cablefront.jpg") img2 = Image.open("terminal1.png") img3 = Image.open("terminal2.png") for step in range(nframes): img = Image.blend(img1, img2, float(step)/nframes) padname = "0"*(4-len(str(step+division*nframes))) + str(step+ division*nframes) img.save("jigsaw/%s.png" % padname, "PNG") division += 1 for step in range(nframes): img = Image.blend(img2, img3, float(step)/nframes) padname = "0"*(4-len(str(step+division*nframes))) + str(step+ division*nframes) img.save("jigsaw/%s.png" % padname, "PNG") division += 1 g = inrgen.Grid(6,30,1,0.1,start=(14,14)) count = 0 thisiter = None for s in xrange(2*nframes): g.mutate() count += 1 fn = str(count) padding = 4-len(fn) fn = "0"*padding+fn thisiter = g.render(img3.size[0], img3.size[1], show=False, backdrop=img3, colours = [(255,0,0), (212,0,0), (170,0,0), (127,0,0), (85,0,0), (42,0,0), (0,0,0)], returnmask=False) padname = "0"*(4-len(str(s+division*nframes))) + str(s+division*nframes) thisiter.save("jigsaw/%s.png" % padname, "PNG") division += 2 cctvtmp = Image.open( "c:\Documents and Settings\Andrew Walkingshaw\Desktop\cctv.jpg") cctv = cctvtmp.crop((0,0,img1.size[0], img1.size[1])) img = None for step in range(nframes): img = Image.blend(thisiter, cctv, float(step)/nframes) padname = "0"*(4-(len(str(step+division*nframes)))) + \ str(step+division*nframes) img.save("jigsaw/%s.png" % padname, "PNG") division+=1 photo = modifier9.Photo(img) ntb = (img.size[0]*img.size[1])/nframes print ntb for s in xrange(1, img.size[0]*img.size[1]): photo.mutatex(s) if s%ntb == 0: padname = "0"*(4-(len(str((s/ntb)+division*nframes)))) + \ str((s/ntb)+division*nframes) img = photo.render() img.save("jigsaw/%s.png" % padname, "PNG") division += 1 grid = img.copy() gridcanvas = ImageDraw.Draw(grid) interval = grid.size[0]/15 x = interval/2 y = interval/2 while x < grid.size[0]: gridcanvas.line([(x,0),(x,grid.size[1])], fill=(0,0,0), width=1) x += interval/2 while y < grid.size[1]: gridcanvas.line([(0,y),(grid.size[0],y)], fill=(0,0,0), width=1) y += interval/2 torender = cctv alternate = nframes/32 s = 0 while s < nframes: if s%alternate==0: if torender==grid: torender=cctv elif torender==cctv: torender=grid padname = "0"*(4-(len(str((s)+division*nframes)))) + \ str((s)+division*nframes) print "grid:", padname torender.save("jigsaw/%s.png" % padname, "PNG") s += 1 division += 1 if __name__ == "__main__": main()