Exemplo n.º 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'
         }))
Exemplo n.º 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'
         }))
Exemplo n.º 3
0
 def _lines(self, node):
     line_str = utils.text_get(node).split()
     lines = []
     while len(line_str) > 3:
         lines.append([utils.unit_get(l) for l in line_str[0:4]])
         line_str = line_str[4:]
     self.canvas.lines(lines)
Exemplo n.º 4
0
 def _lines(self, node):
     line_str = utils.text_get(node).split()
     lines = []
     while len(line_str) > 3:
         lines.append([utils.unit_get(l) for l in line_str[0:4]])
         line_str = line_str[4:]
     self.canvas.lines(lines)
Exemplo n.º 5
0
 def __init__(self, node, style):
     coord = [utils.unit_get(x) for x in utils.text_get(node).split(' ')]
     self.ok = False
     self.posx = coord[0]
     self.posy = coord[1]
     self.width = coord[2]-coord[0]
     self.ok = coord[1]==coord[3]
     self.style = style
     self.style = style.get('hr')
Exemplo n.º 6
0
 def __init__(self, node, style):
     self.posx = utils.unit_get(node.get('x'))
     self.posy =  utils.unit_get(node.get('y'))
     aligns = {
         'drawString': 'left',
         'drawRightString': 'right',
         'drawCentredString': 'center'
     }
     align = aligns[node.localName]
     self.pos = [(self.posx, self.posy, align, utils.text_get(node), style.get('td'), style.font_size_get('td'))]
Exemplo n.º 7
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"}))
Exemplo n.º 8
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'}))
Exemplo n.º 9
0
 def _curves(self, node):
     line_str = utils.text_get(node).split()
     lines = []
     while len(line_str) > 7:
         self.canvas.bezier(*[utils.unit_get(l) for l in line_str[0:8]])
         line_str = line_str[8:]
Exemplo n.º 10
0
 def _curves(self, node):
     line_str = utils.text_get(node).split()
     lines = []
     while len(line_str) > 7:
         self.canvas.bezier(*[utils.unit_get(l) for l in line_str[0:8]])
         line_str = line_str[8:]