Show / Hide Table of Contents

Class Gradient

Represents a gradient with multiple color stops.

Inheritance
object
Gradient
Implements
IEnumerable<GradientStop>
IEnumerable
IMatchable<Gradient>
Inherited Members
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: SadRogue.Primitives
Assembly: TheSadRogue.Primitives.dll
Syntax
[DataContract]
public class Gradient : IEnumerable<GradientStop>, IEnumerable, IMatchable<Gradient>

Constructors

View Source

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.

View Source

Gradient(params 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.

View Source

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

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<float> stops

The gradient stops where the colors are used.

View Source

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

View Source

Stops

The color stops that define the gradient.

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

Methods

View Source

GetEnumerator()

Gets an enumerator with all of the gradient stops.

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

An enumerator

View Source

Lerp(float)

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

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

The lerp amount.

Returns
Type Description
Color

A color.

View Source

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
bool

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

View Source

ToColorArray(int)

Gets an array of colors based from the gradient.

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

The amount of colors to produce.

Returns
Type Description
Color[]

An array of colors.

Operators

View Source

implicit operator Gradient(Color)

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

IEnumerable<T>
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>>?)
ToStringExtensions.ExtendToString<T>(IEnumerable<T>, string, Func<T, string>?, string, string)
  • View Source
In this article
Back to top Generated by DocFX