Class ColorHarmony
Derives a set of related colors from one base color by rotating its hue according to a classical harmony scheme.
Inherited Members
Namespace: Scylla.Core.Util
Assembly: ScyllaCore.dll
Syntax
public static class ColorHarmony
Remarks
Pick a scheme with ColorHarmonyType and a color space with ColorHarmonyHueMode. The scheme decides which hues come back; the mode decides whether they match the base color in perceived brightness, in raw saturation, or in saturation relative to what each hue can actually hold.
The first entry of every result is the base hue, so a returned set can be assigned to palette roles in order without re-checking which one the caller started from.
Methods
Generate(Color, ColorHarmonyType, int, ColorHarmonyHueMode)
Generates the set of colors that make up a harmony scheme around a base color.
Declaration
public static Color[] Generate(Color baseColor, ColorHarmonyType type, int monoCount = 5, ColorHarmonyHueMode hueMode = ColorHarmonyHueMode.Oklch)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | baseColor | The color the scheme is built around. |
| ColorHarmonyType | type | The harmony scheme to apply. |
| int | monoCount | Number of entries for Monochromatic. Values below 2 are raised to 2. Ignored by every other scheme. |
| ColorHarmonyHueMode | hueMode | The color space the rotation happens in. |
Returns
| Type | Description |
|---|---|
| Color[] | A new array whose first entry is the base hue, with the original alpha preserved throughout. |
Remarks
Monochromatic ignores
hueMode and sweeps lightness across a single hue
instead of rotating. Every other scheme rotates the fixed offsets
listed on ColorHarmonyType.
GetHueOffsetsDegrees(ColorHarmonyType, int)
Returns the hue rotations, in degrees, that a harmony scheme applies to the base hue.
Declaration
public static float[] GetHueOffsetsDegrees(ColorHarmonyType type, int monoCount = 5)
Parameters
| Type | Name | Description |
|---|---|---|
| ColorHarmonyType | type | The harmony scheme to describe. |
| int | monoCount | Number of entries for Monochromatic. Values below 2 are raised to 2. Ignored by every other scheme. |
Returns
| Type | Description |
|---|---|
| float[] | A new array of hue offsets in degrees. |
Remarks
The first offset is always zero, since every scheme includes the base hue itself. Use this to draw a scheme on a hue wheel without generating the colors.
Monochromatic returns an array of zeros, one per requested entry, because the scheme varies lightness rather than hue.