changeset 338:d517fc608e89 trunk

[svn] - some more presets - add dynamic colourmap, a scripted colourmap basically.
author nenolod
date Wed, 06 Dec 2006 05:09:57 -0800
parents 5d12ef0b97a5
children d19ac60697ec
files ChangeLog src/paranormal/builtins.c src/paranormal/cmaps.c src/paranormal/presets/Makefile src/paranormal/presets/nenolod_-_kaliedoscope.pnv src/paranormal/presets/nenolod_-_tunnel_vision.pnv
diffstat 6 files changed, 161 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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 <nenolod@nenolod.net>
+  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 <nenolod@nenolod.net>
   revision [736]
   - implement AVS-like Trans / Dynamic Movement
--- 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,
--- 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
+};
--- 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}		\
--- /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 @@
+<?xml version="1.0"?>
+
+<paranormal_preset>
+ <container_simple>
+  <container_once>
+   <cmap_dynamic>
+    <low_index> 0 </low_index>
+    <high_index> 255 </high_index>
+    <script> blue = blue + 0.006999; green = green + 0.007; red = red + 0.004599; </script>
+   </cmap_dynamic>
+  </container_once>
+  <wave_horizontal>
+   <channels> -1 </channels>
+   <value> 255 </value>
+   <lines> TRUE </lines>
+  </wave_horizontal>
+  <xform_movement>
+   <formula>  d=cos(d)^2;  </formula>
+  </xform_movement>
+  <general_blur>
+  </general_blur>
+  <general_blur>
+  </general_blur>
+  <general_fade>
+   <amount> 1 </amount>
+  </general_fade>
+ </container_simple>
+</paranormal_preset>
\ No newline at end of file
--- /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 @@
+<?xml version="1.0"?>
+
+<paranormal_preset>
+ <container_simple>
+  <container_once>
+   <cmap_bwgradient>
+    <low_index> 0 </low_index>
+    <high_index> 255 </high_index>
+    <color> 0, 130, 191 </color>
+   </cmap_bwgradient>
+  </container_once>
+  <wave_horizontal>
+   <channels> -1 </channels>
+   <value> 255 </value>
+   <lines> TRUE </lines>
+  </wave_horizontal>
+  <xform_dynmovement>
+   <init_script> rseek=1.45; dseek=2; </init_script>
+   <frame_script>  </frame_script>
+   <point_script> r=r/rseek; d=d*dseek;  </point_script>
+  </xform_dynmovement>
+  <general_blur>
+  </general_blur>
+  <general_blur>
+  </general_blur>
+  <general_fade>
+   <amount> 2 </amount>
+  </general_fade>
+ </container_simple>
+</paranormal_preset>
\ No newline at end of file