Documentation
¶
Overview ¶
Package colorpicker is the magnifier-loupe color picker (crates/lys-shell/src/shell/color_picker): a frozen-frame layer surface per monitor with a zoom loupe that follows the pointer - the magnified pixels around it, a crosshair on the exact pixel a click picks, and the color's readout in the chosen format, which Tab cycles - and a strip of recently picked swatches, a click on one picking it again. A click samples that pixel; Escape cancels. The screenshot host captures the frames and hands them over (it owns the capture path), and the portal's Screenshot.PickColor and `lys-shell colorpicker` reach it over dev.stubbe.lys.Screenshot1.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HistoryPath ¶
func HistoryPath() string
HistoryPath is the persisted swatch file: $XDG_DATA_HOME/lys-shell/color-history, else ~/.local/share/lys-shell/color-history. Empty when neither is an absolute path.
Types ¶
type Options ¶ added in v0.3.15
type Options struct {
// Format is the readout's first format; empty starts in the one the
// last pick used, else the configured one.
Format config.ColorFormat
// NoLoupe shows a crosshair pointer over the frozen screen instead of
// the magnifier.
NoLoupe bool
}
Options shape one pick.
type Pick ¶ added in v0.3.15
type Pick struct {
Color RGB
Format config.ColorFormat
}
Pick is a picked color and the format the readout showed at the click.
type Picker ¶
type Picker struct {
// contains filtered or unexported fields
}
Picker is the picker component. Request is its entry point; the rest runs on the lys-ui loop goroutine.
func New ¶
func New(a *app.Application, gate *regionoverlay.Gate, outputs func() []*app.Output, font render.Font, historyPath string, configured func() config.ColorFormat) *Picker
New builds the picker. gate is the shell's one capture gate; font is the readout's monospace bold face; the history loads from historyPath (HistoryPath for the real one); configured reads colorpicker.format.
func (*Picker) Request ¶
func (p *Picker) Request(ctx context.Context, frames regionoverlay.Frames, opts Options) (Pick, bool, error)
Request opens the picker over the frozen frames (keyed by connector), which frames captures once the gate admits the request, and blocks until a click picks a pixel or a recent swatch (ok), or the user cancels or ctx ends (not ok, no error). A monitor without a frame gets no surface; when no frame matches any monitor there is nothing to pick from, and that is an error naming both, not a cancel. While another session holds the gate the request opens nothing, takes no frames and answers regionoverlay.ErrBusy. Call it from any goroutine but the loop's.
type RGB ¶
type RGB struct{ R, G, B uint8 }
RGB is one 8-bit color.
func (RGB) CMYK ¶ added in v0.3.15
CMYK is the color's naive cyan, magenta, yellow and key in [0, 1].
func (RGB) Format ¶ added in v0.3.15
func (c RGB) Format(f config.ColorFormat) string
Format writes the color in f.
func (RGB) HSL ¶ added in v0.3.15
HSL is the color's hue in degrees [0, 360) and its HSL saturation and lightness in [0, 1].