gimp r26577 - in trunk: . plug-ins/common



Author: neo
Date: Fri Aug 15 18:40:20 2008
New Revision: 26577
URL: http://svn.gnome.org/viewvc/gimp?rev=26577&view=rev

Log:
2008-08-15  Sven Neumann  <sven gimp org>

	* plug-ins/common/mosaic.c: formatting.	



Modified:
   trunk/ChangeLog
   trunk/plug-ins/common/mosaic.c

Modified: trunk/plug-ins/common/mosaic.c
==============================================================================
--- trunk/plug-ins/common/mosaic.c	(original)
+++ trunk/plug-ins/common/mosaic.c	Fri Aug 15 18:40:20 2008
@@ -413,31 +413,30 @@
     case GIMP_RUN_NONINTERACTIVE:
       /*  Make sure all the arguments are there!  */
       if (nparams != 15)
-        status = GIMP_PDB_CALLING_ERROR;
-      if (status == GIMP_PDB_SUCCESS)
         {
-          mvals.tile_size = param[3].data.d_float;
-          mvals.tile_height = param[4].data.d_float;
-          mvals.tile_spacing = param[5].data.d_float;
-          mvals.tile_neatness = param[6].data.d_float;
-          mvals.tile_allow_split = (param[7].data.d_int32) ? TRUE : FALSE;
-          mvals.light_dir = param[8].data.d_float;
-          mvals.color_variation = param[9].data.d_float;
-          mvals.antialiasing = (param[10].data.d_int32) ? TRUE : FALSE;
-          mvals.color_averaging = (param[11].data.d_int32) ? TRUE : FALSE;
-          mvals.tile_type = param[12].data.d_int32;
-          mvals.tile_surface = param[13].data.d_int32;
-          mvals.grout_color = param[14].data.d_int32;
-        }
-      if (status == GIMP_PDB_SUCCESS &&
-          (mvals.tile_type < SQUARES || mvals.tile_type > TRIANGLES))
-        status = GIMP_PDB_CALLING_ERROR;
-      if (status == GIMP_PDB_SUCCESS &&
-          (mvals.tile_surface < SMOOTH || mvals.tile_surface > ROUGH))
-        status = GIMP_PDB_CALLING_ERROR;
-      if (status == GIMP_PDB_SUCCESS &&
-          (mvals.grout_color < BW || mvals.grout_color > FG_BG))
-        status = GIMP_PDB_CALLING_ERROR;
+          status = GIMP_PDB_CALLING_ERROR;
+          break;
+        }
+
+      mvals.tile_size = param[3].data.d_float;
+      mvals.tile_height = param[4].data.d_float;
+      mvals.tile_spacing = param[5].data.d_float;
+      mvals.tile_neatness = param[6].data.d_float;
+      mvals.tile_allow_split = (param[7].data.d_int32) ? TRUE : FALSE;
+      mvals.light_dir = param[8].data.d_float;
+      mvals.color_variation = param[9].data.d_float;
+      mvals.antialiasing = (param[10].data.d_int32) ? TRUE : FALSE;
+      mvals.color_averaging = (param[11].data.d_int32) ? TRUE : FALSE;
+      mvals.tile_type = param[12].data.d_int32;
+      mvals.tile_surface = param[13].data.d_int32;
+      mvals.grout_color = param[14].data.d_int32;
+
+      if (mvals.tile_type    < SQUARES || mvals.tile_type    > TRIANGLES ||
+          mvals.tile_surface < SMOOTH  || mvals.tile_surface > ROUGH     ||
+          mvals.grout_color  < BW      || mvals.grout_color  > FG_BG)
+        {
+          status = GIMP_PDB_CALLING_ERROR;
+        }
       break;
 
     case GIMP_RUN_WITH_LAST_VALS:
@@ -1573,7 +1572,7 @@
     }
 
   size = (grid_rows + grid_row_pad) * (grid_cols + grid_col_pad);
