Skip to main content

ColorModal class

Namespace: Arlecchino.Modals.Setting · Assembly: Arlecchino

A color picked on three sliders: hue, saturation and lightness, converted to Rgb on the way out. Both directions round to whole units, so feeding a color back in can shift it by one.

public sealed class ColorModal : Modal

Inherits from Modal

Constructors

MemberSummary
ColorModal()

Properties

MemberSummary
ChannelWhich of the three sliders the arrows move.
ChannelMaximumUpper end of the slider the arrows move.
ChannelRowsWhere each slider's row was drawn last frame, used to turn a click into a channel.
ChannelTracksWhere each slider's track was drawn last frame, used to turn a click into a value.
ChannelValueValue of the slider the arrows move.
HuePosition on the color wheel, from 0 to 359. It wraps rather than stopping.
LargeStepHow far the page keys move the active slider.
LightnessDistance from black toward white, in percent. Fifty is the pure color.
OnPickedCalled with the color that was confirmed.
SaturationDistance from gray, in percent.
StepHow far the arrow keys move the active slider.
ValueThe three sliders resolved into a color, as drawn in the swatch.

Methods

MemberSummary
Add(int)Moves the active slider. Hue wraps around the wheel; the other two halt at their ends.
Draw(ModalFrame)
Handle(ModalFrame, KeyPress)
HandleMouse(ModalFrame, MouseEvent)
MaximumOf(ColorChannel)Upper end of a slider, since hue counts degrees and the others count percent.
MoveChannel(int)Moves between the sliders, stopping at the first and the last.
MoveToMaximum()Jumps the active slider to its right end.
MoveToMinimum()Jumps the active slider to its left end.
SetChannelFromFraction(ColorChannel, decimal)Places a slider's handle at a position along its track.
SetValue(Rgb)Loads a color into the three sliders, which is how an existing value is edited.
ValueOf(ColorChannel)Value of a slider, for drawing all three at once.

Constructors in detail

ColorModal()

Obsolete

Constructors of types with required members are not supported in this version of your compiler.

public ColorModal();

Properties in detail

Channel

public ColorChannel Channel { get; set; }

Which of the three sliders the arrows move.

Type ColorChannel

ChannelMaximum

public int ChannelMaximum { get; }

Upper end of the slider the arrows move.

Type int

ChannelRows

public SurfaceRegion[] ChannelRows { get; set; }

Where each slider's row was drawn last frame, used to turn a click into a channel.

Type SurfaceRegion[]

ChannelTracks

public SurfaceRegion[] ChannelTracks { get; set; }

Where each slider's track was drawn last frame, used to turn a click into a value.

Type SurfaceRegion[]

ChannelValue

public int ChannelValue { get; }

Value of the slider the arrows move.

Type int

Hue

public int Hue { get; set; }

Position on the color wheel, from 0 to 359. It wraps rather than stopping.

Type int

LargeStep

public int LargeStep { get; init; }

How far the page keys move the active slider.

Type int

Lightness

public int Lightness { get; set; }

Distance from black toward white, in percent. Fifty is the pure color.

Type int

OnPicked

public Action<Rgb> OnPicked { get; init; }

Called with the color that was confirmed.

Type Action<T><Rgb>

Saturation

public int Saturation { get; set; }

Distance from gray, in percent.

Type int

Step

public int Step { get; init; }

How far the arrow keys move the active slider.

Type int

Value

public Rgb Value { get; }

The three sliders resolved into a color, as drawn in the swatch.

Type Rgb

Methods in detail

Add(int)

public void Add(int delta);

Moves the active slider. Hue wraps around the wheel; the other two halt at their ends.

Parameters

NameTypeDescription
deltaintHow far to move; negative goes left.

Draw(ModalFrame)

public override void Draw(ModalFrame frame);

Parameters

NameTypeDescription
frameModalFrame

Handle(ModalFrame, KeyPress)

public override void Handle(ModalFrame frame, KeyPress key);

Parameters

NameTypeDescription
frameModalFrame
keyKeyPress

HandleMouse(ModalFrame, MouseEvent)

public override void HandleMouse(ModalFrame frame, MouseEvent mouse);

Parameters

NameTypeDescription
frameModalFrame
mouseMouseEvent

MaximumOf(ColorChannel)

public static int MaximumOf(ColorChannel channel);

Upper end of a slider, since hue counts degrees and the others count percent.

Parameters

NameTypeDescription
channelColorChannelThe slider to ask about.

Returns int — The largest value it accepts.

MoveChannel(int)

public void MoveChannel(int delta);

Moves between the sliders, stopping at the first and the last.

Parameters

NameTypeDescription
deltaintHow far to move; negative goes up.

MoveToMaximum()

public void MoveToMaximum();

Jumps the active slider to its right end.

MoveToMinimum()

public void MoveToMinimum();

Jumps the active slider to its left end.

SetChannelFromFraction(ColorChannel, decimal)

public void SetChannelFromFraction(ColorChannel channel, decimal fraction);

Places a slider's handle at a position along its track.

Parameters

NameTypeDescription
channelColorChannelThe slider to move.
fractiondecimalPosition from 0 at the left end to 1 at the right; anything outside is pulled in.

SetValue(Rgb)

public void SetValue(Rgb color);

Loads a color into the three sliders, which is how an existing value is edited.

Parameters

NameTypeDescription
colorRgbThe color to start from.

ValueOf(ColorChannel)

public int ValueOf(ColorChannel channel);

Value of a slider, for drawing all three at once.

Parameters

NameTypeDescription
channelColorChannelThe slider to read.

Returns int — Its current value.