vector_graphics
vector_graphics copied to clipboard
Optimize: clips
We should be able to pre-process clips such that we do not require any clipping at runtime.
For example, use path intersection logic to produce a path or set of paths that fit within the clipped area.
This has to take into account stroking properties altering the effective size of the path. For example, a path with a stroke width that != 1 or a non-butt cap will draw additional pixels that should be clipped.
For instance, the following relatively simple SVG cannot be clipped without tessellating the stroke into a fill (or at least into vertices):
<svg width="10" height="10">
<clipPath id="clip0">
<path d="M2 3h7.9v2H1" />
</clipPath>
<path d="M2, 5L8,6" stroke="black" stroke-linecap="round" stroke-width="2" clip-path="url(#clip0)" />
</svg>