# HG changeset patch # User nenolod # Date 1162443058 28800 # Node ID 6048abdac7d121c4cf658b0034ac23d734fd29fb # Parent 156d6c875ef0309db892528fd74b2dddfa3e1e42 [svn] - add value replace filter, replaces a range of values with a different value - add preset which demonstrates how this can be abused diff -r 156d6c875ef0 -r 6048abdac7d1 ChangeLog --- a/ChangeLog Wed Nov 01 13:19:36 2006 -0800 +++ b/ChangeLog Wed Nov 01 20:50:58 2006 -0800 @@ -1,3 +1,12 @@ +2006-11-01 21:19:36 +0000 William Pitcock + revision [362] + - add value invert filter + + trunk/src/paranormal/builtins.c | 2 ++ + trunk/src/paranormal/general.c | 20 ++++++++++++++++++++ + 2 files changed, 22 insertions(+) + + 2006-11-01 09:50:23 +0000 William Pitcock revision [360] - take advantage of the ability to do nothing diff -r 156d6c875ef0 -r 6048abdac7d1 src/paranormal/builtins.c --- a/src/paranormal/builtins.c Wed Nov 01 13:19:36 2006 -0800 +++ b/src/paranormal/builtins.c Wed Nov 01 20:50:58 2006 -0800 @@ -29,6 +29,7 @@ DECLARE_ACTUATOR (general_clear); DECLARE_ACTUATOR (general_noop); DECLARE_ACTUATOR (general_invert); +DECLARE_ACTUATOR (general_replace); /* **************** wave **************** */ DECLARE_ACTUATOR (wave_horizontal); @@ -64,6 +65,7 @@ &builtin_general_clear, &builtin_general_noop, &builtin_general_invert, + &builtin_general_replace, /* **************** wave **************** */ &builtin_wave_horizontal, &builtin_wave_vertical, diff -r 156d6c875ef0 -r 6048abdac7d1 src/paranormal/general.c --- a/src/paranormal/general.c Wed Nov 01 13:19:36 2006 -0800 +++ b/src/paranormal/general.c Wed Nov 01 20:50:58 2006 -0800 @@ -198,3 +198,41 @@ NULL, NULL, general_invert_exec }; +/* **************** general_replace **************** */ +static struct pn_actuator_option_desc general_replace_opts[] = +{ + { "start", "The beginning colour value that should be replaced by the value of out.", + OPT_TYPE_INT, { ival: 250 } }, + { "end", "The ending colour value that should be replaced by the value of out.", + OPT_TYPE_INT, { ival: 255 } }, + { "out", "The colour value that in is replaced with.", + OPT_TYPE_INT, { ival: 0 } }, + { NULL } +}; + +static void +general_replace_exec (const struct pn_actuator_option *opts, + gpointer data) +{ + register int i, j; + register guchar val; + guchar begin = opts[0].val.ival > 255 || opts[0].val.ival < 0 ? 250 : opts[0].val.ival; + guchar end = opts[1].val.ival > 255 || opts[1].val.ival < 0 ? 255 : opts[1].val.ival; + guchar out = opts[2].val.ival > 255 || opts[2].val.ival < 0 ? 0 : opts[2].val.ival; + + for (j=0; j < pn_image_data->height; j++) + for (i=0; i < pn_image_data->width; i++) + { + val = pn_image_data->surface[0][PN_IMG_INDEX (i, j)]; + if (val >= begin && val <= end) + pn_image_data->surface[0][PN_IMG_INDEX (i, j)] = out; + } +} + +struct pn_actuator_desc builtin_general_replace = +{ + "general_replace", "Value Replace", "Performs a value replace on a range of values.", + 0, general_replace_opts, + NULL, NULL, general_replace_exec +}; + diff -r 156d6c875ef0 -r 6048abdac7d1 src/paranormal/presets/Makefile --- a/src/paranormal/presets/Makefile Wed Nov 01 13:19:36 2006 -0800 +++ b/src/paranormal/presets/Makefile Wed Nov 01 20:50:58 2006 -0800 @@ -12,6 +12,7 @@ nenolod_-_quakingscope.pnv:$(presetsdir) \ nenolod_-_beatscope.pnv:$(presetsdir) \ nenolod_-_branchscope.pnv:$(presetsdir) \ - nenolod_-_retroscope.pnv:$(presetsdir) + nenolod_-_retroscope.pnv:$(presetsdir) \ + nenolod_-_value_replace_fun.pnv:$(presetsdir) include ../../../mk/objective.mk diff -r 156d6c875ef0 -r 6048abdac7d1 src/paranormal/presets/nenolod_-_value_replace_fun.pnv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/paranormal/presets/nenolod_-_value_replace_fun.pnv Wed Nov 01 20:50:58 2006 -0800 @@ -0,0 +1,31 @@ + + + + + + + 0 + 255 + 151, 179, 234 + + + + -1 + + + 255 + 255 + 180 + + + 0.00000 + 0.00000 + -0.94000 + + + + + 1 + + + \ No newline at end of file