gimp r28036 - in trunk: . app/core app/paint



Author: neo
Date: Sat Feb 14 22:00:48 2009
New Revision: 28036
URL: http://svn.gnome.org/viewvc/gimp?rev=28036&view=rev

Log:
2009-02-14  Sven Neumann  <sven gimp org>

	Bug 99457 â Support for dynamics on tilt

	* app/core/gimpbrush.[ch]
	* app/core/gimpbrushgenerated.c
	* app/core/gimpbrush-transform.[ch]
	* app/paint/gimpbrushcore.c
	* app/paint/gimpsmudge.c: applied patch from Alexia Death,
	separates brush scaling for x and y.



Modified:
   trunk/ChangeLog
   trunk/app/core/gimpbrush-transform.c
   trunk/app/core/gimpbrush-transform.h
   trunk/app/core/gimpbrush.c
   trunk/app/core/gimpbrush.h
   trunk/app/core/gimpbrushgenerated.c
   trunk/app/paint/gimpbrushcore.c
   trunk/app/paint/gimpsmudge.c

Modified: trunk/app/core/gimpbrush-transform.c
==============================================================================
--- trunk/app/core/gimpbrush-transform.c	(original)
+++ trunk/app/core/gimpbrush-transform.c	Sat Feb 14 22:00:48 2009
@@ -34,7 +34,8 @@
 /*  local function prototypes  */
 
 static void  gimp_brush_transform_matrix       (GimpBrush         *brush,
-                                                gdouble            scale,
+                                                gdouble            scale_x,
+                                                gdouble            scale_y,
                                                 gdouble            angle,
                                                 GimpMatrix3       *matrix);
 static void  gimp_brush_transform_bounding_box (GimpBrush         *brush,
@@ -49,7 +50,8 @@
 
 void
 gimp_brush_real_transform_size (GimpBrush *brush,
-                                gdouble    scale,
+                                gdouble    scale_x,
+                                gdouble    scale_y,
                                 gdouble    angle,
                                 gint      *width,
                                 gint      *height)
@@ -57,13 +59,14 @@
   GimpMatrix3 matrix;
   gint        x, y;
 
-  gimp_brush_transform_matrix (brush, scale, angle, &matrix);
+  gimp_brush_transform_matrix (brush, scale_x, scale_y, angle, &matrix);
   gimp_brush_transform_bounding_box (brush, &matrix, &x, &y, width, height);
 }
 
 TempBuf *
 gimp_brush_real_transform_mask (GimpBrush *brush,
-                                gdouble    scale,
+                                gdouble    scale_x,
+                                gdouble    scale_y,
                                 gdouble    angle)
 {
   TempBuf      *result;
@@ -76,7 +79,7 @@
   gint          dest_height;
   gint          x, y;
 
-  gimp_brush_transform_matrix (brush, scale, angle, &matrix);
+  gimp_brush_transform_matrix (brush, scale_x, scale_y, angle, &matrix);
 
   if (gimp_matrix3_is_identity (&matrix))
     return temp_buf_copy (brush->mask, NULL);
@@ -125,7 +128,8 @@
 
 TempBuf *
 gimp_brush_real_transform_pixmap (GimpBrush *brush,
-                                  gdouble    scale,
+                                  gdouble    scale_x,
+                                  gdouble    scale_y,
                                   gdouble    angle)
 {
   TempBuf      *result;
@@ -138,7 +142,7 @@
   gint          dest_height;
   gint          x, y;
 
-  gimp_brush_transform_matrix (brush, scale, angle, &matrix);
+  gimp_brush_transform_matrix (brush, scale_x, scale_y, angle, &matrix);
 
   if (gimp_matrix3_is_identity (&matrix))
     return temp_buf_copy (brush->pixmap, NULL);
@@ -196,7 +200,8 @@
 
 static void
 gimp_brush_transform_matrix (GimpBrush   *brush,
-                             gdouble      scale,
+                             gdouble      scale_x,
+                             gdouble      scale_y,
                              gdouble      angle,
                              GimpMatrix3 *matrix)
 {
@@ -207,7 +212,7 @@
   gimp_matrix3_translate (matrix, - center_x, - center_x);
   gimp_matrix3_rotate (matrix, -2 * G_PI * angle);
   gimp_matrix3_translate (matrix, center_x, center_y);
-  gimp_matrix3_scale (matrix, scale, scale);
+  gimp_matrix3_scale (matrix, scale_x, scale_y);
 }
 
 static void

Modified: trunk/app/core/gimpbrush-transform.h
==============================================================================
--- trunk/app/core/gimpbrush-transform.h	(original)
+++ trunk/app/core/gimpbrush-transform.h	Sat Feb 14 22:00:48 2009
@@ -24,15 +24,18 @@
 /*  virtual functions of GimpBrush, don't call directly  */
 
 void      gimp_brush_real_transform_size   (GimpBrush *brush,
-                                            gdouble    scale,
+                                            gdouble    scale_x,
+                                            gdouble    scale_y,
                                             gdouble    angle,
                                             gint      *scaled_width,
                                             gint      *scaled_height);
 TempBuf * gimp_brush_real_transform_mask   (GimpBrush *brush,
-                                            gdouble    scale,
+                                            gdouble    scale_x,
+                                            gdouble    scale_y,
                                             gdouble    angle);
 TempBuf * gimp_brush_real_transform_pixmap (GimpBrush *brush,
-                                            gdouble    scale,
+                                            gdouble    scale_x,
+                                            gdouble    scale_y,
                                             gdouble    angle);
 
 

Modified: trunk/app/core/gimpbrush.c
==============================================================================
--- trunk/app/core/gimpbrush.c	(original)
+++ trunk/app/core/gimpbrush.c	Sat Feb 14 22:00:48 2009
@@ -276,13 +276,13 @@
 
       if (scale != 1.0)
         {
-          mask_buf = gimp_brush_transform_mask (brush, scale, 0.0);
+          mask_buf = gimp_brush_transform_mask (brush, scale, scale, 0.0);
 
           if (! mask_buf)
             mask_buf = temp_buf_new (1, 1, 1, 0, 0, transp);
 
           if (pixmap_buf)
-            pixmap_buf = gimp_brush_transform_pixmap (brush, scale, 0.0);
+            pixmap_buf = gimp_brush_transform_pixmap (brush, scale, scale, 0.0);
 
           mask_width  = mask_buf->width;
           mask_height = mask_buf->height;
@@ -457,17 +457,19 @@
 
 void
 gimp_brush_transform_size (GimpBrush     *brush,
-                           gdouble        scale,
+                           gdouble        scale_x,
+                           gdouble        scale_y,
                            gdouble        angle,
                            gint          *width,
                            gint          *height)
 {
   g_return_if_fail (GIMP_IS_BRUSH (brush));
-  g_return_if_fail (scale > 0.0);
+  g_return_if_fail (scale_x > 0.0);
+  g_return_if_fail (scale_y > 0.0);
   g_return_if_fail (width != NULL);
   g_return_if_fail (height != NULL);
 
-  if ((scale == 1.0) && ((angle == 0.0) || (angle == 0.5) || (angle == 1.0)))
+  if ((scale_x == 1.0) && (scale_y == 1.0) && ((angle == 0.0) || (angle == 0.5) || (angle == 1.0)))
     {
       *width  = brush->mask->width;
       *height = brush->mask->height;
@@ -475,36 +477,41 @@
       return;
     }
 
-  GIMP_BRUSH_GET_CLASS (brush)->transform_size (brush, scale, angle, width, height);
+  GIMP_BRUSH_GET_CLASS (brush)->transform_size (brush, scale_x, scale_y, angle, width, height);
 }
 
 TempBuf *
 gimp_brush_transform_mask (GimpBrush *brush,
-                           gdouble    scale,
+                           gdouble    scale_x,
+                           gdouble    scale_y,
                            gdouble    angle)
 {
   g_return_val_if_fail (GIMP_IS_BRUSH (brush), NULL);
-  g_return_val_if_fail (scale > 0.0, NULL);
+  g_return_val_if_fail (scale_x > 0.0, NULL);
+  g_return_val_if_fail (scale_y > 0.0, NULL);
 
-  if ((scale == 1.0) && (angle == 0.0))
+  if ((scale_x == 1.0) && (scale_y == 1.0) && (angle == 0.0))
     return temp_buf_copy (brush->mask, NULL);
 
-  return GIMP_BRUSH_GET_CLASS (brush)->transform_mask (brush, scale, angle);
+  return GIMP_BRUSH_GET_CLASS (brush)->transform_mask (brush, scale_x, scale_y, angle);
 }
 
 TempBuf *
 gimp_brush_transform_pixmap (GimpBrush *brush,
-                             gdouble    scale,
+                             gdouble    scale_x,
+                             gdouble    scale_y,
                              gdouble    angle)
 {
   g_return_val_if_fail (GIMP_IS_BRUSH (brush), NULL);
   g_return_val_if_fail (brush->pixmap != NULL, NULL);
-  g_return_val_if_fail (scale > 0.0, NULL);
+  g_return_val_if_fail (scale_x > 0.0, NULL);
+  g_return_val_if_fail (scale_y > 0.0, NULL);
 
-  if ((scale == 1.0) && (angle == 0.0))
+
+  if ((scale_x == 1.0) && (scale_y == 1.0) && (angle == 0.0))
     return temp_buf_copy (brush->pixmap, NULL);
 
-  return GIMP_BRUSH_GET_CLASS (brush)->transform_pixmap (brush, scale, angle);
+  return GIMP_BRUSH_GET_CLASS (brush)->transform_pixmap (brush, scale_x, scale_y, angle);
 }
 
 TempBuf *

Modified: trunk/app/core/gimpbrush.h
==============================================================================
--- trunk/app/core/gimpbrush.h	(original)
+++ trunk/app/core/gimpbrush.h	Sat Feb 14 22:00:48 2009
@@ -57,15 +57,18 @@
                                     GimpCoords *last_coords,
                                     GimpCoords *cur_coords);
   void        (* transform_size)   (GimpBrush  *brush,
-                                    gdouble     scale,
+                                    gdouble     scale_x,
+                                    gdouble     scale_y,
                                     gdouble     angle,
                                     gint       *width,
                                     gint       *height);
   TempBuf   * (* transform_mask)   (GimpBrush  *brush,
-                                    gdouble     scale,
+                                    gdouble     scale_x,
+                                    gdouble     scale_y,
                                     gdouble     angle);
   TempBuf   * (* transform_pixmap) (GimpBrush  *brush,
-                                    gdouble     scale,
+                                    gdouble     scale_x,
+                                    gdouble     scale_y,
                                     gdouble     angle);
 
   /*  signals  */
@@ -87,15 +90,18 @@
 
 /* Gets width and height of a transformed mask of the brush, for provided parameters. */
 void        gimp_brush_transform_size   (GimpBrush        *brush,
-                                         gdouble           scale,
+                                         gdouble           scale_x,
+                                         gdouble           scale_y,
                                          gdouble           angle,
                                          gint             *width,
                                          gint             *height);
 TempBuf   * gimp_brush_transform_mask   (GimpBrush        *brush,
-                                         gdouble           scale,
+                                         gdouble           scale_x,
+                                         gdouble           scale_y,
                                          gdouble           angle);
 TempBuf   * gimp_brush_transform_pixmap (GimpBrush        *brush,
-                                         gdouble           scale,
+                                         gdouble           scale_x,
+                                         gdouble           scale_y,
                                          gdouble           angle);
 
 TempBuf   * gimp_brush_get_mask         (const GimpBrush  *brush);

Modified: trunk/app/core/gimpbrushgenerated.c
==============================================================================
--- trunk/app/core/gimpbrushgenerated.c	(original)
+++ trunk/app/core/gimpbrushgenerated.c	Sat Feb 14 22:00:48 2009
@@ -64,12 +64,14 @@
 static GimpData    * gimp_brush_generated_duplicate     (GimpData     *data);
 
 static void          gimp_brush_generated_transform_size(GimpBrush    *gbrush,
-                                                         gdouble       scale,
+                                                         gdouble       scale_x,
+                                                         gdouble       scale_y,
                                                          gdouble       angle,
                                                          gint         *width,
                                                          gint         *height);
 static TempBuf     * gimp_brush_generated_transform_mask(GimpBrush    *gbrush,
-                                                         gdouble       scale,
+                                                         gdouble       scale_x,
+                                                         gdouble       scale_y,
                                                          gdouble       angle);
 
 static TempBuf     * gimp_brush_generated_calc          (GimpBrushGenerated      *brush,
@@ -280,7 +282,8 @@
 
 static void
 gimp_brush_generated_transform_size (GimpBrush *gbrush,
-                                     gdouble    scale,
+                                     gdouble    scale_x,
+                                     gdouble    scale_y,
                                      gdouble    angle,
                                      gint      *width,
                                      gint      *height)
@@ -291,10 +294,10 @@
 
   gimp_brush_generated_get_half_size (brush,
                                       brush->shape,
-                                      brush->radius * scale,
+                                      brush->radius * (scale_x + scale_y) / 2,
                                       brush->spikes,
                                       brush->hardness,
-                                      brush->aspect_ratio,
+                                      brush->aspect_ratio * scale_x / scale_y,
                                       (brush->angle + 360 * angle),
                                       &half_width, &half_height,
                                       NULL, NULL, NULL, NULL);
@@ -305,17 +308,18 @@
 
 static TempBuf *
 gimp_brush_generated_transform_mask (GimpBrush *gbrush,
-                                     gdouble    scale,
+                                     gdouble    scale_x,
+                                     gdouble    scale_y,
                                      gdouble    angle)
 {
   GimpBrushGenerated *brush  = GIMP_BRUSH_GENERATED (gbrush);
 
   return gimp_brush_generated_calc (brush,
                                     brush->shape,
-                                    brush->radius * scale,
+                                    brush->radius * (scale_x + scale_y) / 2,
                                     brush->spikes,
                                     brush->hardness,
-                                    brush->aspect_ratio,
+                                    brush->aspect_ratio * scale_x / scale_y,
                                     (brush->angle + 360 * angle),
                                     NULL, NULL);
 }

Modified: trunk/app/paint/gimpbrushcore.c
==============================================================================
--- trunk/app/paint/gimpbrushcore.c	(original)
+++ trunk/app/paint/gimpbrushcore.c	Sat Feb 14 22:00:48 2009
@@ -716,7 +716,7 @@
 
   core->scale = gimp_brush_core_clamp_brush_scale (core, core->scale);
 
-  gimp_brush_transform_size (core->brush, core->scale, core->angle, &brush_width, &brush_height);
+  gimp_brush_transform_size (core->brush, core->scale, core->scale, core->angle, &brush_width, &brush_height);
 
   /*  adjust the x and y coordinates to the upper left corner of the brush  */
   x = (gint) floor (paint_core->cur_coords.x) - (brush_width  / 2);
@@ -809,7 +809,7 @@
     {
       scale = gimp_brush_core_clamp_brush_scale (core, scale);
 
-      mask = gimp_brush_transform_mask (core->main_brush, scale, angle);
+      mask = gimp_brush_transform_mask (core->main_brush, scale, scale, angle);
     }
 
   if (mask)
@@ -1314,7 +1314,7 @@
   if ((core->scale == 1.0) && (core->angle == 0.0))
     return brush->mask;
 
-  gimp_brush_transform_size (brush, core->scale, core->angle, &width, &height);
+  gimp_brush_transform_size (brush, core->scale, core->scale, core->angle, &width, &height);
 
     if (! core->cache_invalid                      &&
       core->transform_brush                      &&
@@ -1337,7 +1337,7 @@
   if (core->transform_brush)
     temp_buf_free (core->transform_brush);
 
-  core->transform_brush = gimp_brush_transform_mask (brush, core->scale, core->angle);
+  core->transform_brush = gimp_brush_transform_mask (brush, core->scale, core->scale, core->angle);
 
   core->cache_invalid       = TRUE;
   core->solid_cache_invalid = TRUE;
@@ -1358,7 +1358,7 @@
   if ((core->scale == 1.0) && (core->angle == 0.0))
     return brush->pixmap;
 
-  gimp_brush_transform_size (brush, core->scale, core->angle, &width, &height);
+  gimp_brush_transform_size (brush, core->scale, core->scale, core->angle, &width, &height);
 
 
   if (! core->cache_invalid                              &&
@@ -1380,7 +1380,7 @@
     temp_buf_free (core->transform_pixmap);
 
 
-  core->transform_pixmap = gimp_brush_transform_pixmap (brush, core->scale, core->angle);
+  core->transform_pixmap = gimp_brush_transform_pixmap (brush, core->scale, core->scale, core->angle);
 
   core->cache_invalid = TRUE;
 

Modified: trunk/app/paint/gimpsmudge.c
==============================================================================
--- trunk/app/paint/gimpsmudge.c	(original)
+++ trunk/app/paint/gimpsmudge.c	Sat Feb 14 22:00:48 2009
@@ -328,8 +328,10 @@
   gint           width;
   gint           height;
 
-  gimp_brush_transform_size (brush_core->brush, brush_core->scale,
-                             brush_core->angle, &width, &height);
+  gimp_brush_transform_size (brush_core->brush,
+                             brush_core->scale, brush_core->scale,
+                             brush_core->angle,
+                             &width, &height);
 
   /* Note: these are the brush mask size plus a border of 1 pixel */
   *x = (gint) paint_core->cur_coords.x - width  / 2 - 1;



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