[gtk/matthiasc/lottie2] Fix up rectangle offsets



commit 44370707d502901b51de51b86ecc20384605f2e5
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Nov 26 09:08:07 2020 -0500

    Fix up rectangle offsets
    
    When showing the closest point as it moves around
    the rectangle contour, one can observe the 'offset
    point' jump to the opposite side for two sections
    of the outline.
    Fix that by doing things more manually.

 gsk/gskpath.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/gsk/gskpath.c b/gsk/gskpath.c
index b42d81c1e4..da6898e710 100644
--- a/gsk/gskpath.c
+++ b/gsk/gskpath.c
@@ -347,8 +347,16 @@ gsk_rect_contour_get_closest_point (const GskContour       *contour,
     *out_pos = p;
 
   if (out_offset)
-    *out_offset = (t.x > 0.5 ? t.y : 2 - t.y) * ABS (self->height) + 
-                  (t.y > 0.5 ? 2 - t.x : t.x) * ABS (self->width);
+    {
+      if (t.y == 0.0)
+        *out_offset = t.x * ABS (self->width);
+      else if (t.y == 1.0)
+        *out_offset = (2 - t.x) * ABS (self->width) + ABS (self->height);
+      else if (t.x == 1.0)
+        *out_offset = ABS (self->width) + t.y * ABS (self->height);
+      else
+        *out_offset = 2 * ABS (self->width) + ( 2 - t.y) * ABS (self->height);
+    }
 
   if (out_tangent)
     {


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