Skip to content

Commit 3dd1156

Browse files
authored
Merge pull request #43 from jberlin/master
update documentation, add missing functions saturate() and swatch()
2 parents 6a746ff + 1e35b3f commit 3dd1156

23 files changed

+14122
-4932
lines changed

README

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,25 @@ Getting started
2121
---------------
2222
Examining the demo applications in src/demo is a great way to see
2323
some usage examples of the library. The basic strategy is to subclass
24-
the SeExpression class and implement the methods that describe what
24+
the Expression class and implement the methods that describe what
2525
extra functions and variables your expression evaluation will need
2626

27-
Be sure to check out the doxygen pages for an API overview.
28-
27+
Be sure to check out the doxygen pages for an API overview:
28+
http://wdas.github.io/SeExpr/doxygen/
2929

3030
Source code overview
3131
====================
3232

3333
src/
3434
SeExpr/ Library code
35+
ui/ User Interface components for editing
3536
demos/ Demo Applications
3637
tests/ Regression Tests
3738
doc/ Doxygen generation
3839

3940
SeExpr Developers
4041
=================
42+
Janet Berlin
4143
Brent Burley
4244
Lawrence Chai
4345
Andrew Selle

TODO.txt

Lines changed: 0 additions & 45 deletions
This file was deleted.

src/SeExpr/ExprBuiltins.cpp

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,25 @@ static const char* hsltorgb_docstring =
386386
"hsl value (except for negative s values), the conversion is\n"
387387
"well-defined and reversible.";
388388

