Exemplo n.º 1
0
 def arcTo(self, x1,y1, x2,y2, startAng=0, extent=90):
     """Like arc, but draws a line from the current point to
     the start if the start is not the current point."""
     pointList = pdfgeom.bezierArc(x1,y1, x2,y2, startAng, extent)
     self._code.append('%0.4f %0.4f l' % pointList[0][:2])
     for curve in pointList:
         self._code.append('%0.4f %0.4f %0.4f %0.4f %0.4f %0.4f c' % curve[2:])
Exemplo n.º 2
0
 def ellipse(self, x, y, width, height):
     """adds an ellipse to the path"""
     pointList = pdfgeom.bezierArc(x, y, x + width, y + height, 0, 360)
     self._code.append('%0.4f %0.4f m' % pointList[0][:2])
     for curve in pointList:
         self._code.append('%0.4f %0.4f %0.4f %0.4f %0.4f %0.4f c' %
                           curve[2:])
Exemplo n.º 3
0
 def arcTo(self, x1,y1, x2,y2, startAng=0, extent=90):
     """Like arc, but draws a line from the current point to
     the start if the start is not the current point."""
     pointList = pdfgeom.bezierArc(x1,y1, x2,y2, startAng, extent)
     self._code.append('%0.4f %0.4f l' % pointList[0][:2])
     for curve in pointList:
         self._code.append('%0.4f %0.4f %0.4f %0.4f %0.4f %0.4f c' % curve[2:])
Exemplo n.º 4
0
 def ellipse(self, x1, y1, x2, y2, stroke=1, fill=0):
     """Uses bezierArc, which conveniently handles 360 degrees -
     nice touch Robert"""
     pointList = pdfgeom.bezierArc(x1,y1, x2,y2, 0, 360)
     #move to first point
     self._code.append('n %0.4f %0.4f m' % pointList[0][:2])
     for curve in pointList:
         self._code.append('%0.4f %0.4f %0.4f %0.4f %0.4f %0.4f c' % curve[2:])
     #finish
     self._code.append(PATH_OPS[stroke, fill, self._fillMode])
Exemplo n.º 5
0
 def ellipse(self, x1, y1, x2, y2, stroke=1, fill=0):
     """Uses bezierArc, which conveniently handles 360 degrees -
     nice touch Robert"""
     pointList = pdfgeom.bezierArc(x1,y1, x2,y2, 0, 360)
     #move to first point
     self._code.append('n %0.4f %0.4f m' % pointList[0][:2])
     for curve in pointList:
         self._code.append('%0.4f %0.4f %0.4f %0.4f %0.4f %0.4f c' % curve[2:])
     #finish
     self._code.append(PATH_OPS[stroke, fill, self._fillMode])
Exemplo n.º 6
0
    def drawArc(self,
                x1,
                y1,
                x2,
                y2,
                startAng=0,
                extent=90,
                edgeColor=None,
                edgeWidth=None,
                fillColor=None):
        """This draws a PacMan-type shape connected to the centre.  One
        idiosyncracy - if you specify an edge color, it apples to the
        outer curved rim but not the radial edges."""
        if edgeColor:
            self._updateLineColor(edgeColor)
        if edgeWidth:
            self._updateLineWidth(edgeWidth)
        if fillColor:
            self._updateFillColor(fillColor)
        # I need to do some more work on flipping the coordinate system -
        # in pdfgen - note the angle reversal needed when drawing top-down.
        pointList = pdfgeom.bezierArc(x1, y1, x2, y2, -startAng, -extent)
        start = pointList[0]
        end = pointList[-1]
        x_cen = 0.5 * (x1 + x2)
        y_cen = 0.5 * (y1 + y2)

        #first the fill
        p = self.pdf.beginPath()
        p.moveTo(x_cen, y_cen)
        p.lineTo(start[0], start[1])
        for curve in pointList:
            p.curveTo(curve[2], curve[3], curve[4], curve[5], curve[6],
                      curve[7])
        p.close()  #back to centre
        self._endPath(p, transparent, fillColor)  #handles case of transparency
        #now the outer rim
        p2 = self.pdf.beginPath()
        p2.moveTo(start[0], start[1])
        for curve in pointList:
            p2.curveTo(curve[2], curve[3], curve[4], curve[5], curve[6],
                       curve[7])
        self._endPath(p2, edgeColor,
                      transparent)  #handles case of transparency

        if edgeColor:
            self._updateLineColor(self.defaultLineColor)
        if edgeWidth:
            self._updateLineWidth(self.defaultLineWidth)
        if fillColor:
            self._updateFillColor(self.defaultFillColor)
Exemplo n.º 7
0
    def arc(self, x1,y1, x2,y2, startAng=0, extent=90):
        """Contributed to piddlePDF by Robert Kern, 28/7/99.
        Draw a partial ellipse inscribed within the rectangle x1,y1,x2,y2,
        starting at startAng degrees and covering extent degrees.   Angles
        start with 0 to the right (+x) and increase counter-clockwise.
        These should have x1<x2 and y1<y2.

        The algorithm is an elliptical generalization of the formulae in
        Jim Fitzsimmon's TeX tutorial <URL: http://www.tinaja.com/bezarc1.pdf>."""

        pointList = pdfgeom.bezierArc(x1,y1, x2,y2, startAng, extent)
        #move to first point
        self._code.append('%0.4f %0.4f m' % pointList[0][:2])
        for curve in pointList:
            self._code.append('%0.4f %0.4f %0.4f %0.4f %0.4f %0.4f c' % curve[2:])
