User Guide

Ruby Component
Path Gradients
Path gradients provide another way of producing smooth transitional fills between different colours. Unlike the LinearGradientBrush they
create a radial gradient from a central colour out towards a set of surrounding colours.
The surrounding area is defined by a path and colours can be distributed along the path. A single central colour is also defined and the
colour gradient is calculated by blending outwards from the central point.
In its simplest form a PathGradientBrush allows you to define a gradient between two colours. You create an instance of the class as follows:
b = PathGradientBrush.new path
There is a single input parameter, the path. The path can either be an array of points (represented as an array of two element arrays
containing the x and y coordinates of each point) or it can be a GraphicsPath object.
The default colours are Black at the centre and White on the path.
Here's an example using a square path and the default colours:
Changing Colours
There are two methods of the PathGradientBrush class that allow you to change the colours.
setCenterColor colour
setSurroundColours colourArray
The setCenterColor method takes a single colour object. The setSurroundColours method takes an array of colours. By default these
colours are allocated in turn to each point in the path. If there are fewer colours than path points and so we run out of colours when allocating
them to points on the path, the last colour in the array is used on all subsequent points.
The example below shows what we get when changing the centre colour to pink and the outer colours to red, green, blue and yellow.
132 of 212