summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2016-12-19 15:20:10 -0800
committerCedric BAIL <cedric@osg.samsung.com>2016-12-19 16:33:46 -0800
commit701aa35e6ed7f8e44195913e51ea488ffaf92465 (patch)
tree005cd28eba506dcc90c3a46c2f3feb3fd1634e03 /src
parent3751e29a9b8127a2730b1d54a1268eac0ed9be10 (diff)
eina fixup bezier
Diffstat (limited to 'src')
-rw-r--r--src/lib/eina/eina_bezier.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/src/lib/eina/eina_bezier.c b/src/lib/eina/eina_bezier.c
index c6bcd3c04f..391bf14359 100644
--- a/src/lib/eina/eina_bezier.c
+++ b/src/lib/eina/eina_bezier.c
@@ -79,13 +79,15 @@ _eina_bezier_split(const Eina_Bezier *b,
79 first->end.y = second->start.y = (first->ctrl_end.y + second->ctrl_start.y) * 0.5; 79 first->end.y = second->start.y = (first->ctrl_end.y + second->ctrl_start.y) * 0.5;
80} 80}
81 81
82static void 82#include <stdio.h>
83_eina_bezier_length_helper(const Eina_Bezier *b, 83
84 double *length) 84static float
85_eina_bezier_length_helper(const Eina_Bezier *b)
85{ 86{
86 Eina_Bezier left, right; /* bez poly splits */ 87 Eina_Bezier left, right; /* bez poly splits */
87 double len = 0.0; /* arc length */ 88 float len = 0.0; /* arc length */
88 double chord; /* chord length */ 89 float chord; /* chord length */
90 float length;
89 91
90 len = len + _line_length(b->start.x, b->start.y, b->ctrl_start.x, b->ctrl_start.y); 92 len = len + _line_length(b->start.x, b->start.y, b->ctrl_start.x, b->ctrl_start.y);
91 len = len + _line_length(b->ctrl_start.x, b->ctrl_start.y, b->ctrl_end.x, b->ctrl_end.y); 93 len = len + _line_length(b->ctrl_start.x, b->ctrl_start.y, b->ctrl_end.x, b->ctrl_end.y);
@@ -93,16 +95,16 @@ _eina_bezier_length_helper(const Eina_Bezier *b,
93 95
94 chord = _line_length(b->start.x, b->start.y, b->end.x, b->end.y); 96 chord = _line_length(b->start.x, b->start.y, b->end.x, b->end.y);
95 97
96 if (!EINA_DBL_CMP(len, chord)) { 98 if (fabsf(len - chord) > FLT_MIN) {
97 _eina_bezier_split(b, &left, &right); /* split in two */ 99 _eina_bezier_split(b, &left, &right); /* split in two */
98 _eina_bezier_length_helper(&left, length); /* try left side */ 100 length =
99 _eina_bezier_length_helper(&right, length); /* try right side */ 101 _eina_bezier_length_helper(&left) + /* try left side */
100 return; 102 _eina_bezier_length_helper(&right); /* try right side */
101 }
102 103
103 *length = *length + len; 104 return length;
105 }
104 106
105 return; 107 return len;
106} 108}
107 109
108EAPI void 110EAPI void
@@ -185,11 +187,7 @@ eina_bezier_angle_at(const Eina_Bezier *b, double t)
185EAPI double 187EAPI double
186eina_bezier_length_get(const Eina_Bezier *b) 188eina_bezier_length_get(const Eina_Bezier *b)
187{ 189{
188 double length = 0.0; 190 return _eina_bezier_length_helper(b);
189
190 _eina_bezier_length_helper(b, &length);
191
192 return length;
193} 191}
194 192
195static void 193static void
@@ -228,7 +226,7 @@ eina_bezier_t_at(const Eina_Bezier *b, double l)
228 double biggest = 1.0; 226 double biggest = 1.0;
229 double t = 1.0; 227 double t = 1.0;
230 228
231 if (l > len || (EINA_DBL_CMP(len, l))) 229 if (l >= len)// || (EINA_DBL_CMP(len, l)))
232 return t; 230 return t;
233 231
234 t *= 0.5; 232 t *= 0.5;