[gegl/samplers-api-rework: 3/3] fractal-trace: use lohalo with inverse jacobian



commit 3e109ef8c471047def902a1b3ea2f9ae87e9a61a
Author: Ãyvind KolÃs <pippin gimp org>
Date:   Fri Jul 1 04:29:22 2011 +0100

    fractal-trace: use lohalo with inverse jacobian

 operations/workshop/fractal-trace.c |   34 +++++++++++++++++++++++++---------
 1 files changed, 25 insertions(+), 9 deletions(-)
---
diff --git a/operations/workshop/fractal-trace.c b/operations/workshop/fractal-trace.c
index 345da2d..f6f2f21 100644
--- a/operations/workshop/fractal-trace.c
+++ b/operations/workshop/fractal-trace.c
@@ -116,6 +116,7 @@ fractaltrace (GeglBuffer          *input,
               BackgroundType       background_type,
               Babl                *format)
 {
+  GeglMatrix2    inverse_jacobian;
   gint           x, i, offset;
   gdouble        scale_x, scale_y;
   gdouble        cx, cy;
@@ -136,27 +137,42 @@ fractaltrace (GeglBuffer          *input,
       dest[1] = dest[2] = dest[3] = dest[0] = 0.0;
       cx = o->X1 + (x - picture->x) * scale_x;
 
+
+
       switch (fractal_type)
         {
         case FRACTAL_TYPE_JULIA:
-          julia (cx, cy, o->JX, o->JY, &px, &py, o->depth, bailout2);
+#define inverse_map(u,v,ud,vd) {\
+       gdouble rx, ry;\
+       julia (cx, cy, o->JX, o->JY, &rx, &ry, o->depth, bailout2);\
+       ud = (rx - o->X1) / scale_x + picture->x;\
+       vd = (ry - o->Y1) / scale_y + picture->y;\
+      }
+      gegl_compute_inverse_jacobian (inverse_jacobian, x, y);
+      inverse_map(x,y,px,py);
+#undef inverse_map
           break;
 
         case FRACTAL_TYPE_MANDELBROT:
-          julia (cx, cy, cx, cy, &px, &py, o->depth, bailout2);
+#define inverse_map(u,v,ud,vd) {\
+           gdouble rx, ry;\
+           julia (cx, cy, cx, cy, &rx, &ry, o->depth, bailout2);\
+           ud = (rx - o->X1) / scale_x + picture->x;\
+           vd = (ry - o->Y1) / scale_y + picture->y;\
+         }
+      gegl_compute_inverse_jacobian (inverse_jacobian, x, y);
+      inverse_map(x,y,px,py);
+#undef inverse_map
           break;
 
         default:
           g_error (_("Unsupported fractal type"));
         }
 
-      px = (px - o->X1) / scale_x + picture->x;
-      py = (py - o->Y1) / scale_y + picture->y;
-
       if (0 <= px && px < picture->width && 0 <= py && py < picture->height)
         {
-          gegl_buffer_sample (input, px, py, 1.0, dest, format,
-                              GEGL_INTERPOLATION_LINEAR);
+          gegl_buffer_sample2 (input, px, py, &inverse_jacobian, dest, format,
+                               GEGL_INTERPOLATION_LOHALO);
         }
       else
         {
@@ -188,8 +204,8 @@ fractaltrace (GeglBuffer          *input,
                     py = picture->height - 1.0;
                 }
 
-              gegl_buffer_sample (input, px, py, 1.0, dest, format,
-                                  GEGL_INTERPOLATION_LINEAR);
+              gegl_buffer_sample2 (input, px, py, &inverse_jacobian, dest, format,
+                                   GEGL_INTERPOLATION_LOHALO);
               break;
 
             case BACKGROUND_TYPE_TRANSPARENT:



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