Merge pull request #2344 from takaakifuji/newer-gspp-from-fontpens
Use newer version of GuessSmoothPointPen from fontPens
This commit is contained in:
commit
414c3733aa
@ -330,8 +330,9 @@ class GuessSmoothPointPen(AbstractPointPen):
|
|||||||
should be "smooth", ie. that it's a "tangent" point or a "curve" point.
|
should be "smooth", ie. that it's a "tangent" point or a "curve" point.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, outPen):
|
def __init__(self, outPen, error=0.05):
|
||||||
self._outPen = outPen
|
self._outPen = outPen
|
||||||
|
self._error = error
|
||||||
self._points = None
|
self._points = None
|
||||||
|
|
||||||
def _flushContour(self):
|
def _flushContour(self):
|
||||||
@ -366,9 +367,9 @@ class GuessSmoothPointPen(AbstractPointPen):
|
|||||||
if pt != prevPt and pt != nextPt:
|
if pt != prevPt and pt != nextPt:
|
||||||
dx1, dy1 = pt[0] - prevPt[0], pt[1] - prevPt[1]
|
dx1, dy1 = pt[0] - prevPt[0], pt[1] - prevPt[1]
|
||||||
dx2, dy2 = nextPt[0] - pt[0], nextPt[1] - pt[1]
|
dx2, dy2 = nextPt[0] - pt[0], nextPt[1] - pt[1]
|
||||||
a1 = math.atan2(dx1, dy1)
|
a1 = math.atan2(dy1, dx1)
|
||||||
a2 = math.atan2(dx2, dy2)
|
a2 = math.atan2(dy2, dx2)
|
||||||
if abs(a1 - a2) < 0.05:
|
if abs(a1 - a2) < self._error:
|
||||||
points[i] = pt, segmentType, True, name, kwargs
|
points[i] = pt, segmentType, True, name, kwargs
|
||||||
|
|
||||||
for pt, segmentType, smooth, name, kwargs in points:
|
for pt, segmentType, smooth, name, kwargs in points:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user