arminstraub.com

Clipping

SimplyDraw - Clipping

This easy example shows how you can do clipping. Just use the function set which is also used for scaling here. You can use any path for clipping.

One great advantage of Python shows up when we stroke several circles using a single for loop.

And you can see, it's really simple to add arbitrary text. You can supply the text function with a string that is interpreted internally by TeX.

set(scale=2, clip=rect(0, -1, 2, 2))

stroke(line(0, -1, 0, 1), [linewidth.THick])

for s in [.12, .3, .5, .7, 1.3, 3]:
    stroke(circle(1, 0, 1), [scale(s), linewidth.thin])

stroke(line(1.5, 0, 2, 0), [earrow.normal])
text(2, -1, "$r\\rightarrow\\infty$", [valign.bottom, halign.right])