[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz/gfx/demo paperbasis.py
From: |
Tuomas J. Lukka |
Subject: |
[Gzz-commits] gzz/gfx/demo paperbasis.py |
Date: |
Mon, 25 Nov 2002 14:15:22 -0500 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Tuomas J. Lukka <address@hidden> 02/11/25 14:15:20
Modified files:
gfx/demo : paperbasis.py
Log message:
Generalize a little
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/paperbasis.py.diff?tr1=1.16&tr2=1.17&r1=text&r2=text
Patches:
Index: gzz/gfx/demo/paperbasis.py
diff -u gzz/gfx/demo/paperbasis.py:1.16 gzz/gfx/demo/paperbasis.py:1.17
--- gzz/gfx/demo/paperbasis.py:1.16 Mon Nov 25 09:16:07 2002
+++ gzz/gfx/demo/paperbasis.py Mon Nov 25 14:15:20 2002
@@ -22,14 +22,6 @@
if k == "d":
global dbg
dbg = not dbg
- """
- if k >= "F5" and k <= "F8":
- i = int(k[1]) - 5
- global passmask
- passmask[i] = not passmask[i]
- print passmask
- currentScene.initpaper()
- """
tex0codes = {
"RGB" : nvcode.parseCombiner("""
@@ -145,11 +137,7 @@
""")
}
-tex0comb = "RGB"
-tex1comb = "RGB"
-isectcomb = "BAND0"
-
-def getpaper(vecs, cols):
+def getpaper(vecs, cols, tex0comb, isectcomb, tex1comb):
pap = Paper()
pap.setNPasses(1)
ppass = pap.getPass(0)
@@ -205,20 +193,14 @@
rng = java.util.Random()
-class PaperRegcombScene:
- pass
-
-class PaperScene:
+class PaperTemplate:
def __init__(self):
- self.bgcolor = (0.7, 0.8, 0.6)
-
self.vecseed0 = 0
- self.vecseed1 = 0
- self.colseed = 0
+ self.vecseed1 = 1
+ self.colseed = 2
self.initvecs()
self.initcols()
- self.initpaper()
self.x0, self.y0 = 600, 450
self.x1, self.y1 = 600, 600
@@ -236,7 +218,6 @@
Vertex 1 -1
End
""")
-
def initvecs(self):
colors = Colors(self.vecseed0)
r0 = colors.getNVDP3VecStr(0)
@@ -251,31 +232,22 @@
self.cols = [ colors.getColorStr(colorbase+i)
for i in range(0,4) ]
- def initpaper(self):
- self.pq = getpaper(self.vecs, self.cols)
- AbstractUpdateManager.setNoAnimation()
-
def key(self, k):
- global tex0comb,tex1comb,isectcomb
if k == "v":
self.vecseed0 = rng.nextInt(2000000000)
self.vecseed1 = rng.nextInt(2000000000)
self.colseed = rng.nextInt(2000000000)
self.initvecs()
self.initcols()
- self.initpaper()
elif k == "1":
self.vecseed0 = rng.nextInt(2000000000)
self.initvecs()
- self.initpaper()
elif k == "3":
self.vecseed1 = rng.nextInt(2000000000)
self.initvecs()
- self.initpaper()
elif k == "2":
self.colseed = rng.nextInt(2000000000)
self.initcols()
- self.initpaper()
elif k == "F4":
self.texgen0 = TexGenXYRepeatUnit(rnd=rng)
elif k == "F5":
@@ -284,68 +256,79 @@
elif k == "Down": self.y0 += 20
elif k == "Left": self.x0 -= 20
elif k == "Right": self.x0 += 20
- elif k == "F1":
- list = tex0codes.keys()
- tex0comb = list[(list.index(tex0comb) + 1) % len(list)]
- print "Using", tex0comb, isectcomb, tex1comb, "combiners"
- print tex0codes[tex0comb]
- self.initpaper()
- elif k == "F3":
- list = tex1codes.keys()
- tex1comb = list[(list.index(tex1comb) + 1) % len(list)]
- print "Using", tex0comb, isectcomb, tex1comb, "combiners"
- print tex1codes[tex1comb]
- self.initpaper()
- elif k == "c":
- list = isectcodes.keys()
- list.sort()
- isectcomb = list[(list.index(isectcomb) + 1) % len(list)]
- print "Using", tex0comb, isectcomb, tex1comb, "combiners"
- print isectcodes[isectcomb]
- self.initpaper()
- elif k == "C":
- list = isectcodes.keys()
- list.sort()
- isectcomb = list[(list.index(isectcomb) - 1) % len(list)]
- print "Using", tex0comb, isectcomb, tex1comb, "combiners"
- self.initpaper()
-
- def scene(self, vs):
- if not self.pq: self.initpaper()
- putnoc(vs, background(self.bgcolor))
-
- def scene(self, vs):
- if not self.pq: self.initpaper()
- putnoc(vs, background(self.bgcolor))
+
+ def place(self, vs, into, t1, c, t2):
+ pq = getpaper(self.vecs, self.cols, t1, c, t2)
+
# cs1 and cs2 specify the mapping from the texture coords
# [0,1] x [0,1] to vertex coords, cs1 is for the first texture unit
# and cs2 for the second
scale = 400
- cs1 = vs.coords.affineCoordsys(0, 10, self.x0, self.y0,
+ cs1 = vs.coords.affineCoordsys(into, 10, self.x0, self.y0,
scale * self.texgen0.vecs[0][0],
scale * self.texgen0.vecs[1][0],
scale * self.texgen0.vecs[0][1],
scale * self.texgen0.vecs[1][1])
vs.matcher.add(cs1, "1")
- cs2 = vs.coords.affineCoordsys(0, 10, self.x1, self.y1,
+ cs2 = vs.coords.affineCoordsys(into, 10, self.x1, self.y1,
scale * self.texgen1.vecs[0][0],
scale * self.texgen1.vecs[1][0],
scale * self.texgen1.vecs[0][1],
scale * self.texgen1.vecs[1][1])
vs.matcher.add(cs2, "2")
- vs.map.put(self.pq, cs1, cs2)
+ vs.map.put(pq, cs1, cs2)
vs.map.put(self.frame, cs1)
vs.map.put(self.frame, cs2)
+class PaperScene:
+ def __init__(self):
+ self.bgcolor = (0.7, 0.8, 0.6)
+ self.pt = PaperTemplate()
+ self.tex0comb = "RGB"
+ self.isectcomb = "BAND0"
+ self.tex1comb = "RGB"
+ def key(self, k):
+ if k == "F1":
+ list = tex0codes.keys()
+ self.tex0comb = list[(list.index(self.tex0comb) + 1) % len(list)]
+ print "Using", self.tex0comb, self.isectcomb, self.tex1comb,
"combiners"
+ print tex0codes[self.tex0comb]
+ AbstractUpdateManager.setNoAnimation()
+ elif k == "F3":
+ list = tex1codes.keys()
+ self.tex1comb = list[(list.index(self.tex1comb) + 1) % len(list)]
+ print "Using", self.tex0comb, self.isectcomb, self.tex1comb,
"combiners"
+ print tex1codes[self.tex1comb]
+ AbstractUpdateManager.setNoAnimation()
+ elif k == "c":
+ list = isectcodes.keys()
+ list.sort()
+ self.isectcomb = list[(list.index(self.isectcomb) + 1) % len(list)]
+ print "Using", self.tex0comb, self.isectcomb, self.tex1comb,
"combiners"
+ print isectcodes[self.isectcomb]
+ AbstractUpdateManager.setNoAnimation()
+ elif k == "C":
+ list = isectcodes.keys()
+ list.sort()
+ self.isectcomb = list[(list.index(self.isectcomb) - 1) % len(list)]
+ AbstractUpdateManager.setNoAnimation()
+ else:
+ self.pt.key(k)
+
+ def scene(self, vs):
+ putnoc(vs, background(self.bgcolor))
+
+ self.pt.place(vs, 0, self.tex0comb, self.isectcomb, self.tex1comb)
+
for i in range(0,3):
cs = vs.coords.affineCoordsys(0, 10, 600 + (i-1)*150, 80, 50, 0,
0, 50)
vs.matcher.add(cs, "col" + str(i))
- col = self.cols[i].split()
+ col = self.pt.cols[i].split()
cq = coloredQuad((col[0], col[1], col[2]))
vs.map.put(cq, cs)
- vs.map.put(self.frame, cs)
+ vs.map.put(self.pt.frame, cs)
currentScene = PaperScene()
- [Gzz-commits] gzz/gfx/demo paperbasis.py, Janne V. Kujala, 2002/11/25
- [Gzz-commits] gzz/gfx/demo paperbasis.py,
Tuomas J. Lukka <=
- [Gzz-commits] gzz/gfx/demo paperbasis.py, Tuomas J. Lukka, 2002/11/26
- [Gzz-commits] gzz/gfx/demo paperbasis.py, Tuomas J. Lukka, 2002/11/26
- [Gzz-commits] gzz/gfx/demo paperbasis.py, Tuomas J. Lukka, 2002/11/26
- [Gzz-commits] gzz/gfx/demo paperbasis.py, Janne V. Kujala, 2002/11/26
- [Gzz-commits] gzz/gfx/demo paperbasis.py, Janne V. Kujala, 2002/11/26
- [Gzz-commits] gzz/gfx/demo paperbasis.py, Tuomas J. Lukka, 2002/11/26
- [Gzz-commits] gzz/gfx/demo paperbasis.py, Janne V. Kujala, 2002/11/26