Skip to main content

Shade class

Namespace: Arlecchino.Rendering.Colors · Assembly: Arlecchino.Core

Colors worked out against the background they will be read on, so a palette is written as how far apart things should read rather than as a list of colors that only suit one terminal.

public static class Shade

Methods

MemberSummary
Against(Rgb, double, double, double)A color of this hue and chroma, as light or as dark as it must be to reach the wanted contrast against the background. The hue is kept whatever happens, and the chroma is cut only to stay in sRGB.
Against(Rgb, Rgb, double)The same, taking the hue and chroma off a color that already has them.
Lifted(Rgb, double)The background lifted off itself by a step of lightness, which is what a raised surface is. It keeps the background's own hue and chroma, being the same surface raised rather than a different one.
Pull(Rgb)How much a background's own color should sway a design drawn for a gray one. It is nothing behind a terminal theme and everything behind a background someone chose a color for.
Rise(Rgb)Which way surfaces are raised off this background: lighter on a dark terminal, darker on a light one, and the other way where that would take the tallest of them across Contrast.Pivot.
Scaled(double, double, double, Rgb)A wanted contrast brought down to what the background can actually give, keeping the order of a ladder that would otherwise flatten. A background near the middle reaches about 5 and no more.
Turn(Rgb, double, double)The turn to add to every hue of a design so it sits at an angle from a colored background rather than across from it. Turning the whole design at once keeps its colors spaced as they were drawn.

Methods in detail

Against(Rgb, double, double, double)

public static Rgb Against(Rgb background, double hue, double chroma, double contrast);

A color of this hue and chroma, as light or as dark as it must be to reach the wanted contrast against the background. The hue is kept whatever happens, and the chroma is cut only to stay in sRGB.

Parameters

NameTypeDescription
backgroundRgbThe color it will be read on.
huedoubleDegrees around the wheel, which the answer keeps.
chromadoubleHow vivid to be, cut back where sRGB cannot hold it.
contrastdoubleThe contrast to reach, or as near as the background allows.

Returns Rgb — The color to write in.

Against(Rgb, Rgb, double)

public static Rgb Against(Rgb background, Rgb sample, double contrast);

The same, taking the hue and chroma off a color that already has them.

Parameters

NameTypeDescription
backgroundRgbThe color it will be read on.
sampleRgbThe color whose hue and chroma to keep.
contrastdoubleThe contrast to reach.

Returns Rgb — The color to write in.

Lifted(Rgb, double)

public static Rgb Lifted(Rgb background, double step);

The background lifted off itself by a step of lightness, which is what a raised surface is. It keeps the background's own hue and chroma, being the same surface raised rather than a different one.

Parameters

NameTypeDescription
backgroundRgbThe surface to lift off.
stepdoubleHow far, in lightness, a whole surface being about 0.07.

Returns Rgb — The raised surface.

Pull(Rgb)

public static double Pull(Rgb background);

How much a background's own color should sway a design drawn for a gray one. It is nothing behind a terminal theme and everything behind a background someone chose a color for.

Parameters

NameTypeDescription
backgroundRgbThe color behind the text.

Returns double — How far to follow the background, from 0 to 1.

Rise(Rgb)

public static double Rise(Rgb background);

Which way surfaces are raised off this background: lighter on a dark terminal, darker on a light one, and the other way where that would take the tallest of them across Contrast.Pivot.

Parameters

NameTypeDescription
backgroundRgbThe color behind the text.

Returns double1 where a raised surface is the lighter one, -1 where it is the darker.

Scaled(double, double, double, Rgb)

public static double Scaled(double contrast, double lowest, double highest, Rgb background);

A wanted contrast brought down to what the background can actually give, keeping the order of a ladder that would otherwise flatten. A background near the middle reaches about 5 and no more.

Parameters

NameTypeDescription
contrastdoubleThe contrast the design asks for.
lowestdoubleThe least contrast in the ladder, which is left where it is.
highestdoubleThe most contrast in the ladder.
backgroundRgbThe color everything is read on.

Returns double — The contrast to ask Shade.Against for.

Turn(Rgb, double, double)

public static double Turn(Rgb background, double anchor, double offset);

The turn to add to every hue of a design so it sits at an angle from a colored background rather than across from it. Turning the whole design at once keeps its colors spaced as they were drawn.

Parameters

NameTypeDescription
backgroundRgbThe color behind the text.
anchordoubleThe hue of the design's own accent, which the turn is measured from.
offsetdoubleHow far from the background the accent is to end up.

Returns double — Degrees to add to every hue, which is nothing behind a near-neutral terminal.