[gimp] app: A few more generic aspect ratio fixes



commit b0d02666a3521d8ed78f92ef23708a4b1a563d0f
Author: Alexia Death <alexiadeath gmail com>
Date:   Fri May 14 20:57:48 2010 +0300

    app: A few more generic aspect ratio fixes

 app/core/gimpbrushgenerated.c |   54 ++++++++++++++++++++++++++++------------
 app/paint/gimpbrushcore.c     |   13 +++++++---
 2 files changed, 47 insertions(+), 20 deletions(-)
---
diff --git a/app/core/gimpbrushgenerated.c b/app/core/gimpbrushgenerated.c
index eb7aec6..65b3ffa 100644
--- a/app/core/gimpbrushgenerated.c
+++ b/app/core/gimpbrushgenerated.c
@@ -300,23 +300,35 @@ gimp_brush_generated_transform_size (GimpBrush *gbrush,
   GimpBrushGenerated *brush = GIMP_BRUSH_GENERATED (gbrush);
   gint                half_width;
   gint                half_height;
+  gdouble             ratio;
 
-  /* Since generated brushes are symmetric the dont have intput
-   * for aspect ratios  < 1.0. its same as rotate by 90 degrees and
-   * 1 / ratio. So we fix the input up for this case.   */
-
-  if (aspect_ratio < 1.0)
+  if (aspect_ratio == 1.0)
     {
-      aspect_ratio = 1.0 / aspect_ratio;
-      angle = angle + 0.25;
+      ratio = brush->aspect_ratio;
     }
+  else
+    {
+      ratio = MIN (aspect_ratio, 20);
+      /* Since generated brushes are symmetric the dont have input
+       * for aspect ratios  < 1.0. its same as rotate by 90 degrees and
+       * 1 / ratio. So we fix the input up for this case.   */
+
+      if (ratio < 1.0)
+        {
+          ratio = MIN (1.0 / ratio, 20);
+          angle = angle + 0.25;
+        }
+    }
+
+
+
 
   gimp_brush_generated_get_half_size (brush,
                                       brush->shape,
                                       brush->radius * scale,
                                       brush->spikes,
                                       brush->hardness,
-                                      MIN (brush->aspect_ratio * aspect_ratio, 20),
+                                      ratio,
                                       (brush->angle + 360 * angle),
                                       &half_width, &half_height,
                                       NULL, NULL, NULL, NULL);
@@ -333,23 +345,33 @@ gimp_brush_generated_transform_mask (GimpBrush *gbrush,
                                      gdouble    hardness)
 {
   GimpBrushGenerated *brush  = GIMP_BRUSH_GENERATED (gbrush);
+  gdouble             ratio;
 
-  /* Since generated brushes are symmetric the dont have intput
-   * for aspect ratios  < 1.0. its same as rotate by extra 90 degrees and
-   * 1 / ratio. So we fix the input up for this case.   */
-
-  if (aspect_ratio < 1.0)
+  if (aspect_ratio == 1.0)
     {
-      aspect_ratio = 1.0 / aspect_ratio;
-      angle = angle + 0.25;
+      ratio = brush->aspect_ratio;
     }
+  else
+    {
+      ratio = MIN (aspect_ratio, 20);
+      /* Since generated brushes are symmetric the dont have input
+       * for aspect ratios  < 1.0. its same as rotate by 90 degrees and
+       * 1 / ratio. So we fix the input up for this case.   */
+
+      if (ratio < 1.0)
+        {
+          ratio = MIN (1.0 / ratio, 20);
+          angle = angle + 0.25;
+        }
+    }
+
 
   return gimp_brush_generated_calc (brush,
                                     brush->shape,
                                     brush->radius * scale ,
                                     brush->spikes,
                                     brush->hardness * hardness,
-                                    brush->aspect_ratio * aspect_ratio,
+                                    ratio,
                                     (brush->angle + 360 * angle),
                                     NULL, NULL);
 }
diff --git a/app/paint/gimpbrushcore.c b/app/paint/gimpbrushcore.c
index 9d6c2f1..737418f 100644
--- a/app/paint/gimpbrushcore.c
+++ b/app/paint/gimpbrushcore.c
@@ -1025,13 +1025,18 @@ gimp_brush_core_transform_bound_segs (GimpBrushCore    *core,
   angle = core->angle;
   aspect_ratio = core->aspect_ratio;
 
-  /* Generated brushes have their aspect ratio appled before base angle */
-  if (aspect_ratio != 1.0 && GIMP_IS_BRUSH_GENERATED (core->main_brush))
+  /* Generated brushes have their angle applied on top of base angle */
+  if (GIMP_IS_BRUSH_GENERATED (core->main_brush))
     {
-      gdouble base_angle = gimp_brush_generated_get_angle (
-                                       GIMP_BRUSH_GENERATED (core->main_brush));
+      GimpBrushGenerated *generated_brush = GIMP_BRUSH_GENERATED (core->main_brush);
+
+      gdouble base_angle = gimp_brush_generated_get_angle (generated_brush);
       angle = angle + base_angle / 360;
+
+      /* Dont apply  the ratio. I wont make sense. The outlines for generated brushes need to be recreated */
+      aspect_ratio = 1.0;
     }
+
   height = core->brush_bound_width;
   width  = core->brush_bound_height;
 



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