Mathematica: Opacity and graphics

  • Context: Mathematica 
  • Thread starter Thread starter Niles
  • Start date Start date
  • Tags Tags
    Graphics Mathematica
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 3K views
Niles
Messages
1,834
Reaction score
0
Hi

I have the following graphic:
Code:
Graphics[{Opacity[0.5], Rectangle[{0, 0}, {1, 3}]}]
Say I want opacity to vary with x, e.g. with the expression opacity = x^2. Is there a way to do this? I checked out the "Help", but there were no examples of a varying opacity.


Niles.
 
Physics news on Phys.org
Use Raster instead of Rectangle:

Graphics[Raster[Table[{0, 0, 0, x/128}, {x, 128}, {256}]]]

The elements of the Raster are {red, green, blue, opacity}.
 
Thanks, it is kind of you to help me.Niles.