devtools::load_all()

https://github.com/cwickham/munsell/issues/10

mnsl2hex("5PB 5/10") # OK
mnsl2hex("5PB 5/10", fix = TRUE) # Error unused argument

Which functions should check gamut, and which shouldn't?

Functions in alter.R

Generally these functions shouldn't check for in gamut colors, since then you can chain through out of gamut colors into colors that are in the gamut, e.g. this color is in gamut

plot_mnsl("5R 6/12")

A color one darker isn't in the gamut:

plot_mnsl(lighter("5R 6/12"))

But a color one lighter and one less saturated is:

plot_mnsl(desaturate(lighter("5R 6/12")))

Why doesn't this generate a warning? It just returns NA.

mnsl(lighter("5R 6/12"))

These do not currently and shouldn't check for gamut (they do however call mnsl2hvc() which checks for format, but not in_gamut():

plot_mnsl("2.5G 8/12")
plot_mnsl(rygbp("2.5G 8/12"))

seq_mnsl() checks endpoints are in gamut, then calls rgb2mnsl() which doesn't explicilty check colors are in gamut, but by construction will only return colors in gamut.

Functions in convert.R

Calls check_mnsl():

Functions in check.R

check_mnsl() - checks for format validity, hadnles NAs, doesn't currently fix colors.

in_gmaut() - checks if color is inside gamut, i.e. representable. Handles NAs warns if some colors are outside gamut, passes fix onto fix_mnsl()

fix_mnsl() takes out of gamut colors and moves them in gamut.

Functions in plot.R

plot_mnsl() starts with:

cols <- check_mnsl(cols)
cols <- in_gamut(cols, ...)

and does nothing with explicit missing values (does it matter that it passes them on?).

Important points

Decide where NA handling should occur (before check_cols()?), before in_gamut(), make sure it's done consistently.

Any function that checks gamut, should allow fixing of colors.

Action Items



cwickham/munsell documentation built on April 7, 2024, 7:04 p.m.