6

I can draw a polygon with a curved edge using B-splines or Bézier curves:

Graphics[{Line[{{-1, -1}, {1, 2}, {3, -2}, {1, -4}}],
          BSplineCurve[{{-1, -1}, {1, -3}, {-0.75, -2}, {1, -4}}]}]

Curved polygon

My question is: how can I then color the inside of this polygon with a color of my choosing?

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
Musang
  • 1,038
  • 1
  • 9
  • 20

1 Answers1

9
g1 = Graphics[{Line[{{-1, -1}, {1, 2}, {3, -2}, {1, -4}}], 
    BSplineCurve[{{-1, -1}, {1, -3}, {-0.75, -2}, {1, -4}}]}];

BoundaryDiscretizeGraphics[g1, MeshCellStyle -> {1 -> Red, 2 -> LightYellow}]

enter image description here

Also

g1 /. {Line[x_], BSplineCurve[y_]} :> 
  Module[{ls = Join[x, BSplineFunction[y] /@ Subdivide[50]]},
   {EdgeForm[Red], LightGreen, Polygon[ls[[First@FindCurvePath[ls]]]]}]

enter image description here

and

Graphics[{EdgeForm[Red], LightCyan, 
  FilledCurve[{BSplineCurve[{{-1, -1}, {1, -3}, {-0.75, -2}, {1, -4}}], 
    Line[Reverse @ {{-1, -1}, {1, 2}, {3, -2}, {1, -4}}]}]}]

enter image description here

kglr
  • 394,356
  • 18
  • 477
  • 896