Class ColorQuantizer
Helper class for color quantization.
Namespace: Artemis.Core.ColorScience
Assembly: Artemis.Core.dll
Syntax
public static class ColorQuantizer
Methods
FindAllColorVariations(IEnumerable<SKColor>, bool)
Finds all the color variations available and returns a struct containing them all.
Declaration
public static ColorSwatch FindAllColorVariations(IEnumerable<SKColor> colors, bool ignoreLimits = false)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<SKColor> | colors | The colors to find the variations in |
bool | ignoreLimits | Ignore hard limits on whether a color is considered for each category. Some colors may be Empty if this is false |
Returns
Type | Description |
---|---|
ColorSwatch | A swatch containing all color variations |
FindColorVariation(IEnumerable<SKColor>, ColorType, bool)
Finds colors with certain characteristics in a given IEnumerable<T>.
Vibrant variants are more saturated, while Muted colors are less. Light and Dark colors have higher and lower lightness values, respectively.Declaration
public static SKColor FindColorVariation(IEnumerable<SKColor> colors, ColorType type, bool ignoreLimits = false)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<SKColor> | colors | The colors to find the variations in |
ColorType | type | Which type of color to find |
bool | ignoreLimits | Ignore hard limits on whether a color is considered for each category. Result may be Empty if this is false |
Returns
Type | Description |
---|---|
SKColor | The color found |
GetGradientFromImage(SKBitmap)
Gets a gradient from a given image.
Declaration
public static ColorGradient GetGradientFromImage(SKBitmap bitmap)
Parameters
Type | Name | Description |
---|---|---|
SKBitmap | bitmap | The image to process |
Returns
Type | Description |
---|---|
ColorGradient |
Quantize(in Span<SKColor>, int)
Quantizes a span of colors into the desired amount of representative colors.
Declaration
public static SKColor[] Quantize(in Span<SKColor> colors, int amount)
Parameters
Type | Name | Description |
---|---|---|
Span<SKColor> | colors | The colors to quantize |
int | amount | How many colors to return. Must be a power of two. |
Returns
Type | Description |
---|---|
SKColor[] |
|
QuantizeSplit(in Span<SKColor>, int)
Quantizes a span of colors, splitting the average splits
number of times.
Declaration
public static SKColor[] QuantizeSplit(in Span<SKColor> colors, int splits)
Parameters
Type | Name | Description |
---|---|---|
Span<SKColor> | colors | The colors to quantize |
int | splits | How many splits to execute. Each split doubles the number of colors returned. |
Returns
Type | Description |
---|---|
SKColor[] | Up to (2 ^ |