Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

One major problem in my attempt to answer to the CountryData flags question is that the way Mathematica handles filled curves differs from the way SVG and EPS style editors do. The latter two have the option to apply either of two rules, the non-zero rule or the even-odd rule, with the non-zero rule being default. The Windows .NET Framework 4.5 knows both rules too.

Mathematica'sFilledCurve doc page says:

Filled curves can be non-convex and intersect themselves. Self-intersecting curves are filled according to an even-odd rule that alternates between filling and not at each crossing.

Unfortunately, since Import translates filled curve as a FilledCurve with this even-odd rule one gets a star that was efficiently coded in SVG with five points as follows:

      {FaceForm[{Blue, Opacity[1.]}], 
       FilledCurve[{{{0, 2, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}}}, 
          {{{366.902, 230.137}, {258.902,265.33599999999996}, 
            {326.105, 173.336}, {326.105,286.93799999999993}, 
            {258.902, 194.93800000000002}}}
       AspectRatio -> Automatic]

Mathematica graphics

(BTW: I would consider this behavior of Import a bug, as it doesn't respect the original's default setting.)

Getting a star, filled as desired, takes twice as much points:

  Polygon@{{427.3, 183.3}, {401.5, 218.4}, {360.2, 204.8}, {385.7, 
     240}, {360, 275.2}, {401.5, 261.8}, {427.3, 296.6}, {427.2, 
     253.5}, {468.1, 240}, {427.2, 226.6}}}]

Mathematica graphics

(and, of course, Import doesn't do this automatically.)

My question is: Is there a way to let FilledCurve behave according to a non-zero rule, for instance using some undocumented properties like discussed here and here? If not, would it be doable to automatically break up a FilledCurve (that not necessarily contains only straight lines) into separate entities that fill up the original shape as intended?

share|improve this question
This isn't a bug in Import, it's an unfortunate limitation of the current Mathematica graphics language. Import's job is to create the best Mathematica representation of the input file as possible. The Mathematica graphics language simply doesn't support winding rule fills at this time. – ragfield Oct 3 '12 at 15:46
@ragfield Fair enough. Given the presence of the necessary functionality in Microsoft's framework, it appears the addition of this capability to FilledCurve should be quite doable. May I suggest putting this on the wishlist for version 10? – Sjoerd C. de Vries Oct 7 '12 at 15:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.