vector_graphics icon indicating copy to clipboard operation
vector_graphics copied to clipboard

Optimize: clips

Open dnfield opened this issue 3 years ago • 1 comments

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.

dnfield avatar Mar 24 '22 03:03 dnfield

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>

dnfield avatar Apr 12 '22 04:04 dnfield