[xiph-commits] r11974 - trunk/sushivision

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Tue Oct 31 15:36:04 PST 2006


Author: xiphmont
Date: 2006-10-31 15:36:02 -0800 (Tue, 31 Oct 2006)
New Revision: 11974

Modified:
   trunk/sushivision/mapping.c
   trunk/sushivision/mapping.h
   trunk/sushivision/panel-2d.c
   trunk/sushivision/slider.c
Log:
Add several new color mappings (including overlays)



Modified: trunk/sushivision/mapping.c
===================================================================
--- trunk/sushivision/mapping.c	2006-10-31 22:37:23 UTC (rev 11973)
+++ trunk/sushivision/mapping.c	2006-10-31 23:36:02 UTC (rev 11974)
@@ -24,7 +24,7 @@
 #include <string.h>
 #include "mapping.h"
 
-static u_int32_t scalloped_colorwheel(double val){
+static u_int32_t scalloped_colorwheel(double val, u_int32_t mix){
   if(val<0.)val=0.;
   if(val>1.)val=1.;
   {
@@ -66,8 +66,7 @@
   }
 }
 
-#include <stdio.h>
-static u_int32_t smooth_colorwheel(double val){
+static u_int32_t smooth_colorwheel(double val, u_int32_t mix){
   if(val<0)val=0;
   if(val>1)val=1;
   {
@@ -129,7 +128,7 @@
   }
 }
 
-static u_int32_t grayscale(double val){
+static u_int32_t grayscale(double val, u_int32_t mix){
   if(val<0)val=0;
   if(val>1)val=1;
   {
@@ -138,7 +137,7 @@
   }
 }
 
-static u_int32_t grayscale_cont(double val){
+static u_int32_t grayscale_cont(double val, u_int32_t mix){
   if(val<0)val=0;
   if(val>1)val=1;
   {
@@ -148,19 +147,112 @@
   }
 }
 
-static u_int32_t (*mapfunc[])(double)={
+static u_int32_t red(double val, u_int32_t mix){
+  if(val<0)val=0;
+  if(val>1)val=1;
+  {
+    int g=rint(val*255.);
+    return (g<<16);
+  }
+}
+
+static u_int32_t green(double val, u_int32_t mix){
+  if(val<0)val=0;
+  if(val>1)val=1;
+  {
+    int g=rint(val*255.);
+    return (g<<8);
+  }
+}
+
+static u_int32_t blue(double val, u_int32_t mix){
+  if(val<0)val=0;
+  if(val>1)val=1;
+  {
+    int g=rint(val*255.);
+    return (g);
+  }
+}
+
+static u_int32_t red_overlay(double val, u_int32_t mix){
+  if(val<0)val=0;
+  if(val>1)val=1;
+  {
+    unsigned r = ((mix>>16) & 0xff) + (unsigned )(val*255.);
+    unsigned g = ((mix>>8) & 0xff);
+    unsigned b = ((mix) & 0xff);
+    if(r>255){
+      g -= (r-255);
+      b -= (r-255);
+      r=255;
+    }
+    return  (r<<16)+(g<<8)+b;
+  }
+}
+
+static u_int32_t green_overlay(double val, u_int32_t mix){
+  if(val<0)val=0;
+  if(val>1)val=1;
+  {
+    unsigned r = ((mix>>16) & 0xff);
+    unsigned g = ((mix>>8) & 0xff) + (unsigned )(val*255.);
+    unsigned b = ((mix) & 0xff);
+    if(g>255){
+      r -= (g-255);
+      b -= (g-255);
+      g=255;
+    }
+    return  (r<<16)+(g<<8)+b;
+  }
+}
+
+static u_int32_t blue_overlay(double val, u_int32_t mix){
+  if(val<0)val=0;
+  if(val>1)val=1;
+  {
+    unsigned r = ((mix>>16) & 0xff);
+    unsigned g = ((mix>>8) & 0xff);
+    unsigned b = ((mix) & 0xff) + (unsigned )(val*255.);
+    if(b>255){
+      r -= (b-255);
+      g -= (b-255);
+      b=255;
+    }
+    return  (r<<16)+(g<<8)+b;
+  }
+}
+
+static u_int32_t inactive(double val, u_int32_t mix){
+  return mix;
+}
+
+static u_int32_t (*mapfunc[])(double,u_int32_t)={
+  smooth_colorwheel,
   scalloped_colorwheel,
-  smooth_colorwheel,
   grayscale,
   grayscale_cont,
+  red,
+  green,
+  blue,
+  red_overlay,
+  green_overlay,
+  blue_overlay,
+  inactive
 };
 
 static char *mapnames[]={
+  "smooth colorwheel",
   "scalloped colorwheel",
-  "smooth colorwheel",
   "grayscale",
   "grayscale with contours",
-  0
+  "red",
+  "green",
+  "blue",
+  "red overlay",
+  "green overlay",
+  "blue overlay",
+  "inactive",
+0
 };
 
 int num_mappings(){
@@ -200,14 +292,14 @@
   m->mapfunc = mapfunc[funcnum];
 }
 
-u_int32_t mapping_calc(mapping *m, double in){
+u_int32_t mapping_calc(mapping *m, double in, u_int32_t mix){
   if(m->i_range==0){
     if(in<=m->low)
-      return m->mapfunc(0.);
+      return m->mapfunc(0.,mix);
     else
-      return m->mapfunc(1.);
+      return m->mapfunc(1.,mix);
   }else{
     double val = (in - m->low) * m->i_range;
-    return m->mapfunc(val);
+    return m->mapfunc(val,mix);
   }
 }

Modified: trunk/sushivision/mapping.h
===================================================================
--- trunk/sushivision/mapping.h	2006-10-31 22:37:23 UTC (rev 11973)
+++ trunk/sushivision/mapping.h	2006-10-31 23:36:02 UTC (rev 11974)
@@ -25,7 +25,7 @@
   double low;
   double high;
   double i_range;
-  u_int32_t (*mapfunc)(double val);
+  u_int32_t (*mapfunc)(double val,u_int32_t mix);
 
 } mapping;
 
@@ -35,4 +35,4 @@
 extern void mapping_set_lo(mapping *m, double lo);
 extern void mapping_set_hi(mapping *m, double hi);
 extern void mapping_set_func(mapping *m, int funcnum);
-extern u_int32_t mapping_calc(mapping *m, double in);
+extern u_int32_t mapping_calc(mapping *m, double in, u_int32_t mix);

Modified: trunk/sushivision/panel-2d.c
===================================================================
--- trunk/sushivision/panel-2d.c	2006-10-31 22:37:23 UTC (rev 11973)
+++ trunk/sushivision/panel-2d.c	2006-10-31 23:36:02 UTC (rev 11974)
@@ -80,8 +80,7 @@
 	  
 	  /* map/render result */
 	  if(!isnan(val) && val>=alpha)
-	    render[x] = mapping_calc(p2->mappings+i,val);
-
+	    render[x] = mapping_calc(p2->mappings+i,val,render[x]);
 	}
       }
       
@@ -235,7 +234,7 @@
 	work[j] = val;
 	
 	if(!isnan(val) && val>=alpha)
-	  render[j] = mapping_calc(p2->mappings+i,val);
+	  render[j] = mapping_calc(p2->mappings+i,val,render[j]);
 	
       }
       

Modified: trunk/sushivision/slider.c
===================================================================
--- trunk/sushivision/slider.c	2006-10-31 22:37:23 UTC (rev 11973)
+++ trunk/sushivision/slider.c	2006-10-31 23:36:02 UTC (rev 11974)
@@ -91,8 +91,8 @@
 void slider_draw_background(Slider *s){
   int i;
   GtkWidget *parent=gtk_widget_get_parent(s->slices[0]);
+  GdkColor *fg = &s->slices[0]->style->fg[0];
   GdkColor *bg = &parent->style->bg[0];
-  GdkColor *fg = &s->slices[0]->style->fg[0];
   int textborder=1;
   double textr=1.;
   double textg=1.;
@@ -117,13 +117,19 @@
   cairo_rectangle(c,0,0,w,h);
   cairo_fill(c);
 
+
+  cairo_rectangle (c, x+1, ty, w-2, th);
+  parent_shade(s,c,3);
+  cairo_fill (c);
+  cairo_surface_flush(s->background);
+
   // Create trough innards
  if(s->gradient){
     // background map gradient 
     u_int32_t *pixel=s->backdata+ty*s->w;
     
     for(i=tx;i<tx+tw;i++)
-      pixel[i]=mapping_calc(s->gradient,slider_pixel_to_del(s,0,i));
+      pixel[i]=mapping_calc(s->gradient,slider_pixel_to_del(s,0,i), pixel[i]);
     
     for(i=ty+1;i<ty+th;i++){
       memcpy(pixel+w,pixel,w*4);
@@ -136,10 +142,6 @@
     textg=fg->green;
     textb=fg->blue;
     textborder=0;
- 
-    cairo_rectangle (c, x+1, ty, w-2, th);
-    parent_shade(s,c,3);
-    cairo_fill (c);
   }
 
   // Top shadow 



More information about the commits mailing list