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$
3
  • 1
    $\begingroup$ You want to use Opacity. $\endgroup$
    – wxffles
    Commented Feb 7, 2017 at 22:08
  • $\begingroup$ Yep... just insert Opacity[0.5], before Polygon.... $\endgroup$ Commented Feb 7, 2017 at 22:27
  • $\begingroup$ Possible duplicates: (11565), (14836), (47809) $\endgroup$
    – Mr.Wizard
    Commented Feb 8, 2017 at 2:23

1 Answer 1

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 and acknowledge you have read our privacy policy.

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