Gradient Fill using Graphics in Mathematica

2019-06-20 01:56发布

问题:

How could I create the following using Rectangle[] in Graphics[]?

回答1:

Using Polygon, you can

Graphics[{EdgeForm[Black], 
  Polygon[{{0, 0}, {3, 0}, {3, 1}, {0, 1}}, 
   VertexColors -> {White, Red, Red, White}]}]


回答2:

Also:

Graphics[Raster[{Range[100]/100}, ColorFunction -> (Blend[{White, Red}, #] &)], 
 AspectRatio -> .3, 
 Frame       -> True, 
 FrameTicks  -> None]