Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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])
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:])
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:])
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."""
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:])
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])