changeset 333:afc61c0efc05 trunk

[svn] - add Trans / Movement implementation
author nenolod
date Tue, 05 Dec 2006 02:16:09 -0800
parents 626f9f4d79a8
children a9f1bd76a3e6
files ChangeLog src/paranormal/builtins.c src/paranormal/presets/Makefile src/paranormal/presets/nenolod_-_transform_fun.pnv src/paranormal/xform.c
diffstat 5 files changed, 162 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Dec 05 01:07:41 2006 -0800
+++ b/ChangeLog	Tue Dec 05 02:16:09 2006 -0800
@@ -1,3 +1,18 @@
+2006-12-05 09:07:41 +0000  Kiyoshi Aman <kiyoshi.aman@gmail.com>
+  revision [728]
+  Remove old-style is_our_file() where a new-style is_our_fd() exists
+  
+  trunk/src/alac/plugin.c                |   34 -------------------------------
+  trunk/src/console/Audacious_Driver.cxx |   26 -----------------------
+  trunk/src/mpg123/mpg123.c              |   24 ----------------------
+  trunk/src/paranormal/cfg.c             |    2 -
+  trunk/src/sexypsf/xmms.c               |   25 ----------------------
+  trunk/src/timidity/src/xmms-timidity.c |   36 ---------------------------------
+  trunk/src/timidity/src/xmms-timidity.h |    3 --
+  trunk/src/wavpack/libwavpack.cxx       |    3 --
+  8 files changed, 8 insertions(+), 145 deletions(-)
+
+
 2006-12-04 23:26:12 +0000  William Pitcock <nenolod@nenolod.net>
   revision [726]
   - remove gnomevfs reference
--- a/src/paranormal/builtins.c	Tue Dec 05 01:07:41 2006 -0800
+++ b/src/paranormal/builtins.c	Tue Dec 05 02:16:09 2006 -0800
@@ -50,6 +50,7 @@
 DECLARE_ACTUATOR (xform_ripple);
 DECLARE_ACTUATOR (xform_bump_spin);
 DECLARE_ACTUATOR (xform_halfrender);
+DECLARE_ACTUATOR (xform_movement);
 
 /* **************** builtin_table **************** */
 struct pn_actuator_desc *builtin_table[] =
@@ -91,6 +92,7 @@
   &builtin_xform_ripple,
   &builtin_xform_bump_spin,
   &builtin_xform_halfrender,
+  &builtin_xform_movement,
   /* **************** the end! **************** */
   NULL
 };
--- a/src/paranormal/presets/Makefile	Tue Dec 05 01:07:41 2006 -0800
+++ b/src/paranormal/presets/Makefile	Tue Dec 05 02:16:09 2006 -0800
@@ -4,6 +4,7 @@
 presetsdir = $(pkgdatadir)/paranormal/Presets
 
 OBJECTIVE_DATA = \
+	nazca_-_smoke_on_the_water.pnv:$(presetsdir)	\
 	nenolod_-_3d_wave.pnv:$(presetsdir)		\
 	nenolod_-_purple_flower.pnv:$(presetsdir)	\
 	nenolod_-_bumblebees.pnv:$(presetsdir)		\
@@ -23,6 +24,7 @@
 	nenolod_-_swarm.pnv:$(presetsdir)		\
 	nenolod_-_interlaced.pnv:$(presetsdir)		\
 	nenolod_-_cubism.pnv:$(presetsdir)		\
+	nenolod_-_transform_fun.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_-_transform_fun.pnv	Tue Dec 05 02:16:09 2006 -0800
@@ -0,0 +1,24 @@
+<?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_scope>
+   <init_script> points=512; dt=0.01; t=0; sc=1; </init_script>
+   <frame_script> t=t+dt;dt=0.9*dt+0.001;  </frame_script>
+   <sample_script> x=cos(2*index+t)*0.9*(value*0.5+0.5); y=sin(index*2+t)*0.9*(value*0.5+0.5); </sample_script>
+   <lines> TRUE </lines>
+  </wave_scope>
+  <general_blur>
+  </general_blur>
+  <xform_movement>
+   <formula> r=cos(r*3); d=sin(d*1.1) </formula>
+  </xform_movement>
+ </container_simple>
+</paranormal_preset>
\ No newline at end of file
--- a/src/paranormal/xform.c	Tue Dec 05 01:07:41 2006 -0800
+++ b/src/paranormal/xform.c	Tue Dec 05 02:16:09 2006 -0800
@@ -15,6 +15,8 @@
 #include "actuators.h"
 #include "pn_utils.h"
 
+#include "libcalc/calc.h"
+
 struct xform_vector
 {
   gint32 offset; /* the offset of the top left pixel */
@@ -442,3 +444,120 @@
   0, xform_halfrender_opts,
   NULL, NULL, xform_halfrender_exec
 };
+
+/* **************** xform_movement **************** */
+struct pn_actuator_option_desc xform_movement_opts[] =
+{
+  { "formula", "The formula to evaluate.",
+    OPT_TYPE_STRING, { sval: "d = 0.15;" } },
+  { NULL }
+};
+
+typedef struct {
+  int width, height;                 /* Previous width and height. */
+  struct xform_vector *vfield;
+} PnMovementData;
+
+static void
+xform_movement_init (gpointer *data)
+{
+    *data = g_new0(PnMovementData, 1);
+}
+
+static void
+xform_movement_cleanup (gpointer data)
+{
+    PnMovementData *d = (PnMovementData *) data;
+
+    if (d)
+      {
+         if (d->vfield)
+ 	     g_free (d->vfield);
+         g_free (d);
+      }
+}
+
+static void
+xform_movement_exec (const struct pn_actuator_option *opts,
+		 gpointer odata)
+{
+  PnMovementData *d = (PnMovementData *) odata;
+
+  if (d->width != pn_image_data->width
+      || d->height != pn_image_data->height)
+    {
+      gint i, j;
+      gdouble *rf, *df;
+      gdouble xf, yf;
+      gint xn, yn;
+      expression_t *expr;
+      symbol_dict_t *dict;
+
+      d->width = pn_image_data->width;
+      d->height = pn_image_data->height;
+
+      if (d->vfield)
+        {
+  	  g_free (d->vfield);
+          d->vfield = NULL;
+        }
+
+      if (opts[0].val.sval == NULL)
+        return;
+
+      dict = dict_new();
+      expr = expr_compile_string(opts[0].val.sval, dict);
+      if (!expr)
+        {
+           dict_free(dict);
+           return;
+        }
+
+      rf = dict_variable(dict, "r");
+      df = dict_variable(dict, "d");
+
+      d->vfield = g_malloc (sizeof(struct xform_vector)
+			    * d->width * d->height);
+
+      for (j = 0; j < pn_image_data->height; j++)
+	for (i = 0; i < pn_image_data->width; i++)
+	  {
+            /* Points (xf, yf) must be in a (-1..1) square. */
+            xf = 2.0 * i / (pn_image_data->width - 1) - 1.0;
+            yf = 2.0 * j / (pn_image_data->height - 1) - 1.0;
+
+            /* Now, convert to polar coordinates r and d. */
+            *rf = hypot(xf, yf);
+            *df = atan2(yf, xf);
+
+            /* Run the script. */
+            expr_execute(expr, dict);
+
+            /* Back to (-1..1) square. */
+            xf = (*rf) * cos ((*df));
+            yf = (*rf) * sin ((*df));
+
+            /* Convert back to physical coordinates. */
+            xn = (int)(((xf + 1.0) * (pn_image_data->width - 1) / 2) + 0.5);
+            yn = (int)(((yf + 1.0) * (pn_image_data->height - 1) / 2) + 0.5);
+
+            if (xn < 0 || xn >= pn_image_data->width || yn < 0 || yn >= pn_image_data->height)
+              {
+                xn = i; yn = j;
+              }
+
+	    xfvec (xn, yn, &d->vfield[PN_IMG_INDEX (i, j)]);
+	  }
+    }
+
+  apply_xform (d->vfield);
+  pn_swap_surfaces ();
+}
+
+struct pn_actuator_desc builtin_xform_movement =
+{
+  "xform_movement", "Movement Transform",
+  "A customizable blitter.",
+  0, xform_movement_opts,
+  xform_movement_init, xform_movement_cleanup, xform_movement_exec
+};