36static const char*
fabs_docstring =
"float abs(float x)\nabsolute value of x";
39static const char*
deg_docstring =
"float deg(float angle)\nradians to degrees";
40static const char*
rad_docstring =
"float deg(float angle)\ndegrees to radians";
42static const char*
cosd_docstring =
"float cosd(float angle)\ncosine in degrees";
43static const char*
sind_docstring =
"float sind(float angle)\nsine in degrees";
44static const char*
tand_docstring =
"float tand(float angle)\ntangent in degrees";
45static const char*
acosd_docstring =
"float acosd(float angle)\narc cosine in degrees";
46static const char*
asind_docstring =
"float asind(float angle)\narc sine in degrees";
47static const char*
atand_docstring =
"float atand(float angle)\narc tangent in degrees";
49 "float atan2d(float y,float x)\narc tangent in degrees of y/x between -180 and 180";
51static const char*
cos_docstring =
"float cos(float angle)\ncosine in radians";
52static const char*
sin_docstring =
"float sin(float angle)\nsine in radians";
53static const char*
tan_docstring =
"float tan(float angle)\ntangent in radians";
54static const char*
acos_docstring =
"float acos(float angle)\narc cosine in radians";
55static const char*
asin_docstring =
"float asin(float angle)\narc sine in radians";
56static const char*
atan_docstring =
"float atan(float angle)\narc tangent in radians";
57static const char*
atan2_docstring =
"float atan2(float y,float x)\narc tangent in radians of y/x between -PI and PI";
59static const char*
cosh_docstring =
"float cosh(float angle)\nhyperbolic cosine in radians";
60static const char*
sinh_docstring =
"float sinh(float angle)\nhyperbolic sine in radians";
61static const char*
tanh_docstring =
"float tanh(float angle)\nhyperbolic tangent in radians";
62static const char*
acosh_docstring =
"float acosh(float angle)\nhyperbolic arc cosine in radians";
63static const char*
asinh_docstring =
"float asinh(float angle)\nhyperbolic arc sine in radians";
64static const char*
atanh_docstring =
"float atanh(float angle)\nhyperbolic arc tangent in radians";
66static const char*
clamp_docstring =
"float clamp(float x,float lo,float hi)\nconstrain x to range [lo,hi]";
67static const char*
round_docstring =
"float round(float x)\nconstrain x to range [lo,hi]";
68static const char*
max_docstring =
"float max(float a,float b)\ngreater of a and b";
69static const char*
min_docstring =
"float min(float a,float b)\nlesser of a and b";
70static const char*
trunc_docstring =
"float trunc(float a)\nnearest integer towards zero";
72static const char*
ceil_docstring =
"float ceil(float a)\nnext higher integer";
77static const char*
exp_docstring =
"float exp(float x)\nE raised to the x power";
78static const char*
pow_docstring =
"float pow(float x)\nx to the y power, also available as ^";
79static const char*
log_docstring =
"float log(float x)\nNatural logarithm";
81static const char*
fmod_docstring =
"float fmod(float x,float y)\nremainder of x/y (also available as % operator)";
83 "float turbulence(vector v,int octaves=6,float lacunarity=2,float gain=.5)\nAbsolute value of each noise term is "
84 "taken. This gives billowy appearance";
86 "color cturbulence(vector v,int octaves=6,float lacunarity=2,float gain=.5)\nAbsolute value of each noise term is "
87 "taken. This gives billowy appearance";
89 "vector vturbulence(vector v,int octaves=6,float lacunarity=2,float gain=.5)\nAbsolute value of each noise term is "
90 "taken. This gives billowy appearance";
93static const char*
compress_docstring =
"float compress(float x,float lo,float hi)\nRemaps x in [0,1] to [lo,hi]";
96 if (
lo ==
hi)
return x <
lo ? 0 : 1;
99static const char*
expand_docstring =
"float expand(float x,float lo,float hi)\nRemaps x in [lo,hi] to [0,1]";
105 "float fit(float x,float a1,float b1,float a2,float b2)\nLinearly remaps x in [a1,b1] to [a2,b2]";
108static const char*
gamma_docstring =
"float gamma(float x, float g)\nGamma correction of x with gamma factor g";
111 static double C = 1 /
log(0.5);
115 "float bias(float x, float g)\nVariation of gamma where values less than 0.5 pull the curve down\nand values "
116 "greater than 0.5 pull the curve up\npow(x,log(b)/log(0.5))";
120 return 0.5 *
bias(1 - c, 2 *
x);
122 return 1 - 0.5 *
bias(1 - c, 2 - 2 *
x);
125 "float contrast(float x,float x)\nAdjust the contrast. For c from 0 to 0.5, the contrast is decreased. "
126 "For c > 0.5, the contrast is increased.";
128double boxstep(
double x,
double a) {
return x <
a ? 0.0 : 1.0; }
129static const char*
boxstep_docstring =
"float boxstep(float x,float a)\n if x < a then 0 otherwise 1";
133 return x <
a ? 0 : (
x >
b ? 1 : (
x -
a) / (
b -
a));
135 return 1 - (
x <
b ? 0 : (
x >
a ? 1 : (
x -
b) / (
a -
b)));
140 "float linearstep(float x,float a,float b)\n if x < a then 0, if x > b then 1, and\nx transitions linearly "
141 "when < x < b ";
146 if (
x >=
b)
return 1;
147 x = (
x -
a) / (
b -
a);
149 if (
x <=
b)
return 1;
151 x = 1 - (
x -
b) / (
a -
b);
154 return x *
x * (3 - 2 *
x);
157 "float smoothstep(float x,float a,float b)\n if x < a then 0, if x > b then 1, and\nx transitions smoothly "
158 "(cubic) when < x < b";
163 if (
x >=
b)
return 1;
164 x = 1 - (
x -
a) / (
b -
a);
166 if (
x <=
b)
return 1;
168 x = (
x -
b) / (
a -
b);
171 return pow(2, -8 *
x *
x);
174 "float gasussstep(float x,float a,float b)\n if x < a then 0, if x > b then 1, and\nx transitions smoothly "
175 "(exponentially) when < x < b";
202 "remap(float x, float\n"
203 "source, float range, float falloff, float interp)\nGeneral remapping function.\n"
204 "When x is within +/- <i>range</i> of source, the result is one.\n"
205 "The result falls to zero beyond that range over <i>falloff</i> distance.\n"
206 "The falloff shape is controlled by <i>interp</i>. Numeric values\n"
207 "or named constants may be used:\n"
208 " int <b>linear</b>\n"
210 " int <b>smooth</b> = 1\n"
211 " int <b>gaussian</b> = 2\n";
213double mix(
double x,
double y,
double alpha) {
return x * (1 - alpha) +
y * alpha; }
214static const char*
mix_docstring =
"mix(float a,float b,float alpha)\nBlend of a and b according to alpha.";
218 hsl[0] +=
h * (1.0 / 360);
224 if (n < 4)
return 0.0;
226 double h = args[1][0];
227 double s = args[2][0];
228 double i = args[3][0];
231 double m = args[4][0];
239 "color hsi(color x, float h, float s, float i, float map=1)\n"
240 "The hsi function shifts the hue by h\n"
241 "(in degrees) and scales the saturation and intensity by s and i\n"
242 "respectively. An map may be supplied which will control the shift\n"
243 "- the full shift will happen when the map is one and no shift will\n"
244 "happen when the map is zero. The shift will be scaled back for\n"
245 "values between zero and one.";
248 if (n < 4)
return 0.0;
250 double h = args[1][0];
251 double s = args[2][0];
252 double i = args[3][0];
255 double m = args[4][0];
260 if (n >= 6)
falloff = args[5][0];
261 if (n >= 7)
interp = args[6][0];
269 float absm =
fabs(
static_cast<float>(
m));
280 "color midhsi(color x, float h, float s, float i, float map, float falloff=1, int interp=0)\n"
281 "The midhsi function is just like the hsi function except that\n"
282 "the control map is centered around the mid point (value of 0.5)\n"
283 "and can scale the shift in both directions.";
313 S =
diff / (2 - sum);
329 "color rgbtohsl(color rgb)\n"
330 "RGB to HSL color space conversion.\n"
331 "HSL is Hue, Saturation, Lightness (all in range [0..1] )\n"
332 "These functions have also been extended to support rgb and hsl values\n"
333 "outside of the range [0..1] in a reasonable way. For any rgb or\n"
334 "hsl value (except for negative s values), the conversion is\n"
335 "well-defined and reversible.";
341 return x + (
y -
x) *
H * 6;
345 return x + (
y -
x) * (4 / 6. -
H) * 6;
382 "color hsltorgb(color hsl)\n"
383 "RGB to HSL color space conversion.\n"
384 "HSL is Hue, Saturation, Lightness (all in range [0..1] )\n"
385 "These functions have also been extended to support rgb and hsl values\n"
386 "outside of the range [0..1] in a reasonable way. For any rgb or\n"
387 "hsl value (except for negative s values), the conversion is\n"
388 "well-defined and reversible.";
391 const Vec3d lum(.2126, .7152, .0722);
400 if (n < 2)
return 0.0;
401 return saturate(args[0], args[1][0]);
404 "color saturate(color val, float amt)\n"
405 "Scale saturation of color by amt.\n"
406 "The color is scaled around the rec709 luminance value,\n"
407 "and negative results are clamped at zero.\n";
409double hash(
int n,
double* args) {
412 for (
int i = 0;
i < n;
i++) {
419 static const uint32_t M = 1664525,
C = 1013904223;
426 seed ^= (
seed << 15) & 0xefc60000UL;
430 static unsigned char p[256] = {
431 148, 201, 203, 34, 85, 225, 163, 200, 174, 137, 51, 24, 19, 252, 107, 173, 110, 251, 149, 69, 180, 152,
432 141, 132, 22, 20, 147, 219, 37, 46, 154, 114, 59, 49, 155, 161, 239, 77, 47, 10, 70, 227, 53, 235,
433 30, 188, 143, 73, 88, 193, 214, 194, 18, 120, 176, 36, 212, 84, 211, 142, 167, 57, 153, 71, 159, 151,
434 126, 115, 229, 124, 172, 101, 79, 183, 32, 38, 68, 11, 67, 109, 221, 3, 4, 61, 122, 94, 72, 117,
435 12, 240, 199, 76, 118, 5, 48, 197, 128, 62, 119, 89, 14, 45, 226, 195, 80, 50, 40, 192, 60, 65,
436 166, 106, 90, 215, 213, 232, 250, 207, 104, 52, 182, 29, 157, 103, 242, 97, 111, 17, 8, 175, 254, 108,
437 208, 224, 191, 112, 105, 187, 43, 56, 185, 243, 196, 156, 246, 249, 184, 7, 135, 6, 158, 82, 130, 234,
438 206, 255, 160, 236, 171, 230, 42, 98, 54, 74, 209, 205, 33, 177, 15, 138, 178, 44, 116, 96, 140, 253,
439 233, 125, 21, 133, 136, 86, 245, 58, 23, 1, 75, 165, 92, 217, 39, 0, 218, 91, 179, 55, 238, 170,
440 134, 83, 25, 189, 216, 100, 129, 150, 241, 210, 123, 99, 2, 164, 16, 220, 121, 139, 168, 64, 190, 9,
441 31, 228, 95, 247, 244, 81, 102, 145, 204, 146, 26, 87, 113, 198, 181, 127, 237, 169, 28, 93, 27, 41,
442 231, 248, 78, 162, 13, 186, 63, 66, 131, 202, 35, 144, 222, 223};
448 u2.c[3] = p[
u1.c[0]];
449 u2.c[2] = p[(
u1.c[1] +
u2.c[3]) & 0xff];
450 u2.c[1] = p[(
u1.c[2] +
u2.c[2]) & 0xff];
451 u2.c[0] = p[(
u1.c[3] +
u2.c[1]) & 0xff];
457 "float hash(float seed1,[float seed2, ...])\n"
458 "Like rand, but with no internal seeds. Any number of seeds may be given\n"
459 "and the result will be a random function based on all the seeds.";
466 double p[3] = {args[0][0], args[0][1], args[0][2]};
473 for (
int i = 0;
i < n;
i++) p[
i] = args[
i][0];
495 "float noise ( vector v ) <br>\n"
496 "float noise ( float x, float y )\n"
497 "float noise ( float x, float y, float z )\n"
498 "float noise ( float x, float y, float z, float w )\n"
499 "Original perlin noise at location (C2 interpolant)";
503 double args[3] = {p[0], p[1], p[2]};
508 "float snoise ( vector v)\n"
509 "signed noise w/ range -1 to 1 formed with original perlin noise at location (C2 interpolant)";
513 double args[3] = {p[0], p[1], p[2]};
518 "vector vnoise ( vector v)\n"
519 "vector noise formed with original perlin noise at location (C2 interpolant)";
523 "color cnoise ( vector v)\n"
524 "color noise formed with original perlin noise at location (C2 interpolant)";
528 double procargs[4] = {args[0][0], args[0][1], args[0][2], args[1][0]};
533 "float snoise4 ( vector v,float t)\n"
534 "4D signed noise w/ range -1 to 1 formed with original perlin noise at location (C2 interpolant)";
538 double procargs[4] = {args[0][0], args[0][1], args[0][2], args[1][0]};
543 "vector vnoise4 ( vector v,float t)\n"
544 "4D vector noise formed with original perlin noise at location (C2 interpolant)";
548 "color cnoise4 ( vector v,float t)\n"
549 "4D color noise formed with original perlin noise at location (C2 interpolant)";
570 double P[3] = {p[0], p[1], p[2]};
594 double P[3] = {p[0], p[1], p[2]};
620 double P[3] = {p[0], p[1], p[2]};
625 "float fbm(vector v,int octaves=6,float lacunarity=2,float gain=.5)\n"
626 "fbm (Fractal Brownian Motion) is a multi-frequency noise function. \n"
627 "The base frequency is the same as the \"noise\" function. The total \n"
628 "number of frequencies is controlled by octaves. The lacunarity is the \n"
629 "spacing between the frequencies - a value of 2 means each octave is \n"
630 "twice the previous frequency. The gain< controls how much each \n"
631 "frequency is scaled relative to the previous frequency.";
652 double P[3] = {p[0], p[1], p[2]};
656static const char*
vfbm_docstring =
"vector vfbm(vector vint octaves=6,float lacunarity=2,float gain=.5)";
674 time =
static_cast<float>(args[1][0]);
680 double P[4] = {p[0], p[1], p[2], time};
685 "float fbm4(vector v,float time,int octaves=6,float lacunarity=2,float gain=.5)\n"
686 "fbm (Fractal Brownian Motion) is a multi-frequency noise function. \n"
687 "The base frequency is the same as the \"noise\" function. The total \n"
688 "number of frequencies is controlled by octaves. The lacunarity is the \n"
689 "spacing between the frequencies - a value of 2 means each octave is \n"
690 "twice the previous frequency. The gain< controls how much each \n"
691 "frequency is scaled relative to the previous frequency.";
709 time =
static_cast<float>(args[1][0]);
715 double P[4] = {p[0], p[1], p[2], time};
719static const char*
vfbm4_docstring =
"vector vfbm4(vector v,float time,int octaves=6,float lacunarity=2,float gain=.5)";
722static const char*
cfbm_docstring =
"color cfbm(vector vint octaves=6,float lacunarity=2,float gain=.5)";
725static const char*
cfbm4_docstring =
"color cfbm4(vector v,float time,int octaves=6,float lacunarity=2,float gain=.5)";
729 double args[3] = {p[0], p[1], p[2]};
734 "float cellnoise(vector v)\n"
735 "cellnoise generates a field of constant colored cubes based on the integer location.\n"
736 "This is the same as the prman cellnoise function.";
740 double args[3] = {p[0], p[1], p[2]};
745 "color cellnoise(vector v)\n"
746 "cellnoise generates a field of constant colored cubes based on the integer location.\n"
747 "This is the same as the prman cellnoise function.";
751 double args[3] = {p[0], p[1], p[2]};
753 std::max((
int)1, (
int)
period[1]),
754 std::max((
int)1, (
int)
period[2])};
759 "float pnoise ( vector v, vector period )\n"
774 for (
double i = -1;
i <= 1;
i++) {
775 for (
double j = -1;
j <= 1;
j++) {
776 for (
double k = -1;
k <= 1;
k++, n++) {
793 for (;
pos != end;
pos++) {
795 double dist = offset.
dot(offset);
817 for (;
pos != end;
pos++) {
819 double dist = offset.
dot(offset);
854 jitter =
clamp(args[2][0], 1
e-3, 1);
856 type =
int(args[1][0]);
896 "float voronoi(vector v, int type=1,float jitter=0.5, float fbmScale=0, int fbmOctaves=4,float fbmLacunarity=2, "
897 "float fbmGain=.5)\n"
898 "voronoi is a cellular noise pattern. It is a jittered variant of cellnoise.";
920 jitter =
clamp(args[2][0], 1
e-3, 1);
922 type =
int(args[1][0]);
953 return (
f2 -
f1) * color;
963 "color cvoronoi(vector v, int type=1,float jitter=0.5, float fbmScale=0, int fbmOctaves=4,float fbmLacunarity=2, "
964 "float fbmGain=.5)\n"
965 "returns color in cellular pattern. It is a jittered variant of cellnoise.";
986 jitter =
clamp(args[1][0], 1
e-3, 1);
1006 "color pvoronoi(vector v, int type=1,float jitter=0.5, float fbmScale=0, int fbmOctaves=4,float fbmLacunarity=2, "
1007 "float fbmGain=.5)\n"
1008 "returns center of voronoi cell.";
1017 int nargs =
node->numChildren();
1019 node->addError(
"Wrong number of arguments, should be 1 to 7");
1035 int nargs = args.
nargs();
1038 for (
int i = 0;
i < nargs;
i++)
1059 "float dist(vector a, vector b)\n"
1060 "distance between two points";
1064 "float length(vector v)\n"
1069 "float hypot(vector v)\n"
1070 "length of 2d vector [x,y]";
1074 "float dot(vector a,vector b)\n"
1075 "vector dot product";
1085 "vector norm(vector v)\n"
1086 "vector scaled to unit length";
1089 return Vec3d(
a[1] *
b[2] -
a[2] *
b[1],
a[2] *
b[0] -
a[0] *
b[2],
a[0] *
b[1] -
a[1] *
b[0]);
1092 "vector cross(vector a,vector b)\n"
1093 "vector cross product";
1097 if (
len == 0)
return 0;
1101 "float angle(vector a,vector b)\n"
1102 "angle between two vectors (in radians)";
1106 "vector angle(vector a,vector b)\n"
1107 "normalized vector orthogonal to a and b scaled to unit length";
1110 if (n != 3)
return 0.0;
1111 const Vec3d& P = args[0];
1113 float angle =
static_cast<float>(args[2][0]);
1119 "vector rotate(vector v,vector axis,float angle)\n"
1120 "rotates v around axis by given angle (in radians)";
1128 "vector up(vector P,vector upvec)\n"
1129 "rotates v such that the Y axis points in the given up direction";
1141 "int cycle(int index, int loRange, int hiRange )\n"
1142 "Cycles through values between loRange and hiRange based on supplied index.\n"
1143 "This is an offset \"mod\" function. The result is rotates v such that the\n"
1144 "Y axis points in the given up direction";
1146double pick(
int n,
double* params) {
1147 if (n < 3)
return 0;
1175 int m = (
lo +
hi) / 2;
1196 "int pick(float index, int loRange, int hiRange, [float weights, ...] )\n"
1197 "Picks values randomly between loRange and hiRange based on supplied index (which is\n"
1198 "automatically hashed). The values will be distributed according\n"
1199 "to the supplied weights. Any weights not supplied are assumed to\n"
1204 "color swatch(float index, color choice0, color choice1, color choice2, [...])\n"
1205 "Chooses one of the supplied color choices based on the index (assumed to be in range [0..1]).";
1208 if (n < 3)
return 0;
1209 double key = params[0];
1211 if (
key !=
key)
return 0;
1216 "float choose(float index,float choice1, float choice2, [...])\n"
1217 "Chooses one of the supplied choices based on the index (assumed to be in range [0..1]).";
1220 if (n < 5)
return 0;
1221 double key = params[0];
1223 if (
key !=
key)
return 0;
1224 int nvals = (n - 1) / 2;
1231 double weight = params[
i * 2 + 2];
1237 if (
total == 0)
return params[1];
1245 int m = (
lo +
hi) / 2;
1263 return params[
lo * 2 + 1];
1266 "float wchoose(float index,float choice1, float weight1, float choice2, float weight2, [...] )\n"
1267 "Chooses one of the supplied choices based on the index (assumed to be in range[0..1]).\n"
1268 "The values will be distributed according to the supplied weights.";
1271 if (n < 5)
return 0;
1272 double u =
clamp(params[0], 0, 1);
1273 if (u == 0)
return params[2];
1274 if (u == 1)
return params[n - 2];
1278 double* p = ¶ms[
int(
seg) + 1];
1281 return 0.5 * (p[0] * (-
u3 + 2 *
u2 - u) + p[1] * (3 *
u3 - 5 *
u2 + 2) + p[2] * (-3 *
u3 + 4 *
u2 + u) +
1285 "float spline(float param,float y1,float y2,float y3,float y4,[...])\n\n"
1286 "Interpolates a set of values to the parameter specified where y1, ..., yn are\n"
1287 "distributed evenly from [0...1]";
1301 int nargs =
node->numChildren();
1302 if ((nargs - 1) % 3) {
1303 node->addError(
"Wrong number of arguments, should be multiple of 3 plus 1");
1309 for (
int i = 1;
i < nargs;
i += 3) {
1319 for (
int i = 1;
i < args.
nargs() - 2;
i += 3) {
1321 double val = args.
inFp<1>(
i + 1)[0];
1330 data->curve.preparePoints();
1342 "float curve(float param,float pos0,float val0,int interp0,float pos1,float val1,int interp1,[...])\n\n"
1343 "Interpolates a 1D ramp defined by control points at 'param'. Control points are specified \n"
1344 "by triples of parameters pos_i, val_i, and interp_i. Interpolation codes are \n"
1345 "0 - none, 1 - linear, 2 - smooth, 3 - spline, \n"
1346 "4-monotone (non oscillating spline)";
1351 int nargs =
node->numChildren();
1352 if ((nargs - 1) % 3) {
1353 node->addError(
"Wrong number of arguments, should be multiple of 3 plus 1");
1359 for (
int i = 1;
i < nargs;
i += 3) {
1369 for (
int i = 1;
i < args.
nargs() - 2;
i += 3) {
1380 data->curve.preparePoints();
1397 "color curve(float param,float pos0,color val0,int interp0,float pos1,color val1,int interp1,[...])\n\n"
1398 "Interpolates color ramp given by control points at 'param'. Control points are specified \n"
1399 "by triples of parameters pos_i, val_i, and interp_i. Interpolation codes are \n"
1400 "0 - none, 1 - linear, 2 - smooth, 3 - spline, \n"
1401 "4 - monotone (non oscillating spline)";
1414 std::string varName =
node->getStrArg(0);
1418 node->removeLastChild();
1419 node->removeLastChild();
1423 node->swapChildren(0, 1);
1425 node->removeLastChild();
1432 node->type().dim());
1437 static void f(
double*
out,
double* in) {
1438 for (
int k = 0;
k < d;
k++)
out[
k] = in[
k];
1451 throw std::runtime_error(
"getVar does not support non FP types right now got type");
1459 "getVar(string varName,vector defaultValue)\n"
1460 "return value of varName if variable exists, otherwise return defaultValue";
1470 int nargs =
node->numChildren();
1472 node->addError(
"Wrong number of arguments, should be GE 1");
1478 for (
int i = 1;
i < nargs; ++
i)
1491 std::string& format = data->
format;
1492 std::vector<std::pair<int, int> >& ranges = data->
ranges;
1507 int code = (c ==
'v') ? -1 : -2;
1510 ranges.push_back(std::pair<int, int>(
code,
code));
1523 if (
bakeStart != format.
length()) ranges.push_back(std::pair<int, int>(
bakeStart,
static_cast<int>(format.length())));
1540 for (
unsigned int i = 0;
i < data->
ranges.size();
i++) {
1542 if (
range.first == -2) {
1543 std::cerr << args.
inFp<1>(
item)[0];
1545 }
else if (
range.first == -1) {
1546 std::cerr <<
"[" << args.
inFp<3>(
item)[0] <<
"," << args.
inFp<3>(
item)[1] <<
","
1553 std::cerr << std::endl;
1562 "printf(string format,[vec0, vec1, ...])\n"
1563 "Prints out a string to STDOUT, Format parameter allowed is %v";
1582 int nargs =
node->numChildren();
1584 node->addError(
"Wrong number of arguments, should be >= 1");
1588 node->addError(
"First argument must be a string.");
1592 const std::string& format =
static_cast<const ExprStrNode*
>(
node->child(0))->str();
1594 static const std::string
strSpec(
"s");
1599 if (
specStart == std::string::npos)
break;
1601 node->addError(
"incomplete format specifier");
1611 if (
specEnd == std::string::npos) {
1612 node->addError(
"incomplete format specifier");
1646 if (
specStart == std::string::npos)
break;
1677 "sprintf(string format, [double|string, double|string, ...])\n"
1678 "Returns a string formatted from the given values. See 'man sprintf' for format details.";
1706 return new MyData(args.inFp<1>(1)[0]);
1708 virtual void eval(ArgHandle args)
1715static const char* testfunc_docstring=
"fdsA";
1722#define FUNCADOC(name, func) define3(name, ExprFunc(::func), func##_docstring)
1723#define FUNCDOC(func) define3(#func, ExprFunc(::func), func##_docstring)
1755#define FUNCDOC(func) define3(#func, ExprFunc(SeExpr2::func), func##_docstring)
1756#define FUNCNDOC(func, min, max) define3(#func, ExprFunc(SeExpr2::func, min, max), func##_docstring)
virtual void eval(ArgHandle args)
virtual ExprType prep(ExprFuncNode *node, bool scalarWanted, ExprVarEnvBuilder &envBuilder) const
#define FUNCNDOC(func, min, max)
#define FUNCADOC(name, func)
virtual ExprFuncNode::Data * evalConstant(const ExprFuncNode *node, ArgHandle args) const
virtual void eval(ArgHandle args)
virtual ExprType prep(ExprFuncNode *node, bool wantScalar, ExprVarEnvBuilder &envBuilder) const
virtual ExprFuncNode::Data * evalConstant(const ExprFuncNode *node, ArgHandle args) const
CachedVoronoiFunc(VoronoiFunc *vfunc)
virtual ExprType prep(ExprFuncNode *node, bool scalarWanted, ExprVarEnvBuilder &envBuilder) const
virtual ExprFuncNode::Data * evalConstant(const ExprFuncNode *node, ArgHandle args) const
Vec3d VoronoiFunc(VoronoiPointData &data, int n, const Vec3d *args)
virtual ~CachedVoronoiFunc()
virtual void eval(ArgHandle args)
virtual void eval(ArgHandle args)
virtual ExprFuncNode::Data * evalConstant(const ExprFuncNode *node, ArgHandle args) const
virtual ExprType prep(ExprFuncNode *node, bool scalarWanted, ExprVarEnvBuilder &envBuilder) const
Interpolation curve class for double->double and double->Vec3D.
InterpType
Supported interpolation types.
Node that calls a function.
Vec< double, d, true > inFp(int i)
ExprFuncNode::Data * data
void(* Define)(const char *name, ExprFunc f)
void(* Define3)(const char *name, ExprFunc f, const char *docString)
Node that stores a string.
ExprType & FP(int d)
Mutate this into a floating point type of dimension d.
ExprType & String()
Mutate this into a string type.
ExprType & Error()
Mutate this into an error type.
ExprType & Varying()
Mutate this into a varying lifetime.
ExprType & Constant()
Mutate this into a constant lifetime.
Variable scope builder is used by the type checking and code gen to track visiblity of variables and ...
Node that references a variable.
virtual void eval(ArgHandle args)
virtual ExprType prep(ExprFuncNode *node, bool wantScalar, ExprVarEnvBuilder &envBuilder) const
virtual ExprFuncNode::Data * evalConstant(const ExprFuncNode *node, ArgHandle args) const
virtual ExprType prep(ExprFuncNode *node, bool wantScalar, ExprVarEnvBuilder &envBuilder) const
virtual ExprFuncNode::Data * evalConstant(const ExprFuncNode *node, ArgHandle args) const
virtual void eval(ArgHandle args)
virtual ExprFuncNode::Data * evalConstant(const ExprFuncNode *node, ArgHandle args) const
virtual void eval(ArgHandle args)
virtual ExprType prep(ExprFuncNode *node, bool wantScalar, ExprVarEnvBuilder &envBuilder) const
T length() const
Euclidean (2) norm.
T dot(const Vec< T, d, refother > &o) const
T_VEC_VALUE rotateBy(const Vec< T, 3, refother > &axis, T angle) const
Vec3d ortho(const Vec3d &a, const Vec3d &b)
static const char * hypot_docstring
static const char * asind_docstring
Vec3d norm(const Vec3d &a)
SeExpr2::SPrintFuncX sprintf
static const char * dist_docstring
static const char * atan2d_docstring
Vec< double, 3, false > Vec3d
static void voronoi_f1_3d(VoronoiPointData &data, const Vec3d &p, double jitter, double &f1, Vec3d &pos1)
static const std::string _doubleSpec("eEfFgGaA")
static const char * sind_docstring
static const char * curve_docstring
static const char * hsi_docstring
static double hslvalue(double x, double y, double H)
static const char * pow_docstring
Vec3d cvoronoiFn(VoronoiPointData &data, int n, const Vec3d *args)
SeExpr2::CachedVoronoiFunc ExprFuncSimple pvoronoi(pvoronoiFn)
SeExpr2::CachedVoronoiFunc ExprFuncSimple cvoronoi(cvoronoiFn)
static const char * tan_docstring
double atan2d(double y, double x)
static const char * pnoise_docstring
double swatch(int n, double *params)
Vec3d up(const Vec3d &P, const Vec3d &upvec)
static const char * vnoise_docstring
static const char * trunc_docstring
static const char * dot_docstring
void defineBuiltins(ExprFunc::Define define, ExprFunc::Define3 define3)
static const char * round_docstring
static const char * remap_docstring
static const char * bias_docstring
double hypot(double x, double y)
static const char * max_docstring
static const std::string _intSpec("diouxXc")
static const char * snoise4_docstring
double boxstep(double x, double a)
double snoise4(int n, const Vec3d *args)
static const char * compress_docstring
Vec3d vnoise(const Vec3d &p)
static const char * sin_docstring
static const char * clamp_docstring
static const char * ccurve_docstring
static const char * cbrt_docstring
static const char * vnoise4_docstring
static const char * fbm_docstring
static const char * ceil_docstring
double bias(double x, double b)
static const char * sqrt_docstring
SeExpr2::CCurveFuncX ccurve
static const char * fbm4_docstring
static const char * cfbm4_docstring
static const char * sprintf_docstring
static const std::string _strSpec("s")
Vec3d cnoise(const Vec3d &p)
static const char * cycle_docstring
double contrast(double x, double c)
static const char * asin_docstring
static const char * contrast_docstring
static const char * atanh_docstring
static const char * cnoise_docstring
static const char * printf_docstring
double smoothstep(double x, double a, double b)
static const char * spline_docstring
Vec3d cfbm4(int n, const Vec3d *args)
double dot(const Vec3d &a, const Vec3d &b)
double angle(const Vec3d &a, const Vec3d &b)
Vec3d rgbtohsl(const Vec3d &rgb)
static const char * swatch_docstring
static const char * acosh_docstring
static const char * cnoise4_docstring
static const char * midhsi_docstring
static const char * expand_docstring
static const char * cosd_docstring
static const char * turbulence_docstring
static const char * linearstep_docstring
Vec3d vturbulence(int n, const Vec3d *args)
static const char * acosd_docstring
static const char * norm_docstring
static const char * voronoi_docstring
Vec3d cnoise4(int n, const Vec3d *args)
static const char * saturate_docstring
double mix(double x, double y, double alpha)
static const char * log10_docstring
static const char * atan_docstring
Vec3d hsi(int n, const Vec3d *args)
SeExpr2::CurveData voronoi
static const char * cosh_docstring
Vec3d cturbulence(int n, const Vec3d *args)
double linearstep(double x, double a, double b)
static const char * hsltorgb_docstring
static const char * getVar_docstring
Vec3d hsltorgb(const Vec3d &hsl)
double wchoose(int n, double *params)
double dist(double ax, double ay, double az, double bx, double by, double bz)
double length(const Vec3d &v)
static const char * vturbulence_docstring
static const char * ortho_docstring
static const char * atan2_docstring
double noise(int n, const Vec3d *args)
static const char * ccellnoise_docstring
static const char * fabs_docstring
double fbm(int n, const Vec3d *args)
static void voronoi_f1f2_3d(VoronoiPointData &data, const Vec3d &p, double jitter, double &f1, Vec3d &pos1, double &f2, Vec3d &pos2)
static const char * vfbm_docstring
Vec3d midhsi(int n, const Vec3d *args)
static const char * cfbm_docstring
static Vec3d * voronoi_points(VoronoiPointData &data, const Vec3d &cell, double jitter)
Vec3d vfbm4(int n, const Vec3d *args)
static const char * acos_docstring
double gaussstep(double x, double a, double b)
static const char * boxstep_docstring
static const char * deg_docstring
double hash(int n, double *args)
double remap(double x, double source, double range, double falloff, double interp)
static const char * noise_docstring
Vec3d vnoise4(int n, const Vec3d *args)
Vec3d ccellnoise(const Vec3d &p)
static const char * fit_docstring
double turbulence(int n, const Vec3d *args)
Vec3d hsiAdjust(const Vec3d &rgb, double h, double s, double i)
Vec3d cfbm(int n, const Vec3d *args)
static const char * atand_docstring
double max(double x, double y)
Vec3d vfbm(int n, const Vec3d *args)
Vec3d pvoronoiFn(VoronoiPointData &data, int n, const Vec3d *args)
static const char * log_docstring
static const char * cos_docstring
SeExpr2::PrintFuncX printf
static const char * cross_docstring
static const char * choose_docstring
static const char * rotate_docstring
static const char * snoise_docstring
static const char * up_docstring
double compress(double x, double lo, double hi)
static Vec3d saturate(const Vec3d &Cin, double amt)
double pnoise(const Vec3d &p, const Vec3d &period)
static const char * floor_docstring
static const char * vfbm4_docstring
static const char * mix_docstring
static const char * rgbtohsl_docstring
static const char * wchoose_docstring
static const char * pvoronoi_docstring
static const char * sinh_docstring
Vec3d cross(const Vec3d &a, const Vec3d &b)
static const char * rad_docstring
static const char * tand_docstring
double clamp(double x, double lo, double hi)
Vec3d voronoiFn(VoronoiPointData &data, int n, const Vec3d *args)
double min(double x, double y)
static const char * tanh_docstring
static const char * gaussstep_docstring
static const char * fmod_docstring
static const char * hash_docstring
static const char * cellnoise_docstring
static const char * length_docstring
static const char * invert_docstring
static const char * cvoronoi_docstring
double fit(double x, double a1, double b1, double a2, double b2)
double expand(double x, double lo, double hi)
double gamma(double x, double g)
static const char * gamma_docstring
double cellnoise(const Vec3d &p)
Vec3d rotate(int n, const Vec3d *args)
static const char * min_docstring
double snoise(const Vec3d &p)
SeExpr2::CurveFuncX curve
static const char * pick_docstring
static const char * angle_docstring
static const char * smoothstep_docstring
static const char * cturbulence_docstring
static const char * exp_docstring
double fbm4(int n, const Vec3d *args)
static const char * asinh_docstring
base class for custom instance data
static void f(double *out, double *in)
void(* func)(double *in, double *out)
std::vector< std::pair< int, int > > ranges
* sin(val)/val" </pre> we would get <pre> | | | | | </pre> or if we did <pre> ./asciiGraph "x-3" </pre> we'd get <pre> | | ------------------------------|----------------- | | | | | </pre> <h2>Implement the subclass</h2> First we subclass Expression and give it a const ructor
</pre >< h3 > A simple variable reference</h3 > This is not a very interesting subclass of expression until we add some additional variables Variables on some applications may be very dynamic In this we only need x
For< b ></b >< b ></b >< b > cycle
When x is within< i > range</i > of source
The result is computed int loRange
< br > pow($a, 0.5)+ $b< br >< br ></div > External variables can also be overridden by local assignment.  
For< b ></b >< b ></b >< b ></b >< b > spline
Defined as float g float a1
Defined as a *alpha b *alpha< br ></div >< br > float< b > float a
This is the same as the prman cellnoise function< br ></div >< br > float< b > float y< br > float< b > float float z
For< b ></b >< b > choose
The result is computed int int hiRange
Defined as float g float float b1
This is the same as the prman cellnoise function< br ></div >< br > float< b > float y< br > float< b > float y
Defined as float g float float float a2
The result is computed int int< br >< div style="margin-left: 40px;"> Picks values randomly between loRange and hiRange based on supplied index(which is automatically hashed).  
For applying the gamma function to a map adjusts the gamma of all three color channels< br >< br >< h4 >< a name="Curve_Functions"></a > Curve Functions</h4 >< p > Interpolation of parameter values to a set of control points is governed by the following functions</p >< p > color< b > and interp_i Interpolation codes are float float int float pos1