colorpicker

package
v0.3.25 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 22 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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.

func (Pick) Text added in v0.3.15

func (p Pick) Text() string

Text is the color written in the format shown.

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

func (c RGB) CMYK() (cy, m, y, k float64)

CMYK is the color's naive cyan, magenta, yellow and key in [0, 1].

func (RGB) Float

func (c RGB) Float() (r, g, b float64)

Float is the color as sRGB channels in [0, 1], the PickColor reply.

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

func (c RGB) HSL() (h, s, l float64)

HSL is the color's hue in degrees [0, 360) and its HSL saturation and lightness in [0, 1].

func (RGB) HSV added in v0.3.15

func (c RGB) HSV() (h, s, v float64)

HSV is the color's hue in degrees [0, 360) and its HSV saturation and value in [0, 1].

func (RGB) Hex

func (c RGB) Hex() string

Hex is the color as #RRGGBB.

func (RGB) OKLCH added in v0.3.15

func (c RGB) OKLCH() (l, ch, h float64)

OKLCH is the color in Björn Ottosson's Oklab, as lightness in [0, 1], chroma, and hue in degrees [0, 360).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL