iris-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Iris-devel] pinwheel theme


From: The Speedster
Subject: [Iris-devel] pinwheel theme
Date: Sun, 21 Apr 2002 23:01:12 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.2.1) Gecko/20010901

Hello,

The patch should be attached to this email.

My wife named this, when she saw it in action :)

It is circular, with concentric rings that spin and change height.

--
Ron Lockwood-Childs

Binary files iris-0.9/src/.theme_pinwheel.c.swp and 
iris_new/src/.theme_pinwheel.c.swp differ
diff -urN iris-0.9/src/Makefile.in iris_new/src/Makefile.in
--- iris-0.9/src/Makefile.in    Mon Mar 25 13:43:59 2002
+++ iris_new/src/Makefile.in    Thu Apr 18 23:35:38 2002
@@ -102,7 +102,7 @@
 
 CFLAGS = -Wall @XMMS_CFLAGS@ @CFLAGS@ -I$(top_builddir) -I$(top_srcdir) 
-D_REENTRANT @GTK_CFLAGS@
 
-libiris_la_SOURCES = iris.c config.c color.c 3Dstuff.c theme.c 
theme_original.c theme_spectrum.c theme_spectrotoy.c theme_squarefield.c 
theme_pyramid.c theme_waves.c iris.h
+libiris_la_SOURCES = iris.c config.c color.c 3Dstuff.c theme.c 
theme_original.c theme_spectrum.c theme_spectrotoy.c theme_squarefield.c 
theme_pyramid.c theme_waves.c theme_pinwheel.c iris.h
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
 CONFIG_HEADER = ../config.h
 CONFIG_CLEAN_FILES = 
@@ -115,7 +115,7 @@
 libiris_la_LIBADD = 
 libiris_la_OBJECTS =  iris.lo config.lo color.lo 3Dstuff.lo theme.lo \
 theme_original.lo theme_spectrum.lo theme_spectrotoy.lo \
-theme_squarefield.lo theme_pyramid.lo theme_waves.lo
+theme_squarefield.lo theme_pyramid.lo theme_waves.lo theme_pinwheel.lo
 COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) 
$(CFLAGS)
 LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) 
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
@@ -130,7 +130,7 @@
 DEP_FILES =  .deps/3Dstuff.P .deps/color.P .deps/config.P .deps/iris.P \
 .deps/theme.P .deps/theme_original.P .deps/theme_pyramid.P \
 .deps/theme_spectrotoy.P .deps/theme_spectrum.P \
-.deps/theme_squarefield.P .deps/theme_waves.P
+.deps/theme_squarefield.P .deps/theme_waves.P .deps/theme_pinwheel.P
 SOURCES = $(libiris_la_SOURCES)
 OBJECTS = $(libiris_la_OBJECTS)
 
diff -urN iris-0.9/src/iris.h iris_new/src/iris.h
--- iris-0.9/src/iris.h Tue Apr  9 09:44:15 2002
+++ iris_new/src/iris.h Wed Apr 17 23:30:08 2002
@@ -145,7 +145,7 @@
 extern void bar_full (GLfloat height, xz * xz1, xz * xz2, xz * xz3, xz * xz4);
 
 /* theme.c */
-#define THEME_NUMBER 6
+#define THEME_NUMBER 7 // Added 1 theme 4/17/02 RC
 extern void theme_register (void);
 extern iris_theme theme[THEME_NUMBER];
 
diff -urN iris-0.9/src/theme.c iris_new/src/theme.c
--- iris-0.9/src/theme.c        Tue Apr  9 09:44:47 2002
+++ iris_new/src/theme.c        Thu Apr 18 22:52:03 2002
@@ -25,6 +25,8 @@
 extern iris_theme theme_squarefield;
 extern iris_theme theme_waves;
 extern iris_theme theme_pyramid;
+
+extern iris_theme theme_pinwheel; // added 4/17/02 RC
 iris_theme theme[THEME_NUMBER];
 
 /* this initialize the theme registry */
@@ -37,4 +39,6 @@
   theme[3] = theme_squarefield;
   theme[4] = theme_waves;
   theme[5] = theme_pyramid;
+
+  theme[6] = theme_pinwheel;
 }
diff -urN iris-0.9/src/theme_pinwheel.c iris_new/src/theme_pinwheel.c
--- iris-0.9/src/theme_pinwheel.c       Wed Dec 31 16:00:00 1969
+++ iris_new/src/theme_pinwheel.c       Sun Apr 21 22:48:08 2002
@@ -0,0 +1,341 @@
+/*  Iris - visualization plugin for XMMS
+ *  Copyright (C) 2000-2002 Cédric DELFOSSE (address@hidden)
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/* New Theme created by Ron Lockwood-Childs
+ * Looks best when alpha blending is on
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <GL/gl.h>
+#include <xmms/configfile.h>
+#include "iris.h"
+
+#define NUM_BANDS 16
+
+#define NUM_PER_RING 8
+#define GAP (M_PI_4)
+
+static char *modes_name[] = { "Normal" };
+
+static char pinwheel_priority[] = "pinwheel_priority";
+static char pinwheel_blend[] = "pinwheel_blend";
+
+static void init_draw_mode (void);
+static GLfloat get_x_angle (void);
+static gfloat get_priority (void);
+static void set_new_priority (gfloat);
+static void draw_one_frame (gboolean);
+static void config_read (ConfigFile *, char *);
+static void config_write (ConfigFile *, char *);
+static void config_default (void);
+static void config_create (GtkWidget *);
+static void config_apply (void);
+
+
+iris_theme theme_pinwheel = {
+  "PinWheel",
+  1,
+  modes_name,
+  init_draw_mode,
+  get_x_angle,
+  get_priority,
+  set_new_priority,
+  draw_one_frame,
+  config_read,
+  config_write,
+  config_default,
+  config_create,
+  config_apply
+};
+
+struct
+{
+  gfloat priority;
+  gboolean blend;
+}
+config_pinwheel, new_config_pinwheel;
+
+extern GLfloat data1[16];
+GLfloat data2[NUM_BANDS];  // previous freq band data
+GLfloat angle[NUM_BANDS];  // previous angle data
+GLfloat radii[NUM_BANDS+2] = { 0.0f, 0.5f, 1.0f, 1.5f, 2.0f, 2.5f, 3.0f, 3.5f,
+                               4.0f, 4.5f, 5.0f, 5.5f, 6.0f, 6.5f, 7.0f, 7.5f,
+                               8.0f };
+
+static void
+init_draw_mode ()
+{
+  if (config_pinwheel.blend)
+    {
+      if (!glIsEnabled (GL_BLEND))
+       {
+         glBlendFunc (GL_SRC_ALPHA, GL_ONE);
+         glEnable (GL_BLEND);
+         glDisable (GL_DEPTH_TEST);
+       }
+    }
+  else
+    {
+      if (glIsEnabled (GL_BLEND))
+       {
+         glDisable (GL_BLEND);
+         glEnable (GL_DEPTH_TEST);
+       }
+    }
+}
+
+
+static GLfloat
+get_x_angle ()
+{
+  return (10.0 + (int) (80.0 * rand () / (RAND_MAX + 1.0)));
+}
+
+
+static gfloat
+get_priority ()
+{
+  return (config_pinwheel.priority);
+}
+
+
+static void
+set_new_priority (gfloat f)
+{
+  new_config_pinwheel.priority = f;
+}
+
+
+static void
+draw_one_frame (gboolean beat)
+{
+  int t1, t2;                        // loop vars
+  GLfloat red, green, blue;
+  GLfloat z = 0.0;
+  GLfloat scaler = 2.0f;      // scales the whole field - lower is bigger
+  GLfloat scaleh = 2.0f;      // scales height of the bar - lower is smaller
+  GLfloat xin_up, zin_up, xin_dn, zin_dn, xot_up, zot_up, xot_dn, zot_dn;
+  GLfloat rin, rot;           // radius of inner and outer edges of p-gram
+  GLfloat angle_up, angle_dn; // angles of top and bottom of p-gram
+  GLfloat differ;             // holds the angle increment
+  GLfloat maxdropoff = 0.05;  // smooth changes in heights
+  GLfloat angle_step;
+
+  /* internal routine to shift all data when a new datarow arrives */
+  for (t1 = 0; t1 < 16; t1++)
+    {
+        differ = data2[t1] - data1[t1];
+        // Rotate counter c.w. if differ positive, c.w. if negative
+        angle[t1] += (differ * M_PI_4 / 3.0f); // max angle change = +/- PI/12
+        if (angle[t1] > (2.0f * M_PI))
+        { // cap angle at 360
+            angle[t1] -= (2.0f * M_PI);
+        }
+        else if (angle[t1] < 0)
+        { // keep angle positive
+            angle[t1] += (2.0f * M_PI);
+        }
+
+        // smooth bar height changes
+        if (data1[t1] > data2[t1])
+        {
+            if ((data1[t1] - data2[t1]) > maxdropoff)
+                data2[t1] += maxdropoff;
+            else
+                data2[t1] += data1[t1];
+        }
+        else if (data1[t1] < data2[t1])
+        {
+            if ((data2[t1] - data1[t1]) > maxdropoff)
+                data2[t1] -= maxdropoff;
+            else
+                data2[t1] -= data1[t1];
+        }
+    }
+
+  glBegin (GL_QUADS);
+
+  for (t1 = 0; t1 < 16; t1++)
+    { // iterate thru rings
+
+        // calculate inner and outer radius for this ring of p-grams
+        rin = (radii[t1+1] - ((radii[1] - radii[0]) / 2.0f)) / scaler;
+        rot = (radii[t1+1] + ((radii[1] - radii[0]) / 2.0f)) / scaler;
+        for (t2 = 0; t2 < NUM_PER_RING; t2++)
+        { // iterate thru bars in a single ring
+
+            angle_step = angle[t1] + (t2 * GAP);
+            if (angle_step > (M_PI * 2))
+                angle_step -= (M_PI * 2);
+            else if (angle_step < 0)
+                angle_step += (M_PI * 2);
+            // calculate upper and lower angles for this p-gram
+            angle_up = angle_step + (M_PI_2 / 9.0f);
+            angle_dn = angle_step - (M_PI_2 / 9.0f);
+            // now figure out all the p-gram vertices
+            xin_dn = cos( angle_dn ) * rin;
+            zin_dn = sin( angle_dn ) * rin;
+            xin_up = cos( angle_up ) * rin;
+            zin_up = sin( angle_up ) * rin;
+            xot_dn = cos( angle_dn ) * rot;
+            zot_dn = sin( angle_dn ) * rot;
+            xot_up = cos( angle_up ) * rot;
+            zot_up = sin( angle_up ) * rot;
+
+            // now start drawin'
+            // start with the front, then left, back, right, finally the top
+
+            // "front"
+            get_color( &red, &green, &blue, &data2[t1] ); // top color
+            glColor4f( red / 2.0f, green / 2.0f, blue / 2.0f, 0.5f );
+            glVertex3f( xot_dn, data2[t1] * scaleh, zot_dn ); // "top-right"
+
+            get_color( &red, &green, &blue, &z ); // bottom color
+            glColor4f( red / 2.0f, green / 2.0f, blue / 2.0f, 0.5f );
+            glVertex3f( xot_dn, z, zot_dn ); // "bottom-right"
+            glVertex3f( xin_dn, z, zin_dn ); // "bottom-left"
+
+            get_color( &red, &green, &blue, &data2[t1] ); // top color
+            glColor4f( red / 2.0f, green / 2.0f, blue / 2.0f, 0.5f );
+            glVertex3f( xin_dn, data2[t1] * scaleh, zin_dn ); // "top-left"
+
+            // "left"
+            get_color( &red, &green, &blue, &data2[t1] ); // top color
+            glColor4f( red / 2.0f, green / 2.0f, blue / 2.0f, 0.5f );
+            glVertex3f( xin_dn, data2[t1] * scaleh, zin_dn ); // "top-out"
+
+            get_color( &red, &green, &blue, &z ); // bottom color
+            glColor4f( red / 2.0f, green / 2.0f, blue / 2.0f, 0.5f );
+            glVertex3f( xin_dn, z, zin_dn ); // "bottom-out"
+            glVertex3f( xin_up, z, zin_up ); // "bottom-in"
+
+            get_color( &red, &green, &blue, &data2[t1] ); // top color
+            glColor4f( red / 2.0f, green / 2.0f, blue / 2.0f, 0.5f );
+            glVertex3f( xin_up, data2[t1] * scaleh, zin_up ); // "top-in"
+
+            // "back"
+            get_color( &red, &green, &blue, &data2[t1] ); // top color
+            glColor4f( red / 2.0f, green / 2.0f, blue / 2.0f, 0.5f );
+            glVertex3f( xin_up, data2[t1] * scaleh, zin_up ); // "top-left"
+
+            get_color( &red, &green, &blue, &z ); // bottom color
+            glColor4f( red / 2.0f, green / 2.0f, blue / 2.0f, 0.5f );
+            glVertex3f( xin_up, z, zin_up ); // "bottom-left"
+            glVertex3f( xot_up, z, zot_up ); // "bottom-right"
+
+            get_color( &red, &green, &blue, &data2[t1] ); // top color
+            glColor4f( red / 2.0f, green / 2.0f, blue / 2.0f, 0.5f );
+            glVertex3f( xot_up, data2[t1] * scaleh, zot_up ); // "top-right"
+
+            // "right"
+            get_color( &red, &green, &blue, &data2[t1] ); // top color
+            glColor4f( red / 2.0f, green / 2.0f, blue / 2.0f, 0.5f );
+            glVertex3f( xot_up, data2[t1] * scaleh, zot_up ); // "top-in"
+
+            get_color( &red, &green, &blue, &z ); // bottom color
+            glColor4f( red / 2.0f, green / 2.0f, blue / 2.0f, 0.5f );
+            glVertex3f( xot_up, z, zot_up ); // "bottom-in"
+            glVertex3f( xot_dn, z, zot_dn ); // "bottom-out"
+
+            get_color( &red, &green, &blue, &data2[t1] ); // top color
+            glColor4f( red / 2.0f, green / 2.0f, blue / 2.0f, 0.5f );
+            glVertex3f( xot_dn, data2[t1] * scaleh, zot_dn ); // "top-out"
+
+            // "top"
+            get_color( &red, &green, &blue, &data2[t1] ); // top color
+            glColor4f( red / 2.0f, green / 2.0f, blue / 2.0f, 0.5f );
+            glVertex3f( xot_dn, data2[t1] * scaleh, zot_dn ); // "out-right"
+            glVertex3f( xin_dn, data2[t1] * scaleh, zin_dn ); // "out-left"
+            glVertex3f( xin_up, data2[t1] * scaleh, zin_up ); // "in-left"
+            glVertex3f( xot_up, data2[t1] * scaleh, zot_up ); // "in-right"
+
+        }
+    }
+
+  glEnd ();
+
+}
+
+
+static void
+config_read (ConfigFile * f, char *section_name)
+{
+  xmms_cfg_read_float (f, section_name, pinwheel_priority,
+                      &config_pinwheel.priority);
+  xmms_cfg_read_boolean (f, section_name, pinwheel_blend,
+                        &config_pinwheel.blend);
+}
+
+
+static void
+config_write (ConfigFile * f, char *section_name)
+{
+  xmms_cfg_write_float (f, section_name, pinwheel_priority,
+                       config_pinwheel.priority);
+  xmms_cfg_write_boolean (f, section_name, pinwheel_blend,
+                         config_pinwheel.blend);
+}
+
+
+static void
+config_default ()
+{
+  config_pinwheel.priority = 1.0;
+  config_pinwheel.blend = TRUE;
+}
+
+
+static void
+blending_toggled (GtkWidget * widget, gpointer data)
+{
+  new_config_pinwheel.blend = !new_config_pinwheel.blend;
+}
+
+
+static void
+config_create (GtkWidget * vbox)
+{
+  GtkWidget *hbox;
+  GtkWidget *button;
+
+  memcpy (&new_config_pinwheel, &config_pinwheel,
+         sizeof (new_config_pinwheel));
+
+  /* blend mode */
+  hbox = gtk_hbox_new (FALSE, 2);
+  gtk_widget_show (hbox);
+  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 4);
+
+  button = gtk_check_button_new_with_label ("Alpha blending");
+  gtk_widget_show (button);
+  gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 4);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
+                               new_config_pinwheel.blend);
+  gtk_signal_connect (GTK_OBJECT (button), "toggled",
+                     GTK_SIGNAL_FUNC (blending_toggled), NULL);
+}
+
+
+static void
+config_apply (void)
+{
+  memcpy (&config_pinwheel, &new_config_pinwheel,
+         sizeof (config_pinwheel));
+}

reply via email to

[Prev in Thread] Current Thread [Next in Thread]