How could I create the following using Rectangle[]
in Graphics[]
?
Asked
Active
Viewed 2,551 times
6
2 Answers
7
Using Polygon
, you can
Graphics[{EdgeForm[Black],
Polygon[{{0, 0}, {3, 0}, {3, 1}, {0, 1}},
VertexColors -> {White, Red, Red, White}]}]

Szabolcs
- 24,728
- 9
- 85
- 174
-
3And just for fun (requires a webcam to work): pts = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; Graphics[{Texture[CurrentImage[]], Polygon[pts, VertexTextureCoordinates -> pts]}] – Arnoud Buzing Nov 16 '11 at 00:31
-
CurrentImage[] - an interesting example of a function that works so much better in the online documentation than it does on my machine... :) And how do you switch it off... – cormullion Nov 16 '11 at 14:37
-
@cormullion It works pretty well here. Try `Dynamic@CurrentImage[]`. The very first frame it captures might be black (it needs time to adjust), and if there are several `Dynamic` ones, it gets a bit unreliable. `ImageCapture[]` opens an UI that lets you switch it off. – Szabolcs Nov 16 '11 at 14:44
5
Also:
Graphics[Raster[{Range[100]/100}, ColorFunction -> (Blend[{White, Red}, #] &)],
AspectRatio -> .3,
Frame -> True,
FrameTicks -> None]

Dr. belisarius
- 60,527
- 15
- 115
- 190