[gimp] app: mypaint: Include offset_by_random in the cursor calculation



commit ea66a7a9745b733b7fc8c41068c4c6d977ba23da
Author: Daniel Sabo <DanielSabo gmail com>
Date:   Tue Dec 29 09:54:48 2015 -0800

    app: mypaint: Include offset_by_random in the cursor calculation

 app/core/gimpmybrush-load.c    |    4 ++++
 app/core/gimpmybrush-private.h |    1 +
 app/core/gimpmybrush.c         |    8 ++++++++
 app/core/gimpmybrush.h         |   19 ++++++++++---------
 app/tools/gimpmybrushtool.c    |    5 ++++-
 5 files changed, 27 insertions(+), 10 deletions(-)
---
diff --git a/app/core/gimpmybrush-load.c b/app/core/gimpmybrush-load.c
index 4131319..70d9f0c 100644
--- a/app/core/gimpmybrush-load.c
+++ b/app/core/gimpmybrush-load.c
@@ -142,6 +142,10 @@ gimp_mybrush_load (GimpContext   *context,
     mypaint_brush_get_base_value (mypaint_brush,
                                   MYPAINT_BRUSH_SETTING_ERASER) > 0.5f;
 
+  brush->priv->offset_by_random =
+    mypaint_brush_get_base_value (mypaint_brush,
+                                  MYPAINT_BRUSH_SETTING_OFFSET_BY_RANDOM);
+
   mypaint_brush_unref (mypaint_brush);
 
   return g_list_prepend (NULL, brush);
diff --git a/app/core/gimpmybrush-private.h b/app/core/gimpmybrush-private.h
index cfe880d..c50dae7 100644
--- a/app/core/gimpmybrush-private.h
+++ b/app/core/gimpmybrush-private.h
@@ -27,6 +27,7 @@ struct _GimpMybrushPrivate
   gdouble  radius;
   gdouble  opaque;
   gdouble  hardness;
+  gdouble  offset_by_random;
   gboolean eraser;
 };
 
diff --git a/app/core/gimpmybrush.c b/app/core/gimpmybrush.c
index 635fe1f..36d7233 100644
--- a/app/core/gimpmybrush.c
+++ b/app/core/gimpmybrush.c
@@ -261,6 +261,14 @@ gimp_mybrush_get_hardness (GimpMybrush *brush)
   return brush->priv->hardness;
 }
 
+gdouble
+gimp_mybrush_get_offset_by_random (GimpMybrush *brush)
+{
+  g_return_val_if_fail (GIMP_IS_MYBRUSH (brush), 1.0);
+
+  return brush->priv->offset_by_random;
+}
+
 gboolean
 gimp_mybrush_get_is_eraser (GimpMybrush *brush)
 {
diff --git a/app/core/gimpmybrush.h b/app/core/gimpmybrush.h
index bf1d82a..444e489 100644
--- a/app/core/gimpmybrush.h
+++ b/app/core/gimpmybrush.h
@@ -48,18 +48,19 @@ struct _GimpMybrushClass
 };
 
 
-GType         gimp_mybrush_get_type       (void) G_GNUC_CONST;
+GType         gimp_mybrush_get_type             (void) G_GNUC_CONST;
 
-GimpData    * gimp_mybrush_new            (GimpContext *context,
-                                           const gchar *name);
-GimpData    * gimp_mybrush_get_standard   (GimpContext *context);
+GimpData    * gimp_mybrush_new                  (GimpContext *context,
+                                                 const gchar *name);
+GimpData    * gimp_mybrush_get_standard         (GimpContext *context);
 
-const gchar * gimp_mybrush_get_brush_json (GimpMybrush *brush);
+const gchar * gimp_mybrush_get_brush_json       (GimpMybrush *brush);
 
-gdouble       gimp_mybrush_get_radius     (GimpMybrush *brush);
-gdouble       gimp_mybrush_get_opaque     (GimpMybrush *brush);
-gdouble       gimp_mybrush_get_hardness   (GimpMybrush *brush);
-gboolean      gimp_mybrush_get_is_eraser  (GimpMybrush *brush);
+gdouble       gimp_mybrush_get_radius           (GimpMybrush *brush);
+gdouble       gimp_mybrush_get_opaque           (GimpMybrush *brush);
+gdouble       gimp_mybrush_get_hardness         (GimpMybrush *brush);
+gdouble       gimp_mybrush_get_offset_by_random (GimpMybrush *brush);
+gboolean      gimp_mybrush_get_is_eraser        (GimpMybrush *brush);
 
 
 #endif /* __GIMP_MYBRUSH_H__ */
diff --git a/app/tools/gimpmybrushtool.c b/app/tools/gimpmybrushtool.c
index 20cf552..5d1b816 100644
--- a/app/tools/gimpmybrushtool.c
+++ b/app/tools/gimpmybrushtool.c
@@ -38,6 +38,7 @@
 #include "gimpmybrushoptions-gui.h"
 #include "gimpmybrushtool.h"
 #include "gimptoolcontrol.h"
+#include "core/gimpmybrush.h"
 
 #include "gimp-intl.h"
 
@@ -122,10 +123,12 @@ gimp_mybrush_tool_get_outline (GimpPaintTool *paint_tool,
                                gdouble        y)
 {
   GimpMybrushOptions *options = GIMP_MYBRUSH_TOOL_GET_OPTIONS (paint_tool);
+  GimpMybrush        *brush   = gimp_context_get_mybrush (GIMP_CONTEXT (options));
   GimpCanvasItem     *item    = NULL;
   GimpDisplayShell   *shell   = gimp_display_get_shell (display);
 
-  gdouble radius = MAX (MAX (4 / shell->scale_x, 4 / shell->scale_y), exp (options->radius) + 
options->radius * 2);
+  gdouble radius = exp (options->radius) + 2 * options->radius * gimp_mybrush_get_offset_by_random (brush);
+  radius = MAX (MAX (4 / shell->scale_x, 4 / shell->scale_y), radius);
 
   item = gimp_mybrush_tool_create_cursor (paint_tool, display, x, y, radius);
 


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