--- gtkhsv-old.c	2004-01-09 15:53:58.000000000 +0100
+++ gtkhsv.c	2004-01-10 14:42:50.000000000 +0100
@@ -916,11 +916,11 @@
 /* Paints the hue ring */
 static void
 paint_ring (GtkHSV      *hsv,
-	    GdkDrawable *drawable,
-	    gint         x,
-	    gint         y,
-	    gint         width,
-	    gint         height)
+            GdkDrawable *drawable,
+            gint         x,
+            gint         y,
+            gint         width,
+            gint         height)
 {
   HSVPrivate *priv;
   int xx, yy;
@@ -930,104 +930,178 @@
   guchar *buf, *p;
   gdouble angle;
   gdouble hue;
-  gdouble r, g, b;
-  GdkBitmap *mask;
+  gdouble r, g, b, alpha;
   GdkGC *gc;
   GdkColor color;
-  
+
   priv = hsv->priv;
-  
+
   center = priv->size / 2.0;
-  
+
   outer = priv->size / 2.0;
   inner = outer - priv->ring_width;
-  
-  /* Paint the ring */
-  
-  buf = g_new (guchar, width * height * 3);
-  
-  for (yy = 0; yy < height; yy++)
-    {
-      p = buf + yy * width * 3;
-      
-      dy = -(yy + y - center);
-      
-      for (xx = 0; xx < width; xx++)
-	{
-	  dx = xx + x - center;
-	  
-	  dist = dx * dx + dy * dy;
-	  if (dist < ((inner-1) * (inner-1)) || dist > ((outer+1) * (outer+1)))
-	    {
-	      *p++ = 0;
-	      *p++ = 0;
-	      *p++ = 0;
-	      continue;
-	    }
-	  
-	  angle = atan2 (dy, dx);
-	  if (angle < 0.0)
-	    angle += 2.0 * G_PI;
-	  
-	  hue = angle / (2.0 * G_PI);
-	  
-	  r = hue;
-	  g = 1.0;
-	  b = 1.0;
-	  hsv_to_rgb (&r, &g, &b);
-	  
-	  *p++ = floor (r * 255 + 0.5);
-	  *p++ = floor (g * 255 + 0.5);
-	  *p++ = floor (b * 255 + 0.5);
-	}
-    }
-  
-  /* Create clipping mask */
-  
-  mask = gdk_pixmap_new (GTK_WIDGET (hsv)->window, width, height, 1);
 
-  gc = gdk_gc_new (mask);
-  
-  color.pixel = 0;
-  gdk_gc_set_foreground (gc, &color);
-  gdk_draw_rectangle (mask, gc, TRUE,
-		      0, 0, width, height);
-  
-  
-  color.pixel = 1;
-  gdk_gc_set_foreground (gc, &color);
-  gdk_draw_arc (mask, gc, TRUE,
-		-x, -y,
-		priv->size - 1, priv->size - 1,
-		0, 360 * 64);
-  
-  color.pixel = 0;
-  gdk_gc_set_foreground (gc, &color);
-  gdk_draw_arc (mask, gc, TRUE,
-		-x + priv->ring_width - 1, -y + priv->ring_width - 1,
-		priv->size - 2 * priv->ring_width + 1, priv->size - 2 * priv->ring_width + 1,
-		0, 360 * 64);
-  
-  g_object_unref (gc);
-  
-  gdk_gc_set_clip_mask (priv->gc, mask);
-  gdk_gc_set_clip_origin (priv->gc, 0, 0);
-  
-  /* Draw ring */
-  
-  gdk_draw_rgb_image_dithalign (drawable, priv->gc, 0, 0, width, height,
-				GDK_RGB_DITHER_MAX,
-				buf,
-				width * 3,
-				x, y);
-  
+
+
+  {
+    int u,v,xx,yy,alphames;
+    gdouble r;
+    int inrad,outrad;
+    const gdouble out = 0.15;
+    guchar *py,*p;
+    GdkPixbuf *pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, 1,
+                                       8,
+                                       width, height);
+    py = (guchar*)gdk_pixbuf_get_pixels(pixbuf);
+    memset(py, 0, width*height*4);
+    yy = y - center;
+    inrad = inner*inner;
+    outrad = outer*outer;
+    alphames = 0;
+    for(; yy < y-center+height; yy++,
+        py += gdk_pixbuf_get_rowstride(pixbuf))
+      {
+        xx = x - center;
+        p = py;
+        for(; xx < x-center+width; xx++, p+=4)
+          {
+            r = (xx+.5)*(xx+.5)+(yy+.5)*(yy+.5);
+            if (r > outrad || r < inrad)
+              continue;
+
+            angle = atan2 (-yy, xx);
+            if (angle < 0.0)
+              angle += 2.0 * G_PI;
+
+            hue = angle / (2.0 * G_PI);
+
+            r = hue;
+            g = 1.0;
+            b = 1.0;
+            hsv_to_rgb (&r, &g, &b);
+            alpha = 0.0;
+
+            if ( fabs(((double)(r - inrad))/(outrad-inrad)-0.5) < 0.5-out)
+              alpha = 1.0;
+            else
+              { // Supersample
+                const int sampling = 5;
+                const gdouble sample = 1.0 / (2*(sampling + 1));
+                gdouble rad,ru,rv,stepru,scale;
+                rv=yy+sample;
+                u = 0;
+                v = 0;
+                stepru = 2*sample;
+                while(v < sampling)
+                  {
+                    ru=xx+sample;
+                    while(u < sampling)
+                      {
+                        rad = ru*ru+rv*rv;
+                        scale = (rad - inrad)/(outrad - inrad);
+                        if (scale > out && scale < 1.0 - out)
+                          alpha += 1.0/(sampling);
+                        else if (scale >= 0.0 && scale <= out)
+                          alpha += scale/out * 1.0/(sampling);
+                        else if (scale >= 1.0-out && scale <= 1.0)
+                          alpha += (1.0-scale)/out * 1.0/(sampling);
+                        ru += stepru;
+                        u++;
+                      }
+                    rv += 2*sample;
+                    v++;
+                  }
+
+              }
+#if 0
+            // Gamma correction, i don't know
+	    // a lot about it and it consume too much CPU
+            alpha = pow(alpha, 1.0/1.2);
+#endif
+
+            p[0] = floor (r * 255 + 0.5);
+            p[1] = floor (g * 255 + 0.5);
+            p[2] = floor (b * 255 + 0.5);
+            p[3] = floor (alpha * 255 + 0.5);
+          }
+      }
+    if (GTK_WIDGET_HAS_FOCUS (hsv) &&
+        priv->focus_on_ring)
+      {
+
+        inrad = (outer-2)*(outer-2);
+        outrad = (outer)*(outer);
+        py = (guchar*)gdk_pixbuf_get_pixels(pixbuf);
+        yy = y - center;
+        for(; yy < y-center+height; yy++,
+            py += gdk_pixbuf_get_rowstride(pixbuf))
+          {
+            gdouble oldalpha;
+            xx = x - center;
+            p = py;
+            for(; xx < x-center+width; xx++, p+=4 )
+              {
+                r = (xx+.5)*(xx+.5)+(yy+0.5)*(yy+0.5);
+                if (r > outrad+4*(outer+4)+4 || r < inrad-4*(outer+2)+4)
+                  continue;
+                angle = atan2(yy,xx);
+                angle *= 50;
+
+                r = g = b = sin(angle)*sin(angle);
+                alpha = 0.0;
+
+                { // Supersample
+                  const int sampling = 5;
+                  const gdouble out = 0.1;
+                  const gdouble sample = 1.0 / (2*(sampling + 1));
+                  gdouble rad,ru,rv,stepru,scale;
+                  rv=yy+sample;
+                  u = 0;
+                  v = 0;
+                  stepru = 2*sample;
+                  while(v < sampling)
+                    {
+                      ru=xx+sample;
+                      while(u < sampling)
+                        {
+                          rad = ru*ru+rv*rv;
+                          scale = (rad - inrad)/(outrad - inrad);
+                          if (scale > out && scale < 1.0 - out)
+                            alpha += 1.0/(sampling);
+                          else if (scale > 0 && scale < out)
+                            alpha += scale/out * 1.0/(sampling);
+                          else if (scale > 1.0-out && scale < 1.0)
+                            alpha += (1.0-scale)/out * 1.0/(sampling);
+                          ru += stepru;
+                          u++;
+                        }
+                      rv += 2*sample;
+                      v++;
+                    }
+                }
+                oldalpha = ((double)p[3])/255.0;
+
+                p[0] = floor ((r * 255 - p[0]) * alpha + p[0] + 0.5);
+                p[1] = floor ((g * 255 - p[1]) * alpha + p[1] + 0.5);
+                p[2] = floor ((b * 255 - p[2]) * alpha + p[2] + 0.5);
+                alpha = (alpha - oldalpha)*alpha+oldalpha;
+                alpha = pow(alpha, 1.0/1.2);
+                p[3] = floor (alpha * 255 + 0.5);
+              }
+          }
+      }
+    gdk_draw_pixbuf(drawable, priv->gc, pixbuf, 0, 0, 0, 0,
+                    width, height, GDK_RGB_DITHER_MAX, x, y);
+    g_object_unref (pixbuf);
+  }
+
   /* Draw value marker */
