# HG changeset patch # User nenolod # Date 1165410597 28800 # Node ID d517fc608e895f67776ba818f86e9ca610c56ce8 # Parent 5d12ef0b97a5f3b9be8cc864c8acd43079f0b0cf [svn] - some more presets - add dynamic colourmap, a scripted colourmap basically. diff -r 5d12ef0b97a5 -r d517fc608e89 ChangeLog --- a/ChangeLog Tue Dec 05 22:29:56 2006 -0800 +++ b/ChangeLog Wed Dec 06 05:09:57 2006 -0800 @@ -1,3 +1,11 @@ +2006-12-06 06:29:56 +0000 William Pitcock + revision [738] + - note that the dynamic transform is slow + + trunk/src/paranormal/xform.c | 15 ++++++++------- + 1 file changed, 8 insertions(+), 7 deletions(-) + + 2006-12-05 22:10:31 +0000 William Pitcock revision [736] - implement AVS-like Trans / Dynamic Movement diff -r 5d12ef0b97a5 -r d517fc608e89 src/paranormal/builtins.c --- a/src/paranormal/builtins.c Tue Dec 05 22:29:56 2006 -0800 +++ b/src/paranormal/builtins.c Wed Dec 06 05:09:57 2006 -0800 @@ -17,6 +17,7 @@ DECLARE_ACTUATOR (cmap_bwgradient); DECLARE_ACTUATOR (cmap_gradient); +DECLARE_ACTUATOR (cmap_dynamic); /* **************** freq **************** */ DECLARE_ACTUATOR (freq_dots); @@ -65,6 +66,7 @@ /* **************** cmaps **************** */ &builtin_cmap_bwgradient, &builtin_cmap_gradient, + &builtin_cmap_dynamic, /* **************** freq **************** */ &builtin_freq_dots, &builtin_freq_drops, diff -r 5d12ef0b97a5 -r d517fc608e89 src/paranormal/cmaps.c --- a/src/paranormal/cmaps.c Tue Dec 05 22:29:56 2006 -0800 +++ b/src/paranormal/cmaps.c Wed Dec 06 05:09:57 2006 -0800 @@ -7,6 +7,8 @@ #include "paranormal.h" #include "actuators.h" +#include "libcalc/calc.h" + #define STD_CMAP_OPTS { "low_index", "The lowest index of the \ color map that should be altered", OPT_TYPE_COLOR_INDEX, { ival: 0 } },\ { "high_index", "The highest index of the color map that should be \ @@ -89,7 +91,95 @@ "cmap_bwgradient", "Value-based colourmap", "Sets the colormap to a gradient going from black to " - "while, via an intermediate color", + "white, via an intermediate color", 0, cmap_bwgradient_opts, NULL, NULL, cmap_bwgradient_exec }; + +/* **************** cmap_dynamic **************** */ +static struct pn_actuator_option_desc cmap_dynamic_opts[] = +{ + STD_CMAP_OPTS, + { "script", "The script to run on each step.", + OPT_TYPE_STRING, { sval: "red = red + 0.01; blue = blue + 0.01; green = green + 0.01;" } }, + { NULL } +}; + +typedef struct { + expression_t *expr; + symbol_dict_t *dict; +} PnDynamicColourmapData; + +static void +cmap_dynamic_init(gpointer *data) +{ + *data = g_new0(PnDynamicColourmapData, 1); +} + +static void +cmap_dynamic_cleanup(gpointer data) +{ + PnDynamicColourmapData *d = (PnDynamicColourmapData *) data; + + if (d->expr) + expr_free(d->expr); + if (d->dict) + dict_free(d->dict); + + g_free(d); +} + +static void +cmap_dynamic_exec(const struct pn_actuator_option *opts, + gpointer data) +{ + PnDynamicColourmapData *d = (PnDynamicColourmapData *) data; + gint i, j; + gdouble *rf, *bf, *gf, *inf; + gint rn, bn, gn; + + if (!d->dict && !d->expr) + { + d->dict = dict_new(); + if (!d->dict) + return; + + d->expr = expr_compile_string(opts[2].val.sval, d->dict); + if (!d->expr) + { + dict_free(d->dict); + d->dict = NULL; + return; + } + } + + rf = dict_variable(d->dict, "red"); + gf = dict_variable(d->dict, "green"); + bf = dict_variable(d->dict, "blue"); + inf = dict_variable(d->dict, "index"); + + for (i = opts[0].val.ival; i < 255 && i <= opts[1].val.ival; i++) + { + *inf = ((gdouble)i / 255.0); + + expr_execute(d->expr, d->dict); + + /* Convert rf/bf/gf to realworld values. */ + rn = (gdouble)(*rf * 255); + gn = (gdouble)(*gf * 255); + bn = (gdouble)(*bf * 255); + + pn_image_data->cmap[i].r = rn; + pn_image_data->cmap[i].g = gn; + pn_image_data->cmap[i].b = bn; + } +} + +struct pn_actuator_desc builtin_cmap_dynamic = +{ + "cmap_dynamic", + "Dynamic Colourmap", + "Scriptable colourmap modifier.", + 0, cmap_dynamic_opts, + cmap_dynamic_init, cmap_dynamic_cleanup, cmap_dynamic_exec +}; diff -r 5d12ef0b97a5 -r d517fc608e89 src/paranormal/presets/Makefile --- a/src/paranormal/presets/Makefile Tue Dec 05 22:29:56 2006 -0800 +++ b/src/paranormal/presets/Makefile Wed Dec 06 05:09:57 2006 -0800 @@ -25,6 +25,8 @@ nenolod_-_interlaced.pnv:$(presetsdir) \ nenolod_-_cubism.pnv:$(presetsdir) \ nenolod_-_transform_fun.pnv:$(presetsdir) \ + nenolod_-_tunnel_vision.pnv:$(presetsdir) \ + nenolod_-_kaliedoscope.pnv:$(presetsdir) \ aerdan_-_bloody_vortex.pnv:${presetsdir} \ aerdan_-_cloudscape.pnv:${presetsdir} \ aerdan_-_cloudscape2.pnv:${presetsdir} \ diff -r 5d12ef0b97a5 -r d517fc608e89 src/paranormal/presets/nenolod_-_kaliedoscope.pnv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/paranormal/presets/nenolod_-_kaliedoscope.pnv Wed Dec 06 05:09:57 2006 -0800 @@ -0,0 +1,28 @@ + + + + + + + 0 + 255 + + + + + -1 + 255 + TRUE + + + d=cos(d)^2; + + + + + + + 1 + + + \ No newline at end of file diff -r 5d12ef0b97a5 -r d517fc608e89 src/paranormal/presets/nenolod_-_tunnel_vision.pnv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/paranormal/presets/nenolod_-_tunnel_vision.pnv Wed Dec 06 05:09:57 2006 -0800 @@ -0,0 +1,30 @@ + + + + + + + 0 + 255 + 0, 130, 191 + + + + -1 + 255 + TRUE + + + rseek=1.45; dseek=2; + + r=r/rseek; d=d*dseek; + + + + + + + 2 + + + \ No newline at end of file