def renderChar(self, charData, x, y, naChar):
        d = charData.pathStr
        style = getCharStyle(self.strokeWidth, naChar)

        d = getTranslatedPath(d, x, y)

        attribs = {'style': formatStyle(style), 'd': d}
        getEtree().SubElement(self.currG, addNS('path', 'svg'), attribs)
Ejemplo n.º 2
0
    def addElem(self, templLayer, editLayer, glyphIdx, posX, posY):
        char = self.fontChars[glyphIdx]
        charData = self.strokeFontData.glyphMap[char]

        d = getTranslatedPath(charData.pathStr, posX, posY)

        attribs = {'id':char, 'style':formatStyle(self.charStyle), \
            xPath:d, xGlyphName: charData.glyphName}
        getEtree().SubElement(editLayer, addNS('path', 'svg'), attribs)

        return charData.rOffset
    def renderPlainText(self, text, size, x=None, y=None, objName=None):
        textStyle = {'fill': '#000000', 'fill-opacity': '1'}
        textStyle['font-size'] = str(size)
        attribs = {'style': formatStyle(textStyle)}
        if (x != None and y != None):
            attribs['transform'] = 'translate(' + str(x) + ', ' + str(y) + ')'

        textElem = getEtree().SubElement(self.g, addNS('text', 'svg'), attribs)
        textElem.text = text
 def getBoxFromCoords(self, x1, y1, x2, y2):
     attribs = {
         'x': str(x1),
         'y': str(y1),
         'width': str(x2 - x1),
         'height': str(y2 - y1)
     }
     attribs['style'] = self.box.get('style')
     self.box = getEtree().SubElement(self.layer, addNS('rect', 'svg'),
                                      attribs)
     return self.box
    def newBoxToBeRendered(self, box, addPlane):
        boxG = getEtree().SubElement(self.layer, 'g')

        if ('transform' in box.attrib):
            boxG.set('transform', box.get('transform'))

        box.getparent().remove(box)

        # order important!
        self.g.append(box)
        self.g.append(boxG)
        self.currG = boxG
        self.box = box
 def beforeRender(self):
     self.g = getEtree().SubElement(self.layer, 'g')
     self.currG = self.g