]> Dogcows Code - chaz/openbox/commitdiff
PipeCross
authorDerek Foreman <manmower@gmail.com>
Sun, 18 May 2003 23:31:13 +0000 (23:31 +0000)
committerDerek Foreman <manmower@gmail.com>
Sun, 18 May 2003 23:31:13 +0000 (23:31 +0000)
render/gradient.c
render/test.c

index e669a2c482ae21f848502ee88dd62a2fe22029af..ec653b1e2bcf772de18e058dcf88fb51d63b37d2 100644 (file)
@@ -30,7 +30,7 @@ void gradient_render(Surface *sf, int w, int h)
     gradient_pyramid(sf, w, h);
     break;
   case Background_PipeCross:
-    printf("PipeCross\n");
+    gradient_pipecross(sf, w, h);
     break;
   case Background_Rectangle:
     gradient_rectangle(sf, w, h);
@@ -415,3 +415,46 @@ void gradient_rectangle(Surface *sf, int inw, int inh)
     end-=inw;
   }
 }
+
+void gradient_pipecross(Surface *sf, int inw, int inh)
+{
+  pixel32 *data = sf->data.planar.pixel_data;
+  pixel32 *end = data + inw*inh;
+  pixel32 current;
+  float drx, dgx, dbx, dry, dgy, dby;
+  unsigned int r,g,b;
+  int x, y, h=(inh/2) + 1, w=(inw/2) + 1;
+  int val;
+
+  for (y = 0; y < h; ++y) {
+    drx = (float)(sf->data.planar.secondary->r - sf->data.planar.primary->r);
+    dry = drx/(float)h;
+    drx/= (float)w;
+
+    dgx = (float)(sf->data.planar.secondary->g - sf->data.planar.primary->g);
+    dgy = dgx/(float)h;
+    dgx/= (float)w;
+
+    dbx = (float)(sf->data.planar.secondary->b - sf->data.planar.primary->b);
+    dby = dbx/(float)h;
+    dbx/= (float)w;
+    for (x = 0; x < w; ++x, data) {
+      if ((float)x/(float)w > (float)y/(float)h) val = (int)(drx * x);
+      else val = (int)(dry * y);
+
+      r = sf->data.planar.primary->r + val;
+      g = sf->data.planar.primary->g + val;
+      b = sf->data.planar.primary->b + val;
+      current = (r << default_red_offset)
+              + (g << default_green_offset)
+              + (b << default_blue_offset);
+      *(data+x) = current;
+      *(data+inw-x) = current;
+      *(end-x) = current;
+      *(end-(inw-x)) = current;
+    }
+    data+=inw;
+    end-=inw;
+  }
+}
+
index 98508368737dcb062afe237b4b139fe95b9684f8..d57f2c8b9d27e59cd878a348e149a8eca4f64278 100644 (file)
@@ -52,7 +52,7 @@ int main()
        render_startup();
 
        look = appearance_new(Surface_Planar, 0);
-       look->surface.data.planar.grad = Background_Rectangle;
+       look->surface.data.planar.grad = Background_PipeCross;
        look->surface.data.planar.secondary = color_new(0xFF, 0xFF, 0xFF);
        look->surface.data.planar.primary = color_parse("Black");
         look->surface.data.planar.interlaced = FALSE;
This page took 0.02927 seconds and 4 git commands to generate.