WedgeImpl.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Michael Plass, February 3, 1986 12:24:59 pm PST
DIRECTORY Random, Real, RealFns;
WedgeImpl: CEDAR PROGRAM IMPORTS Random, Real, RealFns
~
BEGIN
a, b, c, d: REAL ← 0;
nlevels: INT ← 256;
noiseAmp: REAL ← 1.0;
Noise:
PROC
RETURNS [
REAL] ~ {
RETURN [Random.ChooseInt[min: -9999, max: 9999]*noiseAmp/(10000.0*nlevels)]
};
LinearX:
PROC [x, y:
REAL]
RETURNS [
REAL] ~ {
RETURN [a*x+b*(1-x)+Noise[]]};
LinearY:
PROC [x, y:
REAL]
RETURNS [
REAL] ~ {
a = intensity at top.
b = intensity at bottom.
RETURN [a*y+b*(1-y)+Noise[]]
};
Constant:
PROC [x, y:
REAL]
RETURNS [
REAL] ~ {
RETURN [a]};
QuadY:
PROC [x, y:
REAL]
RETURNS [
REAL] ~ {
a = intensity at top.
b = intensity at bottom.
c proportial to extra intensity at middle.
w: REAL ~ a*y+b*(1-y)+c*y*(1-y);
RETURN [w+Noise[]]
};
CosY:
PROC [x, y:
REAL]
RETURNS [
REAL] ~ {
nRep: REAL ← a;
RETURN [RealFns.Cos[(y*2-1)*3.14159*nRep]/2+0.5+Noise[]]
};
Vignette:
PROC [x, y:
REAL]
RETURNS [
REAL] ~ {
innerRadius: REAL ← a;
outerRadius: REAL ← b;
vinvert: BOOLEAN ← c < 0;
r, phase, level: REAL;
x ← x*2-1;
y ← y*2-1;
r ← Real.SqRt[x*x + y*y];
SELECT r
FROM
<= innerRadius => level ← 1;
>= outerRadius => level ← 0;
ENDCASE => {
phase ← 3.14159*(r-innerRadius)/(outerRadius-innerRadius);
level ← RealFns.Cos[phase]/2+0.5+Noise[];
};
IF vinvert THEN level ← 1.0-level;
RETURN [level]
};
END.
Run AISImpl
Run Texture2DImpl
Alias SetWedgeParam (foo bar) ← WedgeImpl.foo ← bar
Alias ComputeWedge (fileName functionID dots lines) ← Texture2D.FunctionAIS[outputName: "fileName", width: dots, height: lines, f: WedgeImpl.functionID]
Alias Wedge (fileName functionID dots lines aVal bVal cVal) SetWedgeParam a aVal; SetWedgeParam b bVal; SetWedgeParam c cVal; ComputeWedge fileName functionID lines dots