pharo-graphics / Bloc

Low-level UI infrastructure & framework for Pharo
MIT License
80 stars 39 forks source link

SVG: take into account fill-rule #529

Open tinchodias opened 2 months ago

tinchodias commented 2 months ago

Right now, the SVG geometry offers BlSvgPath>>#useEvenOddFillRule and BlSvgPath>>#useWindingFillRule to set what is the rule to draw.

In short, this boolean property tells how the same star path should be rendered, either left of right option:

winding examples

For more info:


EDIT: the source for the star is:

<svg viewBox="-10 -10 220 120" xmlns="http://www.w3.org/2000/svg">
  <!-- Default value for fill-rule -->
  <polygon
    fill-rule="nonzero"
    stroke="red"
    points="50,0 21,90 98,35 2,35 79,90" />

  <!--
  The center of the shape has two
  path segments (shown by the red stroke)
  between it and infinity. It is therefore
  considered outside the shape, and not filled.
  -->
  <polygon
    fill-rule="evenodd"
    stroke="red"
    points="150,0 121,90 198,35 102,35 179,90" />
</svg>
tinchodias commented 2 months ago

I was not precise when I wrote above that the fill-rule property is boolean: in fact, the possible values are "nonzero" and "evenodd" (left and right stars, respectively)

tinchodias commented 2 months ago

It would be responsibility of BlSvgFactory, to consider this attribute.