389+
static Vec3d saturate(const Vec3d& Cin, double amt) {
390+
const Vec3d lum(.2126,.7152,.0722); // rec709 luminance
391+
Vec3d result = Vec3d(Cin.dot(lum) * (1-amt)) + Cin * amt;
392+
if (result[0] < 0) result[0] = 0;
393+
if (result[1] < 0) result[1] = 0;
394+
if (result[2] < 0) result[2] = 0;
395+
return result;
396+
}
397+
398+
Vec3d saturate(int n, const Vec3d* args) {
399+
if (n < 2) return 0.0;
400+
return saturate(args[0], args[1][0]);
401+
}
402+
static const char* saturate_docstring =
403+
"color saturate(color val, float amt)\n"
404+
"Scale saturation of color by amt.\n"
405+
"The color is scaled around the rec709 luminance value,\n"
406+
"and negative results are clamped at zero.\n";
407+
389408
double hash(int n, double* args) {
390409
// combine args into a single seed
391410
uint32_t seed = 0;
@@ -729,7 +748,9 @@ static const char* ccellnoise_docstring =
729748
double pnoise(const Vec3d& p, const Vec3d& period) {
730749
double result;
731750
double args[3] = {p[0], p[1], p[2]};
732-
int pargs[3] = {(int)period[0], (int)period[1], (int)period[2]};
751+
int pargs[3] = {max(1,(int)period[0]),
752+
max(1,(int)period[1]),
753+
max(1,(int)period[2])};
733754
PNoise<3, 1>(args, pargs, &result);
734755
return result;
735756
}
@@ -1177,6 +1198,13 @@ static const char* pick_docstring =
11771198
"to the supplied weights.&nbsp; Any weights not supplied are assumed to\n"
11781199
"be 1.0.";
11791200

1201+
double swatch(int n, double* params) {
1202+
return choose(n, params);
1203+
}
1204+
static const char *swatch_docstring=
1205+
"color swatch(float index, color choice0, color choice1, color choice2, [...])\n"
1206+
"Chooses one of the supplied color choices based on the index (assumed to be in range [0..1]).";
1207+
11801208
double choose(int n, double* params) {
11811209
if (n < 3) return 0;
11821210
double key = params[0];
@@ -1644,6 +1672,7 @@ void defineBuiltins(ExprFunc::Define define, ExprFunc::Define3 define3) {
16441672
FUNCNDOC(midhsi, 5, 7);
16451673
FUNCDOC(hsltorgb);
16461674
FUNCDOC(rgbtohsl);
1675+
FUNCNDOC(saturate, 2, 2);
16471676

16481677
// noise
16491678
FUNCNDOC(hash, 1, -1);
@@ -1684,6 +1713,7 @@ void defineBuiltins(ExprFunc::Define define, ExprFunc::Define3 define3) {
16841713
FUNCNDOC(pick, 3, -1);
16851714
FUNCNDOC(choose, 3, -1);
16861715
FUNCNDOC(wchoose, 4, -1);
1716+
FUNCNDOC(swatch, 3, -1);
16871717
FUNCNDOC(spline, 5, -1);
16881718

16891719
// FuncX interface

src/SeExpr/generated/README

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/doc/license.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ Licensor and its affiliates, except as required for reproducing
1212
the content of the NOTICE file.
1313

1414
You may obtain a copy of the License at
15-
http://www.apache.org/licenses/LICENSE-2.0
1615
</pre>
16+
<a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>

src/doc/main.txt

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,26 @@
2222
* - \subpage plugins - Custom Function Plugins
2323
* \section demos Demo Applications
2424
* - \subpage mytut (code at asciiGraph.cpp)
25-
* - \subpage uitut (code starting at imageEditor.cpp)
26-
* - Image Synthesizer (code at imageSynth.cpp)
27-
* - SeGrapher Qt Grapher (code starting at segraph.cpp)
28-
* - Renderman Shadeop (code at seop.cpp)
25+
* - \subpage uitut (code at imageEditor.cpp)
26+
* - Image Synthesizer (at imageSynth.cpp)
27+
* - SeGrapher Qt Grapher (at demos/segraph)
28+
* - Renderman Shadeop (at demos/rman)
29+
* - \subpage varblocks
2930
* \section mainapi Main API pages
30-
* - SeExpression - Main class to parse a single expression
31-
* - SeExprVarRef - Binding of an external variable to an expression context.
32-
* - SeExprFunc - Define a custom function that calls C++ code
33-
* - SeExprFuncX - Manual argument parsing C++ code
34-
* - SeExprFuncNode - Node that calls a function (needed for SeExprFuncX arg parsing)
31+
* - Expression - Main class to parse a single expression
32+
* - ExprVarRef - Binding of an external variable to an expression context.
33+
* - ExprFunc - Define a custom function that calls C++ code
34+
* - ExprFuncX - Manual argument parsing C++ code
35+
* - ExprFuncNode - Node that calls a function (needed for SeExprFuncX arg parsing)
3536
* \section useful Useful classes and functions
36-
* - SeVec3d - Class to hold and manipulate 3-vectors
37-
* - SeExprBuiltins.h - Useful builtin functions that are also available in C++
38-
* - SeExpr::SeCurve - Hermite interpolation curve.
37+
* - Vec - Class to hold and manipulate n-dimensional vectors
38+
* - ExprBuiltins.h - Useful builtin functions that are also available in C++
39+
* - SeExpr2::Curve - Hermite interpolation curve.
3940
*
4041
* \section internals Internals
41-
* - SeExprNode - Parse Tree Node
42-
* - SeExprParser.h - Entry point to bison/flex parser
43-
*
42+
* - ExprNode - Parse Tree Node
43+
* - ExprParser - Entry point to bison/flex parser
44+
*
4445
* \section Other
4546
* - \subpage license
4647
*/
@@ -50,10 +51,14 @@
5051
\htmlinclude tutorial.txt
5152
*/
5253
/**
53-
\page uitut Simple Image Editor UI Tutorial
54+
\page uitut Image Editor Tutorial
5455
\htmlinclude uitutorial.txt
5556
*/
5657
/**
58+
\page varblocks Using Variable Blocks
59+
\htmlinclude varblocks.txt
60+
*/
61+
/**
5762
\page userdoc User Documentation
5863
\htmlinclude userdoc.txt
5964
*/

0 commit comments

Comments
 (0)