Note that the radial gradient becomes elliptical, when scaled. Here we create two color gradients, but more colors can be used. For more details, take a look at the documentation To run this example you will need the following file(s): ./gradient.box. If the example requires more than one file, then you should put them into the same directory. You can then launch Box with box -l g ./gradient.box.
// Under a shell type: box -l g gradient.box // --- // Here we test the gradient capabilities inherited from Cairo. include "g" // Define a linear and radial gradient g1 = Gradient[Line[(-25, -25), (0, 0)], color.red, color.yellow] g2 = Gradient[Circles[(10, 5), 0; 12], color.white, color.black] ball = Window[][Circle[g2, (10, 5), 12]] w = Window[][ Poly[g1, (-25, -25), (25, -25), (25, 25), (-25, 25)] Put[ball] // Just put the ball Window Put[ball, (-15, -10) // Translate... Scale[(0.2, 0.5)] // Scale and... Angle[const.pi*0.25]] // rotate ] w.Save["gradient.png"]