-  
+
   r = priv->h;
   g = 1.0;
   b = 1.0;
   hsv_to_rgb (&r, &g, &b);
-  
+
   if (INTENSITY (r, g, b) > 0.5)
     {
       color.red = 0x0000;
@@ -1042,39 +1116,11 @@
     }
 
   gdk_gc_set_rgb_fg_color (priv->gc, &color);
-  
-  gdk_draw_line (drawable, priv->gc,
-		 -x + center, -y + center,
-		 -x + center + cos (priv->h * 2.0 * G_PI) * center,
-		 -y + center - sin (priv->h * 2.0 * G_PI) * center);
-  
-  gdk_gc_set_clip_mask (priv->gc, NULL);
-  g_object_unref (mask);
-  
-  g_free (buf);
-  
-  /* Draw ring outline */
 
-  if (GTK_WIDGET_HAS_FOCUS (hsv) &&
-      priv->focus_on_ring)
-    {
-      gint focus_width;
-      gint focus_halfwidth;
-      GdkGC *gc = gtk_hsv_get_focus_gc (hsv, &focus_width);
-      focus_halfwidth = (focus_width + 1) / 2;
-      
-      gdk_draw_arc (drawable, gc, FALSE,
-                    -x + focus_width/2, -y + focus_width/2,
-                    priv->size - focus_width, priv->size - focus_width,
-                    0, 360 * 64);
-      gdk_draw_arc (drawable, gc, FALSE,
-                    -x + priv->ring_width - focus_halfwidth, -y + priv->ring_width - focus_halfwidth,
-                    priv->size - 2 * priv->ring_width + focus_width,
-		    priv->size - 2 * priv->ring_width + focus_width,
-                    0, 360 * 64);
-      
-      g_object_unref (gc);
-    }
+  gdk_draw_line (drawable, priv->gc,
+                 -x + center, -y + center,
+                 -x + center + cos (priv->h * 2.0 * G_PI) * center,
+                 -y + center - sin (priv->h * 2.0 * G_PI) * center);
 }
 
 /* Converts an HSV triplet to an integer RGB triplet */
