コード例 #1
0
 def expand(self, sender):
     glyph = CurrentGlyph()
     
     defconGlyph = glyph.naked()
     
     glyph.prepareUndo("Outline")
     
     isQuad = curveConverter.isQuadratic(defconGlyph)
     
     if isQuad:
         curveConverter.quadratic2bezier(defconGlyph)
     
     outline = self.calculate(glyph)
     
     glyph.clear()
     outline.drawPoints(glyph.getPointPen())
     
     if isQuad:
         curveConverter.bezier2quadratic(defconGlyph)
     
     glyph.round()
     glyph.performUndo()
コード例 #2
0
                    y - radius * cos(phi + rho)
                )
            )
    else:
        for i in range(n - 1, 0, -1):
            rho = 2 * pi * i / n
            pen.lineTo(
                (
                    x - radius * sin(phi + rho),
                    y - radius * cos(phi + rho)
                )
            )
    
    # Close the path
    pen.closePath()


g = CurrentGlyph()
g.clear()
p = g.getPen()

diameter = 600
n = 8

for i in range(10):
    clockwise = i % 2
    phi = 1.2 * i * pi
    draw_polygon(p, (275, 216), diameter, n, phi, clockwise)
    #n -= 1
    diameter -= 50
コード例 #3
0
    
    def _lineTo(self, pt):
        self.writer_pen.lineTo(pt)
    
    def _curveToOne(self, bcp1, bcp2, pt):
        self.writer_pen.curveTo(bcp1, bcp2, pt)
    
    def _closePath(self):
        self.writer_pen.closePath()
    
    def _endPath(self):
        self.writer_pen.endPath()
    
    def addComponent(self, baseGlyphName, transformation):
        pass


source = CurrentGlyph()

# Temporary glyph to which the pen is writing
target = RGlyph()
target_pen = target.getPen()

source_pen = MyPen(CurrentFont(), target_pen)
source.draw(source_pen)

# Clear the original glyph and add the modfied outline
source.clear()
source.appendGlyph(target)

# You will notice any anchors are converted to stray points ...
コード例 #4
0
    def _endPath(self):
        self.writer_pen.endPath()
    
    def addComponent(self, baseGlyphName, transformation):
        pass


source = CurrentGlyph()

# Save the anchors from the original glyph in a list
anchors = [a for a in source.anchors]

# Remove all anchors from the glyph so they don't interfere with our processing
for a in anchors:
    source.removeAnchor(a)

# Temporary glyph to which the pen is writing
target = RGlyph()
target_pen = target.getPen()

source_pen = MyPen(CurrentFont(), target_pen, 10)
source.draw(source_pen)

# Clear the original glyph and add the modfied outline
source.clear(components=False)
source.appendGlyph(target)

# Restore the saved anchors
for a in anchors:
    source.appendAnchor(a.name, a.position)