Python reportlab 之 draw函数介绍

Python reportlab 之 draw函数介绍

本节我们讲介绍一下操作canvas时经常用的工具API。在后续教程中我将会对每个工具进行详细介绍,本文把他们都介绍给大家,方便朋友们开发之用。

Line methods

canvas.line(x1,y1,x2,y2)
canvas.lines(linelist)

用line和lines方法可以直接在canvas里绘制直线段

Shape methods

canvas.grid(xlist, ylist)
canvas.bezier(x1, y1, x2, y2, x3, y3, x4, y4)
canvas.arc(x1,y1,x2,y2)
canvas.rect(x, y, width, height, stroke=1, fill=0)
canvas.ellipse(x1,y1, x2,y2, stroke=1, fill=0)
canvas.wedge(x1,y1, x2,y2, startAng, extent, stroke=1, fill=0)
canvas.circle(x_cen, y_cen, r, stroke=1, fill=0)
canvas.roundRect(x, y, width, height, radius, stroke=1, fill=0)

用shape方法可以绘制复杂的形状

String drawing methods

canvas.drawString(x, y, text):
canvas.drawRightString(x, y, text)
canvas.drawCentredString(x, y, text)

Text object methods

textobject = canvas.beginText(x,y)
canvas.drawText(textobje

你可能感兴趣的:(Python源码大全)