Two-dimensional graphics can be created using the function Graphics and a list of graphics primitives. For three-dimensional graphics, see the following section. The following primitives are available:
Circle[{x, y}, r]Disk[{x, y}, r]Rectangle[{$x_1$, $y_1$}, {$x_2$, $y_2$}]Polygon[{{$x_1$, $y_1$}, {$x_2$, $y_2$}, ...}]Line[{{$x_1$, $y_1$}, {$x_2$, $y_2$}, ...}]Text[text, {x, y}]Graphics[{Circle[{0, 0}, 1]}]
Graphics[{Line[{{0, 0}, {0, 1}, {1, 1}, {1, -1}}], Rectangle[{0, 0}, {-1, -1}]}]
Colors can be added in the list of graphics primitives to change the drawing color. The following ways to specify colors are supported:
RGBColor[r, g, b]CMYKColor[c, m, y, k]Hue[h, s, b]GrayLevel[l]All components range from 0 to 1. Each color function can be supplied with an additional argument specifying the desired opacity (“alpha”) of the color. There are many predefined colors, such as Black, White, Red, Green, Blue, etc.
Graphics[{Red, Disk[]}]
Table of hues:
Graphics[Table[{Hue[h, s], Disk[{12h, 8s}]}, {h, 0, 1, 1/6}, {s, 0, 1, 1/4}]]
Colors can be mixed and altered using the following functions:
Blend[{$color1$, $color2$}, ratio]Lighter[color]White).Darker[color]Black).Graphics[{Lighter[Red], Disk[]}]
Graphics produces a GraphicsBox:
Head[ToBoxes[Graphics[{Circle[]}]]]