[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz/gfx demo/irregu3.py libtexture/irregu.texture
From: |
Janne V. Kujala |
Subject: |
[Gzz-commits] gzz/gfx demo/irregu3.py libtexture/irregu.texture |
Date: |
Mon, 21 Oct 2002 13:37:09 -0400 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Janne V. Kujala <address@hidden> 02/10/21 13:37:09
Modified files:
gfx/demo : irregu3.py
gfx/libtexture : irregu.texture
Log message:
Add interpolation between stored angles; reduces the distortion
resolution even more, now there are only about 32 levels in worst case
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/irregu3.py.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libtexture/irregu.texture.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
Patches:
Index: gzz/gfx/demo/irregu3.py
diff -u gzz/gfx/demo/irregu3.py:1.9 gzz/gfx/demo/irregu3.py:1.10
--- gzz/gfx/demo/irregu3.py:1.9 Mon Oct 21 08:53:56 2002
+++ gzz/gfx/demo/irregu3.py Mon Oct 21 13:37:08 2002
@@ -1,3 +1,5 @@
+from math import sin,cos,sqrt,pi
+
ripple_scale = .25
args = ["radius", "2", str(ripple_scale), "0.25",
@@ -10,13 +12,35 @@
["invert", "1"])
+# alpha(y) = e / y * f >= e
+# y <= f
+def lerp(a, b, f):
+ return [ (1-f) * a[i] + f * b[i] for i in range(0, len(a)) ]
+
+def getirr(texid, angle, pos):
-# alpha(y) = e / y * f >= e
-# y <= f
+ texmat = js([
+ cos(angle), sin(angle), 0, 0,
+ -sin(angle), cos(angle), 0, 0,
+ 0, 0, 1, 0,
+ sin(angle)*pos, cos(angle)*pos, 0, 1,
+ ])
+
+ col0l = [ (1.0,0.5,0.5), (0.5,0.5,1.0), (0.5,1.0,0.5), (1.0,0.5,0.5) ]
+ col1l = [ (.75,0.5,0.5), (0.5,0.5,.75), (0.5,.75,0.5), (.75,0.5,0.5) ]
+
+ a = angle * 6 / (2 * pi)
+ while a < 0: a+=3
+ i = int(a) % 3
+ f = a - int(a)
+
+ col0 = js(lerp(col0l[i], col0l[i+1], f))
+ col1 = js(lerp(col1l[i], col1l[i+1], f))
+
+ #print col0, col1
-def getirr(texid):
e = 0.5
return getDList("""
PushAttrib ENABLE_BIT
@@ -83,25 +107,25 @@
#TexEnv TEXTURE_ENV OPERAND1_ALPHA_ARB SRC_ALPHA
MatrixMode TEXTURE
- LoadMatrix 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
+ LoadMatrix %(texmat)s
MatrixMode MODELVIEW
Begin QUAD_STRIP
TexCoord 0 0 0 1
- Color 1 .5 .5
+ Color %(col0)s
Vertex 0 %(e)s 0 1
TexCoord 0 0 0 %(e)s
- Color .75 .5 .5
+ Color %(col1)s
Vertex 0 %(e)s 0 %(e)s
TexCoord 1 0 0 1
- Color 1 .5 .5
+ Color %(col0)s
Vertex 1 %(e)s 0 1
TexCoord %(e)s 0 0 %(e)s
- Color .75 .5 .5
+ Color %(col1)s
Vertex %(e)s %(e)s 0 %(e)s
End
@@ -163,9 +187,6 @@
""" % vars())
-irr = getirr(tex.getTexId())
-irrinv = getirr(texinv.getTexId())
-
@@ -178,6 +199,8 @@
def __init__(self):
self.scale = 128
self.dist = 1
+ self.angle = 0
+ self.pos = 0
def scene(self, vs):
putnoc(vs, background((0.7,0.7,1.0)))
@@ -187,13 +210,21 @@
vs.matcher.add(cs1, "1")
vs.matcher.add(cs2, "2")
+ irr = getirr(tex.getTexId(), self.angle, self.pos)
+ irrinv = getirr(texinv.getTexId(), self.angle, self.pos)
+
vs.map.put(irr, cs1)
vs.map.put(irrinv, cs2)
def key(self, k):
if k == "+": self.scale *= 1.4142135623731; print round(self.scale)
if k == "-": self.scale /= 1.4142135623731; print round(self.scale)
- if k == "Up": self.dist *= 1.1
- if k == "Down": self.dist /= 1.1
+ if k == "Prior": self.dist *= 1.1
+ if k == "Next": self.dist /= 1.1
+ if k == "Up": self.pos -= 1./128
+ if k == "Down": self.pos += 1./128
+ if k == "Left": self.angle -= pi/180
+ if k == "Right": self.angle += pi/180
+ print "angle",round(self.angle / pi * 180)
currentScene = IrreguScene()
Index: gzz/gfx/libtexture/irregu.texture
diff -u gzz/gfx/libtexture/irregu.texture:1.5
gzz/gfx/libtexture/irregu.texture:1.6
--- gzz/gfx/libtexture/irregu.texture:1.5 Mon Oct 21 08:53:56 2002
+++ gzz/gfx/libtexture/irregu.texture Mon Oct 21 13:37:08 2002
@@ -6,10 +6,10 @@
#define INVERT(i, x) ((i) + 2 * (0.5 - (i)) * (x))
float func(float x, float y) {
- float t = x*10;
- float u = y*10;
- return .5 + .2 * sin(x*M_PI*2*4) - .2*(t-floor(t)) + .2*sin(y*M_PI*2)
- + .2*(u-floor(u));
+ float t = x*5;
+ float u = y*7;
+ return .5 + .1 * sin(x*M_PI*2*4) - .1*(t-floor(t)) + .1*sin(y*M_PI*2)
+ - .1*(u-floor(u));
}
float filter(float *data, int w, int h, int c, float x, float y) {
- [Gzz-commits] gzz/gfx demo/irregu3.py libtexture/irregu.texture, Janne V. Kujala, 2002/10/21
- [Gzz-commits] gzz/gfx demo/irregu3.py libtexture/irregu.texture, Janne V. Kujala, 2002/10/21
- [Gzz-commits] gzz/gfx demo/irregu3.py libtexture/irregu.texture, Janne V. Kujala, 2002/10/21
- [Gzz-commits] gzz/gfx demo/irregu3.py libtexture/irregu.texture,
Janne V. Kujala <=
- [Gzz-commits] gzz/gfx demo/irregu3.py libtexture/irregu.texture, Janne V. Kujala, 2002/10/22
- [Gzz-commits] gzz/gfx demo/irregu3.py libtexture/irregu.texture, Janne V. Kujala, 2002/10/25
- [Gzz-commits] gzz/gfx demo/irregu3.py libtexture/irregu.texture, Janne V. Kujala, 2002/10/25
- [Gzz-commits] gzz/gfx demo/irregu3.py libtexture/irregu.texture, Janne V. Kujala, 2002/10/28
- [Gzz-commits] gzz/gfx demo/irregu3.py libtexture/irregu.texture, Janne V. Kujala, 2002/10/29
- [Gzz-commits] gzz/gfx demo/irregu3.py libtexture/irregu.texture, Janne V. Kujala, 2002/10/29