def addGlyph(self, glyph): BezierPath = glyph._layer.bezierPath() if BezierPath != None: BezierPath = BezierPath.copy() else: BezierPath = NSBezierPath.bezierPath() for currComponent in glyph._layer.components: BezierPath.appendBezierPath_(currComponent.bezierPath()) self.getNSBezierPath().appendBezierPath_(BezierPath)
def drawGlyph(glyph): BezierPath = glyph._layer.bezierPath if BezierPath != None: BezierPath = BezierPath.copy() else: BezierPath = NSBezierPath.bezierPath() OpenBezierPath = glyph._layer.openBezierPath if OpenBezierPath: BezierPath.appendBezierPath_(OpenBezierPath) for currComponent in glyph._layer.components: BezierPath.appendBezierPath_(currComponent.bezierPath) _drawBotDrawingTool.drawPath(BezierPath)
def drawGlyph(glyph): BezierPath = glyph._layer.bezierPath() if BezierPath != None: BezierPath = BezierPath.copy() else: BezierPath = NSBezierPath.bezierPath() OpenBezierPath = glyph._layer.openBezierPath() if OpenBezierPath: BezierPath.appendBezierPath_(OpenBezierPath) for currComponent in glyph._layer.components: BezierPath.appendBezierPath_(currComponent.bezierPath()) _drawBotDrawingTool.drawPath(BezierPath)
def _getObjects(self): return [Dummy(), BezierPath(), FormattedString()]
def contourToPath(contour): u"""Converts SVG contour to a path in DrawBot.""" path = BezierPath() pPrev = [0.0, 0.0] pPrev2 = None previousCommand = None for segment in contour: command = segment[0] points = segment[1] relative = False if command.islower(): relative = True command = command.lower() if command == 'm': if relative: points = getRelative(points, pPrev) path.moveTo(points[0]) elif command in ('l', 'h', 'v'): if command == 'l': if relative: points = getRelative(points, pPrev) elif command == 'h': if relative: points[0][0] += pPrev[0] points[0].append(pPrev[1]) elif command == 'v': points[0].insert(0, pPrev[0]) if relative: points[0][1] += pPrev[1] path.lineTo(points[0]) elif command == 'c': if relative: points = getRelative(points, pPrev) path.curveTo(*points) elif command == 's': if relative: points = getRelative(points, pPrev) # TODO: From the spec: # # If there is no previous command or if the previous command was # not an C, c, S or s, assume the first control point is coincident # with the current point if previousCommand in ('c', 's'): cp = reflect(pPrev2, pPrev) else: print('TODO: implement, test') #copyPoint(cp, points[0]) path.curveTo(cp, *points) elif command == 'z': continue copyPoint(pPrev, points[-1]) if command in ('c', 's'): pPrev2 = [0.0, 0.0] copyPoint(pPrev2, points[-2]) else: pPrev2 = None previousCommand = command path.closePath() return path