6
$\begingroup$

I have this code:

Graphics[
  {Polygon[CirclePoints[25, 4]], 
   {Yellow, Disk[{0, -15}, 1]}, 
   {Yellow, Disk[{0, 0}, 1]}, 
   {Yellow, Disk[{0, 15}, 1]}, 
   {Blue, Disk[{-15, 0}, 1]}, 
   {Blue,Disk[{-15, 15}, 1]}, 
   {Blue, Disk[{-15, -15}, 1]}, 
   {Yellow,Disk[{15, -15}, 1]}, 
   {Blue, Disk[{15, 0}, 1]}, 
   {Yellow, Disk[{15, 15}, 1]}, 
   {Red, Rectangle[{-16, -16}, {-14, 16}]}, 
   {Red, Rectangle[{-1, -16}, {1, 16}]}, 
   {Red, Rectangle[{14, -16}, {16, 16}]}}]

I am trying to figure out a simple way to make the yellow disks turn orange and the blue to turn purple when the red is over them. I looked at Blend but cannot see how that would help. I feel like there must be a simple way to do this, but have very little experience with Mathematica graphics.

$\endgroup$
  • 1
    $\begingroup$ You want to use Opacity. $\endgroup$ – wxffles Feb 7 '17 at 22:08
  • $\begingroup$ Yep... just insert Opacity[0.5], before Polygon.... $\endgroup$ – David G. Stork Feb 7 '17 at 22:27
  • $\begingroup$ Possible duplicates: (11565), (14836), (47809) $\endgroup$ – Mr.Wizard Feb 8 '17 at 2:23
6
$\begingroup$

Not only should you introduce Opacity as suggested in the comments, you should also rearrange the order of evaluation in your graphics expression.

Graphics[
  {Polygon[CirclePoints[25, 4]],
   {Red, 
      Rectangle[{-16, -16}, {-14, 16}],
      Rectangle[{-1, -16}, {1, 16}],
      Rectangle[{14, -16}, {16, 16}]},
   {Opacity[.5],
     {Yellow,
        Disk[{0, -15}, 1], Disk[{0, 0}, 1], Disk[{0, 15}, 1], Disk[{15, -15}, 1], 
        Disk[{15, 15}, 1]},
     {Blue,
        Disk[{-15, 0}, 1], Disk[{-15, 15}, 1], Disk[{-15, -15}, 1], 
        Disk[{15, 0}, 1]}}}]

graphics

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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