
Recreating HAL 9000 using radial gradients
Along with linear gradients, Inkscape also comes with radial gradients. In radial gradients color stops define different circle radii and the color blends between them.
Everything we've learned about linear gradients can be applied to radial ones as well. Radial gradients also have some special features, we will take a look at them throughout this recipe.
In the following recipe, we will create a radial gradient by taking inspiration from an iconic image in sci-fi cinematography.
Getting ready
"Just what do you think you're doing, Dave?" HAL 9000
If you haven't watched Stanley Kubrick's masterpiece 2001: A Space Odyssey, you might not know what the iconic computer HAL 9000 looks like. Take a peek at the finished drawing on the following pages to see what we're about to create, or visit Wikipedia for a detailed description: http://en.wikipedia.org/wiki/HAL_9000.
Since the famous scene from the movie takes place in outer space, we will want to place HAL 9000 in a more appropriate visual context, such as a black background.
You can do this in Document Properties (Shift + Ctrl + D) on the Page tab. Don't forget to set the A (Alpha) box to 255 (fully opaque) because the default is set to 0 (fully transparent).
How to do it...
The following steps will show you how to create HAL 9000:
- Select the Ellipse tool (F5).
- Draw a large circle by holding the Ctrl key.
- Fill the circle with Yellow (#FFFF00) color, set stroke width to 50 or 100, whichever makes more sense to serve as a rim, and color the stroke 30% Gray.
- Select Gradient tool (G).
- Make sure that the button on the gradient toolbar Create radial (elliptic or circular) gradient
and Create gradient in the fill
are selected:
- Hold Ctrl to constrain movement to vertical, click in the center of the bounding box, drag downwards to create a radial gradient fill and release when you reach object bounding box.
- Click on the Black color chip to change the end stop to black.
- Hold Ctrl while dragging the right end stop until you reach the object bounding box.
- Hold Ctrl + Shift while clicking on the bottom end stop and move it towards the center, release after you've traveled approximately one third the distance towards the center. This is what you should end up with something closely similar to the following image:
- Create a new stop approximately at the center of the gradient path by double-clicking.
- Select the new stop and color it Red (#FF0000). Drag the red stop halfway towards the center and release it.
- Create a new stop half way between the red and start (square) stop by double-clicking on the gradient path. Move the new stop half way towards the center. On the gradient toolbar select button Create gradient in the stroke:
- Increase the opacity of the end (circle) stop by replacing 0 with 100 in the Opacity box in the Style indicator.
- Click and drag the start stop (square) towards the center until it snaps with the fill gradient start stop.
- Hold Ctrl while dragging the top end stop until you reach the object bounding box. Hold Ctrl while dragging the left end stop until you reach the object bounding box. Hold Ctrl + Shift while clicking on the top end stop and move it a bit towards the center, release when you've traveled one third of the stroke width.
- Create a new stop by double-clicking approximately at the center of the gradient path leg. Select the new stop and color it 80% Gray. Drag the new gray stop outwards until it reaches the end stop over the stroke, you should end up with the final HAL 9000 staring eerily at us:

How it works...
Radial gradients are set by manipulating a gradient path that has two perpendicular legs. If the legs are the same length we get a circular gradient, if one is longer than the other we get an elliptical gradient.
We can also enhance the gradient by placing extra stops on of the legs; any additions will also be mirrored on the other legs. If the legs aren't of the same length the stops will be placed and moved proportionally.
Holding Ctrl while creating a new gradient can be of assistance when creating gradients constrained to specific angles. This is useful when creating circular gradients, and especially so when snapping is enabled. Start stops can be snapped to the object center and end stops can be snapped to object bounding box or object path.
To maintain the same leg-length ratio hold Shift + Ctrl while dragging one of the end stops.
It can be a bit challenging to edit gradients when both fill and stroke are set to circular gradients. Often we want their start stops to snap together at the object center, but after we do that we can't edit the start stops independently whatever color you apply both stops will take it. The workaround is to edit one of the gradients off-center and snap it after you've achieved the desired look. Or simply detach one gradient from the other by holding Shift while dragging start stop away whenever a change is needed.
HAL 9000 can also be created without the stroke, by using a complex gradient on the fill. Look for the example without stroke in the SVG file RadialGradients.svg
accompanying this chapter.
There's more...
HAL 9000 is a good example of what a few symmetric, circular gradients can accomplish. It is also possible to create asymmetric radial gradients by moving the gradient center away from the start stop. The gradient center isn't normally visible, but when dragged away from the start stop it is represented with a cross. Here's an example:

The fill radial gradient controls the little "orb" we see in the middle. Its gradient center is offset a bit towards the top creating a 3D effect. Stroke gradient center is also offset towards the top also providing a 3D effect on the stroke.
Can you guess how the following example was created? If not, peek inside RadialGradients.svg
accompanying this chapter.

See also
For more information, refer to the recipe on Creating linear gradients in this chapter.