|
|
|
|
tex = GL.createTexture() |
|
|
|
|
|
#tex.shade(128, 128, 0, 4, "RGBA", "RGBA", |
|
|
# "sawnoise", ["bias", ".5", |
|
|
# "scale", "0.15", "freq", "1", "df", "2", |
|
|
# "scale2", "0.25", "freq2", "10", "df2", ".5"]) |
|
|
|
|
1 |
ripple_scale = .25 |
ripple_scale = .25 |
|
tex.shade_all_levels(128, 128, 0, 4, "RGBA", "RGBA", |
|
|
"irregu", ["radius", "2", str(ripple_scale), "0.25", |
|
|
"scale", ".25", "bias", ".75", "eps", ".125"]) |
|
2 |
|
|
3 |
|
args = ["radius", "2", str(ripple_scale), "0.25", |
4 |
|
"scale", ".25", "bias", ".75", "eps", ".125"] |
5 |
|
|
6 |
|
tex = GL.createTexture() |
7 |
|
texinv = GL.createTexture() |
8 |
|
tex.shade_all_levels(128, 128, 0, 4, "RGBA", "RGBA", "irregu", args) |
9 |
|
texinv.shade_all_levels(128, 128, 0, 4, "RGBA", "RGBA", "irregu", args + |
10 |
|
["invert", "1"]) |
11 |
|
|
12 |
|
|
|
e = 0.5 |
|
13 |
|
|
|
texid = tex.getTexId() |
|
14 |
|
|
15 |
|
|
16 |
# alpha(y) = e / y * f >= e |
# alpha(y) = e / y * f >= e |
17 |
# y <= f |
# y <= f |
18 |
|
|
19 |
irr = getDList(""" |
def getirr(texid): |
20 |
|
e = 0.5 |
21 |
|
return getDList(""" |
22 |
PushAttrib ENABLE_BIT |
PushAttrib ENABLE_BIT |
23 |
|
|
24 |
BindTexture TEXTURE_2D %(texid)s |
BindTexture TEXTURE_2D %(texid)s |
163 |
""" % vars()) |
""" % vars()) |
164 |
|
|
165 |
|
|
166 |
|
irr = getirr(tex.getTexId()) |
167 |
|
irrinv = getirr(texinv.getTexId()) |
168 |
|
|
169 |
|
|
170 |
|
|
171 |
|
|
172 |
def getIrregu(x0, y0, x1, y1, s0, t0, s1, t1): |
def getIrregu(x0, y0, x1, y1, s0, t0, s1, t1): |
173 |
tlen = sqrt((s1 - s0)**2 + (t1 - t0)**2) |
tlen = sqrt((s1 - s0)**2 + (t1 - t0)**2) |
174 |
len = sqrt((x1 - x0)**2 + (y1 - y0)**2) |
len = sqrt((x1 - x0)**2 + (y1 - y0)**2) |
177 |
class IrreguScene: |
class IrreguScene: |
178 |
def __init__(self): |
def __init__(self): |
179 |
self.scale = 128 |
self.scale = 128 |
180 |
|
self.dist = 1 |
181 |
|
|
182 |
def scene(self, vs): |
def scene(self, vs): |
183 |
putnoc(vs, background((0.7,0.7,1.0))) |
putnoc(vs, background((0.7,0.7,1.0))) |
184 |
|
|
185 |
cs1 = vs.coords.affineCoordsys(0, 0, 512, 384, self.scale, 0, 0, -2*ripple_scale*self.scale) |
cs1 = vs.coords.affineCoordsys(0, 0, 512, 384, self.scale, 0, 0, -2*ripple_scale*self.scale) |
186 |
|
cs2 = vs.coords.affineCoordsys(0, 0, 512, 384-self.dist*self.scale, self.scale, 0, 0, 2*ripple_scale*self.scale) |
187 |
vs.matcher.add(cs1, "1") |
vs.matcher.add(cs1, "1") |
188 |
|
vs.matcher.add(cs2, "2") |
189 |
|
|
190 |
vs.map.put(irr, cs1) |
vs.map.put(irr, cs1) |
191 |
|
vs.map.put(irrinv, cs2) |
192 |
|
|
193 |
def key(self, k): |
def key(self, k): |
194 |
if k == "+": self.scale *= 1.4142135623731; print round(self.scale) |
if k == "+": self.scale *= 1.4142135623731; print round(self.scale) |
195 |
if k == "-": self.scale /= 1.4142135623731; print round(self.scale) |
if k == "-": self.scale /= 1.4142135623731; print round(self.scale) |
196 |
|
if k == "Up": self.dist *= 1.1 |
197 |
|
if k == "Down": self.dist /= 1.1 |
198 |
|
|
199 |
currentScene = IrreguScene() |
currentScene = IrreguScene() |