Exemplo n.º 8
0
    def arc(self, x1,y1, x2,y2, startAng=0, extent=90):
        """Contributed to piddlePDF by Robert Kern, 28/7/99.
        Draw a partial ellipse inscribed within the rectangle x1,y1,x2,y2,
        starting at startAng degrees and covering extent degrees.   Angles
        start with 0 to the right (+x) and increase counter-clockwise.
        These should have x1<x2 and y1<y2.

        The algorithm is an elliptical generalization of the formulae in
        Jim Fitzsimmon's TeX tutorial <URL: http://www.tinaja.com/bezarc1.pdf>."""

        pointList = pdfgeom.bezierArc(x1,y1, x2,y2, startAng, extent)
        #move to first point
        self._code.append('%0.4f %0.4f m' % pointList[0][:2])
        for curve in pointList:
            self._code.append('%0.4f %0.4f %0.4f %0.4f %0.4f %0.4f c' % curve[2:])
Exemplo n.º 9
0
    def wedge(self, x1,y1, x2,y2, startAng, extent, stroke=1, fill=0):
        """Like arc, but connects to the centre of the ellipse.
        Most useful for pie charts and PacMan!"""

        x_cen  = (x1+x2)/2.
        y_cen  = (y1+y2)/2.
        pointList = pdfgeom.bezierArc(x1,y1, x2,y2, startAng, extent)
  
        self._code.append('n %0.4f %0.4f m' % (x_cen, y_cen))
        # Move the pen to the center of the rectangle
        self._code.append('%0.4f %0.4f l' % pointList[0][:2])
        for curve in pointList:
            self._code.append('%0.4f %0.4f %0.4f %0.4f %0.4f %0.4f c' % curve[2:])
        # finish the wedge
        self._code.append('%0.4f %0.4f l ' % (x_cen, y_cen))
        # final operator
        self._code.append(PATH_OPS[stroke, fill, self._fillMode])
Exemplo n.º 10
0
    def wedge(self, x1,y1, x2,y2, startAng, extent, stroke=1, fill=0):
        """Like arc, but connects to the centre of the ellipse.
        Most useful for pie charts and PacMan!"""

        x_cen  = (x1+x2)/2.
        y_cen  = (y1+y2)/2.
        pointList = pdfgeom.bezierArc(x1,y1, x2,y2, startAng, extent)
  
        self._code.append('n %0.4f %0.4f m' % (x_cen, y_cen))
        # Move the pen to the center of the rectangle
        self._code.append('%0.4f %0.4f l' % pointList[0][:2])
        for curve in pointList:
            self._code.append('%0.4f %0.4f %0.4f %0.4f %0.4f %0.4f c' % curve[2:])
        # finish the wedge
        self._code.append('%0.4f %0.4f l ' % (x_cen, y_cen))
        # final operator
        self._code.append(PATH_OPS[stroke, fill, self._fillMode])
Exemplo n.º 11
0
    def drawArc(self, x1,y1, x2,y2, startAng=0, extent=90, edgeColor=None,
                edgeWidth=None, fillColor=None, dash=None, **kwargs):
        """This draws a PacMan-type shape connected to the centre.  One
        idiosyncracy - if you specify an edge color, it apples to the
        outer curved rim but not the radial edges."""
        if edgeColor:
            self._updateLineColor(edgeColor)
        if edgeWidth:
            self._updateLineWidth(edgeWidth)
        if fillColor:
            self._updateFillColor(fillColor)
        # I need to do some more work on flipping the coordinate system -
        # in pdfgen - note the angle reversal needed when drawing top-down.
        pointList = pdfgeom.bezierArc(x1,y1, x2,y2, -startAng, -extent)
        start = pointList[0]
        end = pointList[-1]
        x_cen = 0.5 * (x1 + x2)
        y_cen = 0.5 * (y1 + y2)

        #first the fill                
        p = self.pdf.beginPath()
        p.moveTo(x_cen, y_cen)
        p.lineTo(start[0], start[1])
        for curve in pointList:
            p.curveTo(curve[2], curve[3], curve[4], curve[5], curve[6], curve[7])
        p.close()  #back to centre
        self._endPath(p, transparent, fillColor) #handles case of transparency
        #now the outer rim
        p2 = self.pdf.beginPath()
        p2.moveTo(start[0], start[1])
        for curve in pointList:
            p2.curveTo(curve[2], curve[3], curve[4], curve[5], curve[6], curve[7])
        self._endPath(p2, edgeColor, transparent) #handles case of transparency
        
        
        if edgeColor:
            self._updateLineColor(self.defaultLineColor)
        if edgeWidth:
            self._updateLineWidth(self.defaultLineWidth)
        if fillColor:
            self._updateFillColor(self.defaultFillColor)
Exemplo n.º 12
0
 def ellipse(self, x, y, width, height):
     """adds an ellipse to the path"""
     pointList = pdfgeom.bezierArc(x, y, x + width,y + height, 0, 360)
     self._code.append('%0.4f %0.4f m' % pointList[0][:2])
     for curve in pointList:
         self._code.append('%0.4f %0.4f %0.4f %0.4f %0.4f %0.4f c' % curve[2:])