From cfa76e2cb1a6e80e20855702f87a02588c3a1c51 Mon Sep 17 00:00:00 2001 From: Michael Schindler Date: Thu, 27 Apr 2006 07:59:47 +0000 Subject: [PATCH] improve the fallback of deformer.smoothed git-svn-id: https://pyx.svn.sourceforge.net/svnroot/pyx/trunk/pyx@2620 069f4177-920e-0410-937b-c2a4a81bcd90 --- pyx/deformer.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pyx/deformer.py b/pyx/deformer.py index 37e473ba..5303eb50 100644 --- a/pyx/deformer.py +++ b/pyx/deformer.py @@ -515,9 +515,12 @@ class smoothed(deformer): # <<< c2 = s2 * abs(c2) # get the length of the control "arms" - a, d = controldists_from_endgeometry_pt(p1, p2, t1, t2, c1, c2, epsilon=epsilon)[0] + controldists = controldists_from_endgeometry_pt(p1, p2, t1, t2, c1, c2, epsilon=epsilon) - if a >= 0 and d >= 0: + if controldists and (controldists[0][0] >= 0 and controldists[0][1] >= 0): + # use the first entry in the controldists + # this should be the "smallest" pair + a, d = controldists[0] # avoid curves with invalid parameterization a = max(a, epsilon) d = max(d, epsilon) @@ -533,10 +536,11 @@ class smoothed(deformer): # <<< d = min(d, abs(s)) else: + # use a fallback t, s = intersection(p1, p2, t1, t2) if t is not None and s is not None: - a = abs(t) - d = abs(s) + a = 0.65 * abs(t) + d = 0.65 * abs(s) else: # if there is no useful result: # take an arbitrary smoothing curve that does not obey -- 2.11.4.GIT