10

Bug introduced in V9.0 or earlier and persisting through V11.3


Here's an example:

Graphics[
    GraphicsComplex[
        {{-1, 0}, {0, 1}, {1, 0}}, 
        BSplineCurve[{1, 2, 3}, SplineClosed -> True]
    ],
    PlotRange -> 1.1, Axes -> True
]

enter image description here

works well, but when we add FilledCurve over BSplineCurve, it doesn't anymore.

FilledCurve @ BSplineCurve[{1,2,3}, SplineClosed -> True]

enter image description here


The workaround is to keep it outside GraphicsComplex:

Graphics[{
  FilledCurve @ BSplineCurve[{{-1, 0}, {0, 1}, {1, 0}}, SplineClosed -> True], 
  GraphicsComplex[{{-1, 0}, {0, 1}, {1, 0}}, Line[{1, 2, 3}]]
  },
  PlotRange -> 1.1, Axes -> True
]

enter image description here

But this just adds work which I would like to avoid. Is it possible?

Could that problem have been anticipated?


Edit: Here's a response from WRI:

It does appear as though GraphicsComplex is misbehaving with the FilledCurve option applied to BSplineCurve. I have thus filed a report with our developers so that they may look in to the issue.

In the meantime, as a workaround you could use replacement rules to get behavior similar to the GraphicsComplex functionality:

Graphics[
    FilledCurve@BSplineCurve[{1, 2, 3}, SplineClosed -> True], 
    PlotRange -> 1.1, Axes -> True
] /. Thread[Range[3] -> {{-1, 0}, {0, 1}, {1, 0}}]
Kuba
  • 136,707
  • 13
  • 279
  • 740

2 Answers2

5

This is fixed in M12:

Graphics[
    GraphicsComplex[
        {{-1,0},{0,1},{1,0}},
        FilledCurve@BSplineCurve[{1,2,3},SplineClosed->True]
    ],
    PlotRange->1.1,
    Axes->True
]

enter image description here

Carl Woll
  • 130,679
  • 6
  • 243
  • 355
4

Not very clean:

v = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

r = Normal /@ {Graphics[GraphicsComplex[v, Polygon[{1, 2, 3, 4}]]], 
               Graphics[GraphicsComplex[v, {Red, Line[{1, 2, 3, 4, 1}]}]]};

r /. {Red, Line[x__]} :> (FilledCurve@Line@x)

Mathematica graphics

Dr. belisarius
  • 115,881
  • 13
  • 203
  • 453