Пример #1
0
 def _path(self, node):
     self.path = self.canvas.beginPath()
     self.path.moveTo(**utils.attr_get(node, ['x', 'y']))
     for n in node.childNodes:
         if n.nodeType == node.ELEMENT_NODE:
             if n.localName == 'moveto':
                 vals = utils.text_get(n).split()
                 self.path.moveTo(utils.unit_get(vals[0]),
                                  utils.unit_get(vals[1]))
             elif n.localName == 'curvesto':
                 vals = utils.text_get(n).split()
                 while len(vals) > 5:
                     pos = []
                     while len(pos) < 6:
                         pos.append(utils.unit_get(vals.pop(0)))
                     self.path.curveTo(*pos)
         elif (n.nodeType == node.TEXT_NODE):
             data = n.data.split(
             )  # Not sure if I must merge all TEXT_NODE ?
             while len(data) > 1:
                 x = utils.unit_get(data.pop(0))
                 y = utils.unit_get(data.pop(0))
                 self.path.lineTo(x, y)
     if (not node.hasAttribute('close')) or utils.bool_get(
             node.getAttribute('close')):
         self.path.close()
     self.canvas.drawPath(
         self.path,
         **utils.attr_get(node, [], {
             'fill': 'bool',
             'stroke': 'bool'
         }))
Пример #2
0
 def _path(self, node):
     self.path = self.canvas.beginPath()
     self.path.moveTo(**utils.attr_get(node, ['x', 'y']))
     for n in utils._child_get(node, self):
         if not n.text:
             if n.tag == 'moveto':
                 vals = utils.text_get(n).split()
                 self.path.moveTo(utils.unit_get(vals[0]),
                                  utils.unit_get(vals[1]))
             elif n.tag == 'curvesto':
                 vals = utils.text_get(n).split()
                 while len(vals) > 5:
                     pos = []
                     while len(pos) < 6:
                         pos.append(utils.unit_get(vals.pop(0)))
                     self.path.curveTo(*pos)
         elif n.text:
             data = n.text.split(
             )  # Not sure if I must merge all TEXT_NODE ?
             while len(data) > 1:
                 x = utils.unit_get(data.pop(0))
                 y = utils.unit_get(data.pop(0))
                 self.path.lineTo(x, y)
     if (not node.get('close')) or utils.bool_get(node.get('close')):
         self.path.close()
     self.canvas.drawPath(
         self.path,
         **utils.attr_get(node, [], {
             'fill': 'bool',
             'stroke': 'bool'
         }))
Пример #3
0
 def _path(self, node):
     self.path = self.canvas.beginPath()
     self.path.moveTo(**utils.attr_get(node, ["x", "y"]))
     for n in node.childNodes:
         if n.nodeType == node.ELEMENT_NODE:
             if n.localName == "moveto":
                 vals = utils.text_get(n).split()
                 self.path.moveTo(utils.unit_get(vals[0]), utils.unit_get(vals[1]))
             elif n.localName == "curvesto":
                 vals = utils.text_get(n).split()
                 while len(vals) > 5:
                     pos = []
                     while len(pos) < 6:
                         pos.append(utils.unit_get(vals.pop(0)))
                     self.path.curveTo(*pos)
         elif n.nodeType == node.TEXT_NODE:
             data = n.data.split()  # Not sure if I must merge all TEXT_NODE ?
             while len(data) > 1:
                 x = utils.unit_get(data.pop(0))
                 y = utils.unit_get(data.pop(0))
                 self.path.lineTo(x, y)
     if (not node.hasAttribute("close")) or utils.bool_get(node.getAttribute("close")):
         self.path.close()
     self.canvas.drawPath(self.path, **utils.attr_get(node, [], {"fill": "bool", "stroke": "bool"}))
Пример #4
0
 def _path(self, node):
     self.path = self.canvas.beginPath()
     self.path.moveTo(**utils.attr_get(node, ['x','y']))
     for n in utils._child_get(node, self):
         if not n.text :
             if n.tag=='moveto':
                 vals = utils.text_get(n).split()
                 self.path.moveTo(utils.unit_get(vals[0]), utils.unit_get(vals[1]))
             elif n.tag=='curvesto':
                 vals = utils.text_get(n).split()
                 while len(vals)>5:
                     pos=[]
                     while len(pos)<6:
                         pos.append(utils.unit_get(vals.pop(0)))
                     self.path.curveTo(*pos)
         elif n.text:
             data = n.text.split()               # Not sure if I must merge all TEXT_NODE ?
             while len(data)>1:
                 x = utils.unit_get(data.pop(0))
                 y = utils.unit_get(data.pop(0))
                 self.path.lineTo(x,y)
     if (not node.get('close')) or utils.bool_get(node.get('close')):
         self.path.close()
     self.canvas.drawPath(self.path, **utils.attr_get(node, [], {'fill':'bool','stroke':'bool'}))