Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Problem / background: consider the following code snippet.

pnt[fig_, n_] := {fig[[1, n]], fig[[2, n]]}
hor := {.025, .1, .25, .4, .475, .525, .6, .75, .9, .975}
ver := {.05, .20, .80, .95}
fig4 := Transpose[{
   {hor[[1]], ver[[2]], 1}, {hor[[2]], ver[[1]], 1}, {hor[[4]], 
    ver[[1]], 1}, {hor[[5]], ver[[2]], 1},
   {hor[[1]], ver[[3]], 1}, {hor[[2]], ver[[4]], 1}, {hor[[4]], 
    ver[[4]], 1}, {hor[[5]], ver[[3]], 1},
   {hor[[6]], ver[[2]], 1}, {hor[[7]], ver[[1]], 1}, {hor[[9]], 
    ver[[1]], 1}, {hor[[10]], ver[[2]], 1},
   {hor[[6]], ver[[3]], 1}, {hor[[7]], ver[[4]], 1}, {hor[[9]], 
    ver[[4]], 1}, {hor[[10]], ver[[3]], 1},
   {hor[[3]], ver[[2]], 1}, {hor[[3]], ver[[3]], 1},
   {hor[[8]], ver[[2]], 1}, {hor[[8]], ver[[3]], 1}
   }]
draw4A[fig_] := {
  BezierCurve[{pnt[fig, 1], pnt[fig, 2], pnt[fig, 3], pnt[fig, 4]}],
  BezierCurve[{pnt[fig, 5], pnt[fig, 6], pnt[fig, 7], pnt[fig, 8]}],
  BezierCurve[{pnt[fig, 9], pnt[fig, 10], pnt[fig, 11], pnt[fig, 12]}],
  BezierCurve[{pnt[fig, 13], pnt[fig, 14], pnt[fig, 15], 
    pnt[fig, 16]}],
  Line[{pnt[fig, 1], pnt[fig, 4]}],
  Line[{pnt[fig, 5], pnt[fig, 8]}],
  Line[{pnt[fig, 9], pnt[fig, 12]}],
  Line[{pnt[fig, 13], pnt[fig, 16]}]}
Graphics[draw4A[fig4]]

which draws four half-pie type of objects:

enter image description here

Question: I want to fill each part with a different, optional color different than that of the surrounding line. How can I add this fill color?

share|improve this question
    
Question: for hor, ver, and fig4 your using SetDelayed, yet they're static values. Are these just place holders for more complex code, as plane Set is better in this context? –  rcollyer Feb 16 '12 at 18:14
    
Thank you for noticing @rcollyer. I'll have look at it. The actual code does more than this though. –  ndroock1 Feb 16 '12 at 20:51
    
I figured it was more complex and they were possibly acting as placeholders. –  rcollyer Feb 16 '12 at 21:51

2 Answers 2

up vote 5 down vote accepted

I presume you are looking for FilledCurve.

enter image description here

enter image description here

share|improve this answer
    
That looks like it..., am going to try this now,. –  ndroock1 Feb 16 '12 at 13:19
    
Yes, works much easier than expected, thank you. - mathematics-diary.blogspot.com/2012/02/… –  ndroock1 Feb 16 '12 at 14:15

Also, you can use FaceForm if you want to specify more than one directive (i.e. not just color, but opacity, etc.) for the primitive:

Graphics[{FaceForm[{Pink, Opacity[.2]}], EdgeForm[Black], 
  FilledCurve[BezierCurve[{{-1, 0}, {-1, 2}, {1, 2}, {1, 0}}]]}, 
 ImageSize -> 100]

Mathematica graphics

share|improve this answer
    
I gave this a vote, but now I am wondering is it necessary to use both FaceForm and EdgeForm? Can you not simply give the directives in FaceForm directly? This appears to work with other primitives. Is FilledCurve different? –  Mr.Wizard Feb 16 '12 at 13:59
    
I think you need both as they cannot be combined. For example you cannot specify Thickness in FaceForm, as it results in the Pink Screen of Death. –  István Zachar Feb 16 '12 at 14:12
    
But are there any combinations that require both FaceForm and EdgeForm? You could put Thickness in either the main list or EdgeForm, right? –  Mr.Wizard Feb 16 '12 at 14:14
    
@Mr.Wizard I could not think of any at the moment. Proper order of naked directives in the main list usually is enough. Would be nice to find a counterexample though. –  István Zachar Feb 17 '12 at 10:14

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.