linebender / piet

An abstraction for 2D graphics.
Apache License 2.0
1.24k stars 93 forks source link

piet-svg combined fill and stroke operation #476

Open ratmice opened 2 years ago

ratmice commented 2 years ago

When executing both RenderContext::stroke and RenderContext::fill, passing the same Shape, such as a BezPath results in multiple path elements in the output when using piet-svg output.

I wonder if this calls for a function that combines both stroke and fill operations, or perhaps some Renderable or Drawable trait which has both shape/geometry and stroke/fill/style information.

Maybe though I'm missing some way to achieve this already via the Brush API though I don't think so.

Here is some output which rather than one path with both fill="#304040" stroke="#000000", you get 2 paths.

<path d="M550 490L580 498.0384757729337L595 472.0577136594005L565.6283359900237 461.3673022289013L534.3716640099763 461.3673022289013Z" fill="#304040" fill-opacity="0.1843137254901961" transform="matrix(1 0 0 1 0 0)"/>
<path d="M550 490L580 498.0384757729337L595 472.0577136594005L565.6283359900237 461.3673022289013L534.3716640099763 461.3673022289013Z" fill="none" stroke="#000000" stroke-opacity="1" transform="matrix(1 0 0 1 0 0)"/>