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
| Member | Summary |
|---|---|
ColorModal() |
Properties
| Member | Summary |
|---|---|
Channel | Which of the three sliders the arrows move. |
ChannelMaximum | Upper end of the slider the arrows move. |
ChannelRows | Where each slider's row was drawn last frame, used to turn a click into a channel. |
ChannelTracks | Where each slider's track was drawn last frame, used to turn a click into a value. |
ChannelValue | Value of the slider the arrows move. |
Hue | Position on the color wheel, from 0 to 359. It wraps rather than stopping. |
LargeStep | How far the page keys move the active slider. |
Lightness | Distance from black toward white, in percent. Fifty is the pure color. |
OnPicked | Called with the color that was confirmed. |
Saturation | Distance from gray, in percent. |
Step | How far the arrow keys move the active slider. |
Value | The three sliders resolved into a color, as drawn in the swatch. |
Methods
| Member | Summary |
|---|---|
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()
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
| Name | Type | Description |
|---|---|---|
delta | int | How far to move; negative goes left. |
Draw(ModalFrame)
public override void Draw(ModalFrame frame);
Parameters
| Name | Type | Description |
|---|---|---|
frame | ModalFrame |
Handle(ModalFrame, KeyPress)
public override void Handle(ModalFrame frame, KeyPress key);
Parameters
| Name | Type | Description |
|---|---|---|
frame | ModalFrame | |
key | KeyPress |
HandleMouse(ModalFrame, MouseEvent)
public override void HandleMouse(ModalFrame frame, MouseEvent mouse);
Parameters
| Name | Type | Description |
|---|---|---|
frame | ModalFrame | |
mouse | MouseEvent |
MaximumOf(ColorChannel)
public static int MaximumOf(ColorChannel channel);
Upper end of a slider, since hue counts degrees and the others count percent.
Parameters
| Name | Type | Description |
|---|---|---|
channel | ColorChannel | The 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
| Name | Type | Description |
|---|---|---|
delta | int | How 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
| Name | Type | Description |
|---|---|---|
channel | ColorChannel | The slider to move. |
fraction | decimal | Position 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
| Name | Type | Description |
|---|---|---|
color | Rgb | The color to start from. |
ValueOf(ColorChannel)
public int ValueOf(ColorChannel channel);
Value of a slider, for drawing all three at once.
Parameters
| Name | Type | Description |
|---|---|---|
channel | ColorChannel | The slider to read. |
Returns int — Its current value.