LoginSignup
0
0

More than 5 years have passed since last update.

reportlabでshapeをclipする

Last updated at Posted at 2012-12-26

CanvasではなくDrawingをクリップするには。

Path および ArcPathisClipPath というプロパティを持っているのでそれでクリップパス領域を作って add すればよい。先にクリップパスを add してから中身を追加する。
デフォルトだと strokefill が描画されるので単にクリップしたいだけなら手動で消すこと。

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 なんかだとできない。できたらいいのに。

参考資料

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0