Show / Hide Table of Contents

Class Gradient

Represents a gradient with multiple color stops.

Inheritance
Object
Gradient
Implements
IEnumerable<GradientStop>
IEnumerable
IMatchable<Gradient>
Namespace: SadRogue.Primitives
Assembly: TheSadRogue.Primitives.dll
Syntax
public class Gradient : Object, IEnumerable<GradientStop>, IEnumerable, IMatchable<Gradient>

Constructors

Gradient(Color, Color)

Creates a new color gradient with only two colors, the first at the start, and the second at the end.

Declaration
public Gradient(Color startingColor, Color endingColor)
Parameters
Type Name Description
Color startingColor

The starting color of the gradient.

Color endingColor

The ending color of the gradient.

Gradient(Color[])

Creates a new color gradient, evenly spacing them out. At least one color must be provided.

Declaration
public Gradient(params Color[] colors)
Parameters
Type Name Description
Color[] colors

The colors to create a gradient from.

Gradient(IEnumerable<Color>, IEnumerable<Single>)

Creates a new color gradient with the defined colors and stops.

Declaration
public Gradient(IEnumerable<Color> colors, IEnumerable<float> stops)
Parameters
Type Name Description
IEnumerable<Color> colors

The colors with the gradient.

IEnumerable<Single> stops

The gradient stops where the colors are used.

Gradient(IEnumerable<GradientStop>)

Creates a new color gradient with the given colors/stops.

Declaration
public Gradient(IEnumerable<GradientStop> gradientStops)
Parameters
Type Name Description
IEnumerable<GradientStop> gradientStops

Stops to include in the gradient.

Fields

Stops

The color stops that define the gradient.

Declaration
public readonly GradientStop[] Stops
Field Value
Type Description
GradientStop[]

Methods

GetEnumerator()

Gets an enumerator with all of the gradient stops.

Declaration
public IEnumerator<GradientStop> GetEnumerator()
Returns
Type Description
IEnumerator<GradientStop>

An enumerator

Lerp(Single)

Returns a color from this gradient at the specified lerp value.

Declaration
public Color Lerp(float amount)
Parameters
Type Name Description
Single amount

The lerp amount.

Returns
Type Description
Color

A color.

Matches(Gradient)

Returns true if the given gradients contain precisely the same stops.

Declaration
public bool Matches(Gradient other)
Parameters
Type Name Description
Gradient other
Returns
Type Description
Boolean

True if the given gradients contain precisely the same stops; false otherwise.

ToColorArray(Int32)

Gets an array of colors based from the gradient.

Declaration
public Color[] ToColorArray(int count)
Parameters
Type Name Description
Int32 count

The amount of colors to produce.

Returns
Type Description
Color[]

An array of colors.

Operators

Implicit(Color to Gradient)

Converts a color to a gradient.

Declaration
public static implicit operator Gradient(Color color)
Parameters
Type Name Description
Color color
Returns
Type Description
Gradient

Implements

System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable
IMatchable<T>

Extension Methods

PropertyChangedEventHelpers.SafelySetProperty<TObject, TProperty>(TObject, ref TProperty, TProperty, EventHandler<ValueChangedEventArgs<TProperty>>)
PropertyChangedEventHelpers.SafelySetProperty<TObject, TProperty>(TObject, ref TProperty, TProperty, EventHandler<ValueChangedEventArgs<TProperty>>, EventHandler<ValueChangedEventArgs<TProperty>>)
In This Article
Back to top Generated by DocFX