6

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.

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
Curious27
  • 85
  • 4

1 Answers1

6

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

m_goldberg
  • 107,779
  • 16
  • 103
  • 257