CanvasではなくDrawingをクリップするには。
Path
および ArcPath
が isClipPath
というプロパティを持っているのでそれでクリップパス領域を作って add
すればよい。先にクリップパスを add
してから中身を追加する。
デフォルトだと stroke
と fill
が描画されるので単にクリップしたいだけなら手動で消すこと。
clip.py
from reportlab.graphics.shapes import *
width = 300
height = 200
d = Drawing(width,height)
clip = Path(fillColor=None, strokeColor=None, isClipPath=True)
clip.moveTo(0,0)
clip.lineTo(width,0)
clip.lineTo(width,height)
clip.lineTo(0,height)
clip.closePath()
d.add(clip)
同じShapesでも Rect
なんかだとできない。できたらいいのに。