Class Palette
Represents a palette of colors
public sealed class Palette : IDisposable, ISpanFormattable, IFormattable, IEnumerable<Color<byte>>, IEnumerable
- Inheritance
-
Palette
- Implements
- Inherited Members
Constructors
Palette(int)
Creates a new Palette with a specified number of colors
public Palette(int length)
Parameters
lengthintThe number of color entries in the palette
Remarks
All palette entries are initialized to be fully white and fully opaque. Use TrySetColors(ReadOnlySpan<Color<byte>>, int) to change the colors in the palette.
Properties
Colors
Gets the colors in the palette
public ReadOnlySpan<Color<byte>> Colors { get; }
Property Value
- ReadOnlySpan<Color<byte>>
The colors in the palette
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Remarks
Don't use the value of the Colors property or any copies or slices of that value (ReadOnlySpan<T>) after disposing the Palette!
~Palette()
protected ~Palette()
GetEnumerator()
Gets an Palette.Enumerator that enumerates the colors in the palette
public Palette.Enumerator GetEnumerator()
Returns
Exceptions
- ArgumentNullException
paletteisnull
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
ToString(IFormatProvider?)
Formats the value of the current instance using the specified format.
public string ToString(IFormatProvider? formatProvider)
Parameters
formatProviderIFormatProviderThe provider to use to format the value.
-or-
A null reference (
Nothingin Visual Basic) to obtain the numeric format information from the current locale setting of the operating system.
Returns
- string
The value of the current instance in the specified format.
ToString(string?)
Formats the value of the current instance using the specified format.
public string ToString(string? format)
Parameters
formatstringThe format to use.
-or-
A null reference (
Nothingin Visual Basic) to use the default format defined for the type of the IFormattable implementation.
Returns
- string
The value of the current instance in the specified format.
ToString(string?, IFormatProvider?)
Formats the value of the current instance using the specified format.
public string ToString(string? format, IFormatProvider? formatProvider)
Parameters
formatstringThe format to use.
-or-
A null reference (
Nothingin Visual Basic) to use the default format defined for the type of the IFormattable implementation.formatProviderIFormatProviderThe provider to use to format the value.
-or-
A null reference (
Nothingin Visual Basic) to obtain the numeric format information from the current locale setting of the operating system.
Returns
- string
The value of the current instance in the specified format.
TryFormat(Span<char>, out int, ReadOnlySpan<char>, IFormatProvider?)
Tries to format the value of the current instance into the provided span of characters.
public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format = default, IFormatProvider? provider = null)
Parameters
destinationSpan<char>The span in which to write this instance's value formatted as a span of characters.
charsWrittenintWhen this method returns, contains the number of characters that were written in
destination.formatReadOnlySpan<char>A span containing the characters that represent a standard or custom format string that defines the acceptable format for
destination.providerIFormatProviderAn optional object that supplies culture-specific formatting information for
destination.
Returns
TrySetColors(ReadOnlySpan<Color<byte>>, int)
Tries to set a range of colors in the palette
public bool TrySetColors(ReadOnlySpan<Color<byte>> colors, int offset = 0)
Parameters
colorsReadOnlySpan<Color<byte>>The colors to copy into the palette
offsetintThe index of the first palette entry to modify (offset into the palette)
Returns
- bool
true, if the provided range ofcolorswas successfully copied into the palette; otherwise,false(check TryGet(out string?) for more information)