-  frac_size = (gint) (size * mvals.color_variation);
+  frac_size = size * mvals.color_variation;
   count = 0;
 
   for (i = -grid_row_pad; i < grid_rows; i++)
@@ -1786,7 +1785,7 @@
           }
 
         if (!preview)
-          gimp_progress_update ((double) count++ / (double) size);
+          gimp_progress_update ((gdouble) count++ / (gdouble) size);
       }
 
   if (preview)
@@ -1796,7 +1795,9 @@
                                 (x2 - x1) * bytes);
     }
   else
-    gimp_progress_update (1.0);
+    {
+      gimp_progress_update (1.0);
+    }
 }
 
 static void
@@ -1833,12 +1834,16 @@
   /*  If the magnitude of direction inside the polygon is greater than
    *  THRESHOLD, split the polygon into two new polygons
    */
-  if (magnitude > MAG_THRESHOLD && (2 * distance / mvals.tile_size) < 0.5 && allow_split)
-    split_poly (poly, drawable, col, dir, color_vary, x1, y1, x2, y2, dest);
-  /*  Otherwise, render the original polygon
-   */
+  if (magnitude > MAG_THRESHOLD &&
+      (2 * distance / mvals.tile_size) < 0.5 && allow_split)
+    {
+      split_poly (poly, drawable, col, dir, color_vary, x1, y1, x2, y2, dest);
+    }
   else
-    render_poly (poly, drawable, col, color_vary, x1, y1, x2, y2, dest);
+    {
+      /*  Otherwise, render the original polygon  */
+      render_poly (poly, drawable, col, color_vary, x1, y1, x2, y2, dest);
+    }
 }
 
 static void
