예제 #1
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'
         }))
예제 #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()
             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 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"}))