Show / Hide Table of Contents

Class Palette

A palette of colors.

Inheritance
object
Palette
Implements
IReadOnlyList<Color>
IReadOnlyCollection<Color>
IEnumerable<Color>
IEnumerable
IMatchable<Palette>
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 Palette : IReadOnlyList<Color>, IReadOnlyCollection<Color>, IEnumerable<Color>, IEnumerable, IMatchable<Palette>

Constructors

View Source

Palette(IEnumerable<Color>)

Creates a new palette of colors from a list of existing colors.

Declaration
public Palette(IEnumerable<Color> colors)
Parameters
Type Name Description
IEnumerable<Color> colors

The list of colors this palette is made from.

View Source

Palette(int)

Creates a new palette with the specified amount of colors.

Declaration
public Palette(int colors)
Parameters
Type Name Description
int colors

The number of colors.

Properties

View Source

Count

How many colors the palette has.

Declaration
public int Count { get; }
Property Value
Type Description
int
View Source

this[int]

Gets or sets a color in the palette by index.

Declaration
public Color this[int index] { get; set; }
Parameters
Type Name Description
int index

Index of the color.

Property Value
Type Description
Color

A color.

View Source

Length

How many colors the palette has.

Declaration
public int Length { get; }
Property Value
Type Description
int

Methods

View Source

GetEnumerator()

Gets the list of colors in the palette.

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

The colors in the palette.

View Source

GetNearest(Color)

Gets the closest color in the palette to the provided color.

Declaration
public Color GetNearest(Color color)
Parameters
Type Name Description
Color color

The color to find.

Returns
Type Description
Color

The closest matching color.

View Source

GetNearestIndex(Color)

Gets the index of the closest color in the palette to the provided color.

Declaration
public int GetNearestIndex(Color color)
Parameters
Type Name Description
Color color

The color to find.

Returns
Type Description
int

The palette index of the closest color.

View Source

Matches(Palette?)

Returns true if the two palettes hold identical colors in the same order.

Declaration
public bool Matches(Palette? other)
Parameters
Type Name Description
Palette other
Returns
Type Description
bool

True if the two palettes hold identical colors in the same order; false otherwise.

View Source

ShiftLeft()

Shifts the entire palette once to the left.

Declaration
public void ShiftLeft()
View Source

ShiftLeft(int, int)

Shifts a range of colors in the palette once to the left.

Declaration
public void ShiftLeft(int startingIndex, int count)
Parameters
Type Name Description
int startingIndex

The starting index in the palette.

int count

The amount of colors to shift from the starting index.

View Source

ShiftRight()

Shifts the entire palette once to the right.

Declaration
public void ShiftRight()
View Source

ShiftRight(int, int)

Shifts a range of colors in the palette once to the right.

Declaration
public void ShiftRight(int startingIndex, int count)
Parameters
Type Name Description
int startingIndex

The starting index in the palette.

int count

The amount of colors to shift from the starting index.

Implements

IReadOnlyList<T>
IReadOnlyCollection<T>
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