[gimp] Bug 769022 - Improve text along path when path is short.



commit 99050ecee6a8240125d511496fd6f9a7f44165e7
Author: Massimo Valentini <mvalentini src gnome org>
Date:   Thu Jul 21 10:31:53 2016 +0200

    Bug 769022 - Improve text along path when path is short.
    
    Extend the text along the tangent of the last path stroke.

 app/vectors/gimpvectors-warp.c |   49 ++++++++++++++++++++++++++++++++++++---
 1 files changed, 45 insertions(+), 4 deletions(-)
---
diff --git a/app/vectors/gimpvectors-warp.c b/app/vectors/gimpvectors-warp.c
index 12385c1..33e9c1e 100644
--- a/app/vectors/gimpvectors-warp.c
+++ b/app/vectors/gimpvectors-warp.c
@@ -44,7 +44,8 @@ static void   gimp_stroke_warp_point   (GimpStroke  *stroke,
                                         gdouble      x,
                                         gdouble      y,
                                         GimpCoords  *point_warped,
-                                        gdouble      y_offset);
+                                        gdouble      y_offset,
+                                        gdouble      x_len);
 
 static void   gimp_vectors_warp_stroke (GimpVectors *vectors,
                                         GimpStroke  *stroke,
@@ -71,7 +72,7 @@ gimp_vectors_warp_point (GimpVectors *vectors,
 
       len = gimp_vectors_stroke_get_length (vectors, stroke);
 
-      if (x < len)
+      if (x < len || ! list->next)
         break;
 
       x -= len;
@@ -84,7 +85,7 @@ gimp_vectors_warp_point (GimpVectors *vectors,
       return;
     }
 
-  gimp_stroke_warp_point (stroke, x, y, point_warped, y_offset);
+  gimp_stroke_warp_point (stroke, x, y, point_warped, y_offset, len);
 }
 
 static void
@@ -92,7 +93,8 @@ gimp_stroke_warp_point (GimpStroke *stroke,
                         gdouble     x,
                         gdouble     y,
                         GimpCoords *point_warped,
-                        gdouble     y_offset)
+                        gdouble     y_offset,
+                        gdouble     x_len)
 {
   GimpCoords point_zero  = { 0, };
   GimpCoords point_minus = { 0, };
@@ -100,6 +102,45 @@ gimp_stroke_warp_point (GimpStroke *stroke,
   gdouble    slope;
   gdouble    dx, dy, nx, ny, len;
 
+  if (x + DX >= x_len)
+    {
+      gdouble tx, ty;
+
+      if (! gimp_stroke_get_point_at_dist (stroke, x_len, EPSILON,
+                                           &point_zero, &slope))
+        {
+          point_warped->x = 0;
+          point_warped->y = 0;
+          return;
+        }
+
+      point_warped->x = point_zero.x;
+      point_warped->y = point_zero.y;
+
+      if (! gimp_stroke_get_point_at_dist (stroke, x_len - DX, EPSILON,
+                                           &point_minus, &slope))
+        return;
+
+      dx = point_zero.x - point_minus.x;
+      dy = point_zero.y - point_minus.y;
+
+      len = hypot (dx, dy);
+
+      if (len < 0.01)
+        return;
+
+      tx = dx / len;
+      ty = dy / len;
+
+      nx = - dy / len;
+      ny =   dx / len;
+
+      point_warped->x += tx * (x - x_len) + nx * (y - y_offset);
+      point_warped->y += ty * (x - x_len) + ny * (y - y_offset);
+
+      return;
+    }
+
   if (! gimp_stroke_get_point_at_dist (stroke, x, EPSILON,
                                        &point_zero, &slope))
     {


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