[gimp/multi-stroke: 6/31] app: some paint settings are based on original stroke.



commit e9064beb7f057983fa0264fb24e66512bd0af1ab
Author: Jehan <jehan girinstud io>
Date:   Sat Mar 21 18:09:46 2015 +0100

    app: some paint settings are based on original stroke.

 app/paint/gimppaintbrush.c |   34 ++++++++++++++------------
 app/paint/gimpsourcecore.c |   57 ++++++++++++++++++++++++--------------------
 2 files changed, 49 insertions(+), 42 deletions(-)
---
diff --git a/app/paint/gimppaintbrush.c b/app/paint/gimppaintbrush.c
index ae8c274..10e2a83 100644
--- a/app/paint/gimppaintbrush.c
+++ b/app/paint/gimppaintbrush.c
@@ -158,20 +158,30 @@ _gimp_paintbrush_motion (GimpPaintCore    *paint_core,
   fade_point = gimp_paint_options_get_fade (paint_options, image,
                                             paint_core->pixel_dist);
 
+  coords = gimp_multi_stroke_get_origin (mstroke);
+  /* Some settings are based on the original stroke. */
+  opacity *= gimp_dynamics_get_linear_value (dynamics,
+                                             GIMP_DYNAMICS_OUTPUT_OPACITY,
+                                             coords,
+                                             paint_options,
+                                             fade_point);
+  if (opacity == 0.0)
+    return;
+
+  paint_appl_mode = paint_options->application_mode;
+
+  grad_point = gimp_dynamics_get_linear_value (dynamics,
+                                               GIMP_DYNAMICS_OUTPUT_COLOR,
+                                               coords,
+                                               paint_options,
+                                               fade_point);
+
   for (i = 0; i < nstrokes; i++)
     {
       gint paint_width, paint_height;
 
       coords = gimp_multi_stroke_get_coords (mstroke, i);
 
-      opacity *= gimp_dynamics_get_linear_value (dynamics,
-                                                 GIMP_DYNAMICS_OUTPUT_OPACITY,
-                                                 coords,
-                                                 paint_options,
-                                                 fade_point);
-      if (opacity == 0.0)
-        continue;
-
       paint_buffer = gimp_paint_core_get_paint_buffer (paint_core, drawable,
                                                        paint_options, coords,
                                                        &paint_buffer_x,
@@ -184,14 +194,6 @@ _gimp_paintbrush_motion (GimpPaintCore    *paint_core,
       op = gimp_multi_stroke_get_operation (mstroke, i,
                                             paint_width,
                                             paint_height);
-      paint_appl_mode = paint_options->application_mode;
-
-      grad_point = gimp_dynamics_get_linear_value (dynamics,
-                                                   GIMP_DYNAMICS_OUTPUT_COLOR,
-                                                   coords,
-                                                   paint_options,
-                                                   fade_point);
-
       if (gimp_paint_options_get_gradient_color (paint_options, image,
                                                  grad_point,
                                                  paint_core->pixel_dist,
diff --git a/app/paint/gimpsourcecore.c b/app/paint/gimpsourcecore.c
index 01f7ef3..249da56 100644
--- a/app/paint/gimpsourcecore.c
+++ b/app/paint/gimpsourcecore.c
@@ -363,6 +363,8 @@ gimp_source_core_motion (GimpSourceCore   *source_core,
   GimpPickable      *src_pickable = NULL;
   GeglBuffer        *src_buffer   = NULL;
   GeglRectangle      src_rect;
+  gint               base_src_offset_x;
+  gint               base_src_offset_y;
   gint               src_offset_x;
   gint               src_offset_y;
   GeglBuffer        *paint_buffer;
@@ -386,41 +388,42 @@ gimp_source_core_motion (GimpSourceCore   *source_core,
   origin   = gimp_multi_stroke_get_origin (mstroke);
   nstrokes = gimp_multi_stroke_get_size (mstroke);
 
-  for (i = 0; i < nstrokes; i++)
-    {
-      coords = gimp_multi_stroke_get_coords (mstroke, i);
+  /* Some settings are based on the original stroke. */
+  opacity = gimp_dynamics_get_linear_value (dynamics,
+                                            GIMP_DYNAMICS_OUTPUT_OPACITY,
+                                            origin,
+                                            paint_options,
+                                            fade_point);
+  if (opacity == 0.0)
+    return;
 
-      opacity = gimp_dynamics_get_linear_value (dynamics,
-                                                GIMP_DYNAMICS_OUTPUT_OPACITY,
-                                                coords,
-                                                paint_options,
-                                                fade_point);
-      if (opacity == 0.0)
-        continue;
+  base_src_offset_x = source_core->offset_x;
+  base_src_offset_y = source_core->offset_y;
 
-      src_offset_x = source_core->offset_x;
-      src_offset_y = source_core->offset_y;
+  if (gimp_source_core_use_source (source_core, options))
+    {
+      src_pickable = GIMP_PICKABLE (source_core->src_drawable);
 
-      if (gimp_source_core_use_source (source_core, options))
+      if (options->sample_merged)
         {
-          src_pickable = GIMP_PICKABLE (source_core->src_drawable);
+          GimpImage *src_image = gimp_pickable_get_image (src_pickable);
+          gint       off_x, off_y;
 
-          if (options->sample_merged)
-            {
-              GimpImage *src_image = gimp_pickable_get_image (src_pickable);
-              gint       off_x, off_y;
+          src_pickable = GIMP_PICKABLE (src_image);
 
-              src_pickable = GIMP_PICKABLE (src_image);
+          gimp_item_get_offset (GIMP_ITEM (source_core->src_drawable),
+                                &off_x, &off_y);
 
-              gimp_item_get_offset (GIMP_ITEM (source_core->src_drawable),
-                                    &off_x, &off_y);
+          base_src_offset_x += off_x;
+          base_src_offset_y += off_y;
+        }
 
-              src_offset_x += off_x;
-              src_offset_y += off_y;
-            }
+      gimp_pickable_flush (src_pickable);
+    }
 
-          gimp_pickable_flush (src_pickable);
-        }
+  for (i = 0; i < nstrokes; i++)
+    {
+      coords = gimp_multi_stroke_get_coords (mstroke, i);
 
       paint_buffer = gimp_paint_core_get_paint_buffer (paint_core, drawable,
                                                        paint_options, coords,
@@ -435,6 +438,8 @@ gimp_source_core_motion (GimpSourceCore   *source_core,
       paint_area_width    = gegl_buffer_get_width  (paint_buffer);
       paint_area_height   = gegl_buffer_get_height (paint_buffer);
 
+      src_offset_x = base_src_offset_x;
+      src_offset_y = base_src_offset_y;
       if (gimp_source_core_use_source (source_core, options))
         {
           /* When using a source, use the same for every stroke. */


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