本文整理汇总了Python中defcon.Glyph.getPen方法的典型用法代码示例。如果您正苦于以下问题:Python Glyph.getPen方法的具体用法?Python Glyph.getPen怎么用?Python Glyph.getPen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类defcon.Glyph
的用法示例。
在下文中一共展示了Glyph.getPen方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OutlinePen
# 需要导入模块: from defcon import Glyph [as 别名]
# 或者: from defcon.Glyph import getPen [as 别名]
class OutlinePen(BasePen):
pointClass = MathPoint
magicCurve = 0.5522847498
def __init__(self, glyphSet, offset=10, contrast=0, contrastAngle=0, connection="square", cap="round", miterLimit=None, closeOpenPaths=True, optimizeCurve=False, preserveComponents=False):
BasePen.__init__(self, glyphSet)
self.offset = abs(offset)
self.contrast = abs(contrast)
self.contrastAngle = contrastAngle
self._inputmiterLimit = miterLimit
if miterLimit is None:
miterLimit = self.offset * 2
self.miterLimit = abs(miterLimit)
self.closeOpenPaths = closeOpenPaths
self.optimizeCurve = optimizeCurve
self.connectionCallback = getattr(self, "connection%s" % (connection.title()))
self.capCallback = getattr(self, "cap%s" % (cap.title()))
self.originalGlyph = Glyph()
self.originalPen = self.originalGlyph.getPen()
self.outerGlyph = Glyph()
self.outerPen = self.outerGlyph.getPen()
self.outerCurrentPoint = None
self.outerFirstPoint = None
self.outerPrevPoint = None
self.innerGlyph = Glyph()
self.innerPen = self.innerGlyph.getPen()
self.innerCurrentPoint = None
self.innerFirstPoint = None
self.innerPrevPoint = None
self.prevPoint = None
self.firstPoint = None
self.firstAngle = None
self.prevAngle = None
self.shouldHandleMove = True
self.preserveComponents = preserveComponents
self.components = []
self.drawSettings()
def _moveTo(self, (x, y)):
if self.offset == 0:
self.outerPen.moveTo((x, y))
self.innerPen.moveTo((x, y))
return
self.originalPen.moveTo((x, y))
p = self.pointClass(x, y)
self.prevPoint = p
self.firstPoint = p
self.shouldHandleMove = True
示例2: OutlinePen
# 需要导入模块: from defcon import Glyph [as 别名]
# 或者: from defcon.Glyph import getPen [as 别名]
class OutlinePen(BasePen):
pointClass = MathPoint
magicCurve = 0.5522847498
def __init__(self, glyphSet, offset=10, connection="square", cap="round", mitterLimit=None, closeOpenPaths=True):
BasePen.__init__(self, glyphSet)
self.offset = abs(offset)
self._inputMitterLimit = mitterLimit
if mitterLimit is None:
mitterLimit = self.offset
self.mitterLimit = abs(mitterLimit)
self.closeOpenPaths = closeOpenPaths
self.connectionCallback = getattr(self, "connection%s" %(connection[0].capitalize() + connection[1:]))
self.capCallback = getattr(self, "cap%s" %(cap[0].capitalize() + cap[1:]))
self.originalGlyph = Glyph()
self.originalPen = self.originalGlyph.getPen()
self.outerGlyph = Glyph()
self.outerPen = self.outerGlyph.getPen()
self.outerCurrentPoint = None
self.outerFirstPoint = None
self.outerPrevPoint = None
self.innerGlyph = Glyph()
self.innerPen = self.innerGlyph.getPen()
self.innerCurrentPoint = None
self.innerFirstPoint = None
self.innerPrevPoint = None
self.prevPoint = None
self.firstPoint = None
self.firstAngle = None
self.prevAngle = None
self.shouldHandleMove = True
self.drawSettings()
def _moveTo(self, (x, y)):
if self.offset == 0:
self.outerPen.moveTo((x, y))
self.innerPen.moveTo((x, y))
return
self.originalPen.moveTo((x, y))
p = self.pointClass(x, y)
self.prevPoint = p
self.firstPoint = p
self.shouldHandleMove = True
示例3: test_remove_tiny_sub_paths_large_contour
# 需要导入模块: from defcon import Glyph [as 别名]
# 或者: from defcon.Glyph import getPen [as 别名]
def test_remove_tiny_sub_paths_large_contour():
g = Glyph()
p = g.getPen()
p.moveTo((100, 100))
p.lineTo((200, 200))
p.lineTo((0, 100))
p.closePath()
assert len(g[0]) == 3
assert g.bounds == (0, 100, 200, 200)
bg = BooleanGlyph(g)
assert remove_tiny_sub_paths(bg, 25, []) == []
示例4: test_remove_tiny_sub_paths_small_contour
# 需要导入模块: from defcon import Glyph [as 别名]
# 或者: from defcon.Glyph import getPen [as 别名]
def test_remove_tiny_sub_paths_small_contour():
g = Glyph()
p = g.getPen()
p.moveTo((1, 1))
p.lineTo((2, 2))
p.lineTo((0, 1))
p.closePath()
assert len(g[0]) == 3
assert g.bounds == (0, 1, 2, 2)
bg = BooleanGlyph(g)
assert remove_tiny_sub_paths(bg, 25, []) == \
['Contour 0 is too small: bounding box is less than minimum area. '
'Start point: ((1, 1)).']
示例5: find_shape_diffs
# 需要导入模块: from defcon import Glyph [as 别名]
# 或者: from defcon.Glyph import getPen [as 别名]
def find_shape_diffs(self):
"""Report differences in glyph shapes, using BooleanOperations."""
self.build_names()
area_pen = GlyphAreaPen(None)
pen = PointToSegmentPen(area_pen)
mismatched = {}
for name in self.names:
glyph_a = Glyph()
glyph_b = Glyph()
self.glyph_set_a[name].draw(
Qu2CuPen(glyph_a.getPen(), self.glyph_set_a))
self.glyph_set_b[name].draw(
Qu2CuPen(glyph_b.getPen(), self.glyph_set_b))
booleanOperations.xor(list(glyph_a), list(glyph_b), pen)
area = abs(area_pen.pop())
if area:
mismatched[name] = (area)
stats = self.stats['compared']
for name, area in mismatched.items():
stats.append((area, name, self.basepath))
示例6: test_CallingPenBallFilter
# 需要导入模块: from defcon import Glyph [as 别名]
# 或者: from defcon.Glyph import getPen [as 别名]
def test_CallingPenBallFilter(self):
testGlyph = Glyph()
pen = testGlyph.getPen()
self.drawTestGlyph(pen)
filteredGlyph = self.filter(testGlyph)
示例7: setUp
# 需要导入模块: from defcon import Glyph [as 别名]
# 或者: from defcon.Glyph import getPen [as 别名]
def setUp(self):
testGlyph = Glyph()
pen = testGlyph.getPen()
self.drawTestGlyph(pen)
self.testGlyph = testGlyph
示例8: OutlinePen
# 需要导入模块: from defcon import Glyph [as 别名]
# 或者: from defcon.Glyph import getPen [as 别名]
class OutlinePen(BasePen):
pointClass = MathPoint
magicCurve = 0.5522847498
def __init__(self, glyphSet, offset=10, contrast=0, contrastAngle=0, connection="square", cap="round", miterLimit=None, closeOpenPaths=True, preserveComponents=False):
BasePen.__init__(self, glyphSet)
self.offset = abs(offset)
self.contrast = abs(contrast)
self.contrastAngle = contrastAngle
self._inputmiterLimit = miterLimit
if miterLimit is None:
miterLimit = self.offset * 2
self.miterLimit = abs(miterLimit)
self.closeOpenPaths = closeOpenPaths
self.connectionCallback = getattr(self, "connection%s" % (connection.title()))
self.capCallback = getattr(self, "cap%s" % (cap.title()))
self.originalGlyph = Glyph()
self.originalPen = self.originalGlyph.getPen()
self.outerGlyph = Glyph()
self.outerPen = self.outerGlyph.getPen()
self.outerCurrentPoint = None
self.outerFirstPoint = None
self.outerPrevPoint = None
self.innerGlyph = Glyph()
self.innerPen = self.innerGlyph.getPen()
self.innerCurrentPoint = None
self.innerFirstPoint = None
self.innerPrevPoint = None
self.prevPoint = None
self.firstPoint = None
self.firstAngle = None
self.prevAngle = None
self.shouldHandleMove = True
self.preserveComponents = preserveComponents
self.components = []
self.drawSettings()
def _moveTo(self, xy):
(x, y) = xy
if self.offset == 0:
self.outerPen.moveTo((x, y))
self.innerPen.moveTo((x, y))
return
self.originalPen.moveTo((x, y))
p = self.pointClass(x, y)
self.prevPoint = p
self.firstPoint = p
self.shouldHandleMove = True
def _lineTo(self, xy):
(x, y) = xy
if self.offset == 0:
self.outerPen.lineTo((x, y))
self.innerPen.lineTo((x, y))
return
self.originalPen.lineTo((x, y))
currentPoint = self.pointClass(x, y)
if currentPoint == self.prevPoint:
return
self.currentAngle = self.prevPoint.angle(currentPoint)
thickness = self.getThickness(self.currentAngle)
self.innerCurrentPoint = self.prevPoint - self.pointClass(cos(self.currentAngle), sin(self.currentAngle)) * thickness
self.outerCurrentPoint = self.prevPoint + self.pointClass(cos(self.currentAngle), sin(self.currentAngle)) * thickness
if self.shouldHandleMove:
self.shouldHandleMove = False
self.innerPen.moveTo(self.innerCurrentPoint)
self.innerFirstPoint = self.innerCurrentPoint
self.outerPen.moveTo(self.outerCurrentPoint)
self.outerFirstPoint = self.outerCurrentPoint
self.firstAngle = self.currentAngle
else:
self.buildConnection()
self.innerCurrentPoint = currentPoint - self.pointClass(cos(self.currentAngle), sin(self.currentAngle)) * thickness
self.innerPen.lineTo(self.innerCurrentPoint)
self.innerPrevPoint = self.innerCurrentPoint
self.outerCurrentPoint = currentPoint + self.pointClass(cos(self.currentAngle), sin(self.currentAngle)) * thickness
self.outerPen.lineTo(self.outerCurrentPoint)
self.outerPrevPoint = self.outerCurrentPoint
self.prevPoint = currentPoint
#.........这里部分代码省略.........