Mercurial > audlegacy-plugins
changeset 182:6048abdac7d1 trunk
[svn] - add value replace filter, replaces a range of values with a different value
- add preset which demonstrates how this can be abused
author | nenolod |
---|---|
date | Wed, 01 Nov 2006 20:50:58 -0800 |
parents | 156d6c875ef0 |
children | 37b53a5a9aa4 |
files | ChangeLog src/paranormal/builtins.c src/paranormal/general.c src/paranormal/presets/Makefile src/paranormal/presets/nenolod_-_value_replace_fun.pnv |
diffstat | 5 files changed, 82 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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 <nenolod@nenolod.net> + 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 <nenolod@nenolod.net> revision [360] - take advantage of the ability to do nothing
--- 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,
--- 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 +}; +
--- 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
--- /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 @@ +<?xml version="1.0"?> + +<paranormal_preset> + <container_simple> + <container_once> + <cmap_bwgradient> + <low_index> 0 </low_index> + <high_index> 255 </high_index> + <color> 151, 179, 234 </color> + </cmap_bwgradient> + </container_once> + <wave_horizontal> + <channels> -1 </channels> + </wave_horizontal> + <general_replace> + <start> 255 </start> + <end> 255 </end> + <out> 180 </out> + </general_replace> + <xform_spin> + <angle> 0.00000 </angle> + <r_add> 0.00000 </r_add> + <r_scale> -0.94000 </r_scale> + </xform_spin> + <general_blur> + </general_blur> + <general_fade> + <amount> 1 </amount> + </general_fade> + </container_simple> +</paranormal_preset> \ No newline at end of file