当前位置: 首页>>代码示例>>Python>>正文


Python Glyph.appendAnchor方法代码示例

本文整理汇总了Python中defcon.Glyph.appendAnchor方法的典型用法代码示例。如果您正苦于以下问题:Python Glyph.appendAnchor方法的具体用法?Python Glyph.appendAnchor怎么用?Python Glyph.appendAnchor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在defcon.Glyph的用法示例。


在下文中一共展示了Glyph.appendAnchor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_appendAnchor

# 需要导入模块: from defcon import Glyph [as 别名]
# 或者: from defcon.Glyph import appendAnchor [as 别名]
 def test_appendAnchor(self):
     glyph = Glyph()
     glyph.dirty = False
     anchor = Anchor()
     glyph.appendAnchor(anchor)
     self.assertEqual(len(glyph.anchors), 1)
     self.assertTrue(glyph.dirty)
     self.assertEqual(anchor.getParent(), glyph)
开发者ID:anthrotype,项目名称:defcon,代码行数:10,代码来源:test_glyph.py

示例2: getGlyphFromDict

# 需要导入模块: from defcon import Glyph [as 别名]
# 或者: from defcon.Glyph import appendAnchor [as 别名]
def getGlyphFromDict(glyph_dict):
    g = Glyph()
    
    # Set attributes
    
    g.height = glyph_dict.get('height', 0)
    g.lib = glyph_dict.get('lib', {})
    g.name = glyph_dict.get('name', '')
    g.note = glyph_dict.get('note', None)
    g.unicode = glyph_dict.get('unicode', None)
    g.unicodes = glyph_dict.get('unicodes', [])
    g.width = glyph_dict.get('width', 0)
    
    # Draw the outlines with a pen
    pen = g.getPointPen()
    
    for contour in glyph_dict.get('contours', []):
        pen.beginPath()
        for point in contour:
            pen.addPoint(
                (
                    point.get('x'),
                    point.get('y')
                ),
                segmentType = point.get('type', None),
                name = point.get('name', None),
                smooth = point.get('smooth', None),
            )
        pen.endPath()
    
    # Add components
    
    for component in glyph_dict.get('components', []):
        c = Component()
        c.baseGlyph = component.get('ref', '')
        c.transformation = component.get('transformation', (1, 0, 0, 1, 0, 0))
        g.appendComponent(c)
    
    # Add anchors
    
    for anchor in glyph_dict.get('anchors', []):
        a = Anchor(anchorDict = anchor)
        g.appendAnchor(a)
    
    # Return the completed glyph object
    
    return g
开发者ID:jenskutilek,项目名称:TypoLabs2016,代码行数:49,代码来源:jsonPen.py


注:本文中的defcon.Glyph.appendAnchor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。