Skip to content
This repository has been archived by the owner on Aug 6, 2021. It is now read-only.

Linear Gradient

DarthAffe edited this page Nov 14, 2015 · 3 revisions

The LinearGradient is one of the default gradients provided by CUE.NET.
It's based on a set of GradientStops. All values are calculated as interpolation between the two GradientStops surrounding the requested point.

Using the linear gradient is quite easy. Just create a new instance of the LinearGradient-class and use an array of GradientStops as constructor-parameter.

If you want to create a gradient to draw something like this.

The gradient is the adopted line from the bottom left to the top right corner represented by the white line in the image.
Note that this direction-info is not included in the gradient!

you could use this code

GradientStop[] gradientStops =
{
    new GradientStop(0f, Color.Blue),
    new GradientStop(1f, Color.Red)
};
LinearGradient blueToRedGradient = new LinearGradient(gradientStops);