Code Search for Developers
 
 
  

paper.py from gzz at Krugle


Show paper.py syntax highlighted

# 
# Copyright (c) 2003, Janne Kujala and Tuomas J. Lukka
# 
# This file is part of Gzz.
# 
# Gzz is free software; you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# 
# Gzz is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
# Public License for more details.
# 
# You should have received a copy of the GNU Lesser General
# Public License along with Gzz; if not, write to the Free
# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA  02111-1307  USA
# 
# 



from gfx.libutil import saveanim
from math import exp
import java

# number of skipped frames
dry = 0

frame = 0

size = {
    "w": 100,
    "h": 100,
}

def _saveframe(w):
    global frame
    if frame > dry:
        saveanim.saveframe("tmpfilm/paper%03i.jpg" % frame, w,
	    **size)
    print "Frame", frame
    frame += 1
    java.lang.System.gc()
    GL.freeQueue()

def saveframe(sc):
    vs = w.createVobScene()
    sc.scene(vs)
    w.renderStill(vs, 0)
    _saveframe(w)

def saveframes(vs1, vs2, n):
    for i in range(0,n):
        fract = i / float(n)
        w.renderAnim(vs1, vs2, fract, 0, 1)
        _saveframe(w)
    
def makeAnim():
    def setFrame(): w.setLocation(0, 0, 1024, 768)
    setFrame()

    if 1:
        execfile("gfx/demo/papertest.py", globals())
        setFrame()
        ps = MultiPaperScene()
        ps.seed = 199871850
        ps.initpaper()

        for i in range(0,100):
            global zoom
            zoom = 900 * exp((i * .015)**2)
            saveframe(ps)

    if 1:
        execfile("gfx/demo/paperbasis.py", globals())

        ps = PaperFlowScene()
        ps.pt.y0 -= .2
        for i in range(0,100):
            ps.pt.x0 += .01
            ps.pt.y0 += sin(i * .00025)
            saveframe(ps)

    if 1:
        execfile("gfx/demo/xupdf.py", globals())
        
        ps = gzz.view.xubuoy.XuPDFScene_PDFContext(xuspace)

        #for i in range(0,48-47):
        #    ps.moveToCell(cells[1], .05 * i, .5)
        #    saveframe(ps)

        vs1 = w.createVobScene()
        ps.moveToCell(cells[1], 0, .5)
        ps.scene(vs1)

        vs2 = w.createVobScene()
        ps.moveToCell(cells[1], 2, .5)
        ps.scene(vs2)
        
        saveframes(vs1, vs2, 100); vs1 = vs2;

        vs2 = w.createVobScene()
        ps.moveToCell(cells[0], .5, .5)
        ps.scene(vs2)

        saveframes(vs1, vs2, 100); vs1 = vs2;

        vs2 = w.createVobScene()
        ps.moveToCell(cells[0], 2, .5)
        ps.scene(vs2)

        saveframes(vs1, vs2, 100); vs1 = vs2;

        vs2 = w.createVobScene()
        ps.moveToCell(cells[2], .5, .5)
        ps.scene(vs2)

        saveframes(vs1, vs2, 100); vs1 = vs2;

        vs2 = w.createVobScene()
        ps.moveToCell(cells[2], 2, .5)
        ps.scene(vs2)

        saveframes(vs1, vs2, 100); vs1 = vs2;

    if frame > dry:
        saveanim.encodefilm("tmpfilm/paper\\*.jpg", "paperfilm.avi")

makeAnim()
currentScene = None




See more files for this project here

gzz

An implementation of Ted Nelson's ZZstructure. ZZstructure is a new type of programming platform for structured data.

Project homepage: http://savannah.nongnu.org/projects/gzz
Programming language(s): C++,Java,Python
License: lgpl21

  fillets.py
  paper.py
  test.py