@@ -1852,7 +1857,8 @@
              gint          y2,
              guchar       *dest)
 {
-  gdouble cx = 0.0, cy = 0.0;
+  gdouble cx = 0.0;
+  gdouble cy = 0.0;
 
   polygon_find_center (poly, &cx, &cy);
 
@@ -1881,7 +1887,8 @@
 {
   Polygon new_poly;
   gdouble spacing;
-  gdouble cx = 0.0, cy = 0.0;
+  gdouble cx = 0.0;
+  gdouble cy = 0.0;
   gdouble magnitude;
   gdouble vec[2];
   gdouble pt[2];
@@ -1925,7 +1932,9 @@
     {
       if (mvals.color_averaging)
         find_poly_color (&new_poly, drawable, col, vary, x1, y1, x2, y2);
+
       scale_poly (&new_poly, cx, cy, scale);
+
       if (mvals.color_averaging)
         fill_poly_color (&new_poly, drawable, col, x1, y1, x2, y2, dest);
       else
@@ -1934,10 +1943,10 @@
 }
 
 static void
-clip_poly (gdouble  *dir,
-           gdouble  *pt,
-           Polygon  *poly,
-           Polygon  *poly_new)
+clip_poly (gdouble *dir,
+           gdouble *pt,
+           Polygon *poly,
+           Polygon *poly_new)
 {
   gint    i;
   gdouble x1, y1, x2, y2;
@@ -1976,7 +1985,9 @@
 
   /*  If both points are to be clipped, ignore  */
   if (side1 < 0.0 && side2 < 0.0)
-    return;
+    {
+      return;
+    }
   /*  If both points are non-clipped, set point  */
   else if (side1 >= 0.0 && side2 >= 0.0)
     {
@@ -2016,7 +2027,6 @@
     }
 }
 
-
 static void
 find_poly_dir (Polygon *poly,
                guchar  *m_gr,
@@ -2052,15 +2062,18 @@
   loc[1] = 0.0;
 
   polygon_extents (poly, &dmin_x, &dmin_y, &dmax_x, &dmax_y);
+
   min_x = (gint) dmin_x;
   min_y = (gint) dmin_y;
   max_x = (gint) dmax_x;
   max_y = (gint) dmax_y;
+
   size_y = max_y - min_y;
   size_x = max_x - min_x;
 
   min_scanlines = g_new (gint, size_y);
   max_scanlines = g_new (gint, size_y);
+
   for (i = 0; i < size_y; i++)
     {
       min_scanlines[i] = max_x;
@@ -2157,6 +2170,7 @@
   bytes = drawable->bpp;
 
   polygon_extents (poly, &dmin_x, &dmin_y, &dmax_x, &dmax_y);
+
   min_x = (gint) dmin_x;
   min_y = (gint) dmin_y;
   max_x = (gint) dmax_x;
@@ -2167,6 +2181,7 @@
 
   min_scanlines = g_new (int, size_y);
   max_scanlines = g_new (int, size_y);
+
   for (i = 0; i < size_y; i++)
     {
       min_scanlines[i] = max_x;
@@ -2187,9 +2202,11 @@
   gimp_pixel_rgn_init (&src_rgn, drawable, 0, 0,
                        drawable->width, drawable->height,
                        FALSE, FALSE);
+
   for (i = 0; i < size_y; i++)
     {
       y = i + min_y;
+
       if (y >= y1 && y < y2)
         {
           for (j = min_scanlines[i]; j < max_scanlines[i]; j++)
@@ -2275,30 +2292,30 @@
 
   bytes = drawable->bpp;
 
-  /* begin loop */
-  if(poly_npts) {
-    pts_tmp = poly->pts;
-    xs = (gint) pts_tmp[poly_npts - 1].x;
-    ys = (gint) pts_tmp[poly_npts - 1].y;
-    xe = (gint) pts_tmp->x;
-    ye = (gint) pts_tmp->y;
+  if (poly_npts)
+    {
+      pts_tmp = poly->pts;
+      xs = (gint) pts_tmp[poly_npts - 1].x;
+      ys = (gint) pts_tmp[poly_npts - 1].y;
+      xe = (gint) pts_tmp->x;
+      ye = (gint) pts_tmp->y;
 
-    calc_spec_vec (vecs, xs, ys, xe, ye);
+      calc_spec_vec (vecs, xs, ys, xe, ye);
 
-    for (i = 1; i < poly_npts; i++)
-      {
-        xs = (gint) (pts_tmp->x);
-        ys = (gint) (pts_tmp->y);
-        pts_tmp++;
-        xe = (gint) pts_tmp->x;
-        ye = (gint) pts_tmp->y;
+      for (i = 1; i < poly_npts; i++)
+        {
+          xs = (gint) (pts_tmp->x);
+          ys = (gint) (pts_tmp->y);
+          pts_tmp++;
+          xe = (gint) pts_tmp->x;
+          ye = (gint) pts_tmp->y;
 
-        calc_spec_vec (vecs+i, xs, ys, xe, ye);
-      }
-  }
-  /* end loop */
+          calc_spec_vec (vecs+i, xs, ys, xe, ye);
+        }
+    }
 
   polygon_extents (poly, &dmin_x, &dmin_y, &dmax_x, &dmax_y);
+
   min_x = (gint) dmin_x;
   min_y = (gint) dmin_y;
   max_x = (gint) dmax_x;
@@ -2309,46 +2326,46 @@
 
   min_scanlines = min_scanlines_iter = g_new (gint, size_y);
   max_scanlines = max_scanlines_iter = g_new (gint, size_y);
+
   for (i = 0; i < size_y; i++)
     {
       min_scanlines[i] = max_x * supersample;
       max_scanlines[i] = min_x * supersample;
     }
 
-  /* begin loop */
-  if(poly_npts) {
-    pts_tmp = poly->pts;
-    xs = (gint) pts_tmp[poly_npts-1].x;
-    ys = (gint) pts_tmp[poly_npts-1].y;
-    xe = (gint) pts_tmp->x;
-    ye = (gint) pts_tmp->y;
-
-    xs *= supersample;
-    ys *= supersample;
-    xe *= supersample;
-    ye *= supersample;
+  if(poly_npts)
+    {
+      pts_tmp = poly->pts;
+      xs = (gint) pts_tmp[poly_npts-1].x;
+      ys = (gint) pts_tmp[poly_npts-1].y;
+      xe = (gint) pts_tmp->x;
+      ye = (gint) pts_tmp->y;
 
-    convert_segment (xs, ys, xe, ye, min_y * supersample,
-                     min_scanlines, max_scanlines);
+      xs *= supersample;
+      ys *= supersample;
+      xe *= supersample;
+      ye *= supersample;
 
-    for (i = 1; i < poly_npts; i++)
-      {
-        xs = (gint) pts_tmp->x;
-        ys = (gint) pts_tmp->y;
-        pts_tmp++;
-        xe = (gint) pts_tmp->x;
-        ye = (gint) pts_tmp->y;
-
-        xs *= supersample;
-        ys *= supersample;
-        xe *= supersample;
-        ye *= supersample;
+      convert_segment (xs, ys, xe, ye, min_y * supersample,
+                       min_scanlines, max_scanlines);
 
-        convert_segment (xs, ys, xe, ye, min_y * supersample,
-                         min_scanlines, max_scanlines);
-      }
-  }
-  /* end loop */
+      for (i = 1; i < poly_npts; i++)
+        {
+          xs = (gint) pts_tmp->x;
+          ys = (gint) pts_tmp->y;
+          pts_tmp++;
+          xe = (gint) pts_tmp->x;
+          ye = (gint) pts_tmp->y;
+
+          xs *= supersample;
+          ys *= supersample;
+          xe *= supersample;
+          ye *= supersample;
+
+          convert_segment (xs, ys, xe, ye, min_y * supersample,
+                           min_scanlines, max_scanlines);
+        }
+    }
 
   gimp_pixel_rgn_init (&src_rgn, drawable, 0, 0,
                        drawable->width, drawable->height,
@@ -2381,8 +2398,10 @@
                   if (x >= x1 && x < x2)
                     {
                       val = 0;
+
                       for (k = 0; k < supersample; k++)
                         val += vals[j + k];
+
                       val /= supersample2;
 
                       if (val > 0)
@@ -2468,6 +2487,7 @@
     }
 
   polygon_extents (poly, &dmin_x, &dmin_y, &dmax_x, &dmax_y);
+
   min_x = (gint) dmin_x;
   min_y = (gint) dmin_y;
   max_x = (gint) dmax_x;
@@ -2478,6 +2498,7 @@
 
   min_scanlines = g_new (gint, size_y);
   max_scanlines = g_new (gint, size_y);
+
   for (i = 0; i < size_y; i++)
     {
       min_scanlines[i] = max_x * supersample;
@@ -2507,6 +2528,7 @@
     gimp_pixel_rgn_init (&dest_rgn, drawable, 0, 0,
                          drawable->width, drawable->height,
                          TRUE, TRUE);
+
   vals = g_new (gint, size_x);
   for (i = 0; i < size_y; i++)
     {
@@ -2586,11 +2608,13 @@
 
   vec->base_x = x1;
   vec->base_y = y1;
+
   r = sqrt (SQR (x2 - x1) + SQR (y2 - y1));
+
   if (r > 0.0)
     {
       vec->norm_x = -(y2 - y1) / r;
-      vec->norm_y = (x2 - x1) / r;
+      vec->norm_y =  (x2 - x1) / r;
     }
   else
     {
@@ -2656,12 +2680,14 @@
       tmp = y2; y2 = y1; y1 = tmp;
       tmp = x2; x2 = x1; x1 = tmp;
     }
+
   ydiff = y2 - y1;
 
   if (ydiff)
     {
       xinc = (gdouble) (x2 - x1) / (gdouble) ydiff;
       xstart = x1 + 0.5 * xinc;
+
       for (y = y1; y < y2; y++)
         {
           min[y - offset] = MIN (min[y - offset], xstart);



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