Merge pull request #690 from jamesgk/area-pen
Allow single-point open contours in area pen
This commit is contained in:
commit
0682e77370
@ -63,5 +63,9 @@ class AreaPen(BasePen):
|
||||
del self._p0, self._startPoint
|
||||
|
||||
def _endPath(self):
|
||||
"""Area is not defined for open contours."""
|
||||
raise NotImplementedError
|
||||
"""Area is not defined for open contours.
|
||||
Single-point open contours, which often represent anchors, are allowed.
|
||||
"""
|
||||
if self._p0 != self._startPoint:
|
||||
raise NotImplementedError
|
||||
del self._p0, self._startPoint
|
||||
|
@ -163,6 +163,17 @@ class AreaPenTest(unittest.TestCase):
|
||||
draw8_(pen)
|
||||
self.assertEqual(104602.791667, round(pen.value, precision))
|
||||
|
||||
def test_openPaths(self):
|
||||
pen = AreaPen()
|
||||
pen.moveTo((0, 0))
|
||||
pen.endPath()
|
||||
self.assertEqual(0, pen.value)
|
||||
|
||||
pen.moveTo((0, 0))
|
||||
pen.lineTo((1, 0))
|
||||
with self.assertRaises(NotImplementedError):
|
||||
pen.endPath()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Loading…
x
Reference in New Issue
Block a user