Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should we really have LCH coords directly on Color instances? #147

Closed
LeaVerou opened this issue Jun 19, 2022 · 3 comments
Closed

Should we really have LCH coords directly on Color instances? #147

LeaVerou opened this issue Jun 19, 2022 · 3 comments

Comments

@LeaVerou
Copy link
Member

Right now color.lightness, color.chroma and color.hue are shortcuts to color.lch.lightness, color.lch.chroma, and color.lch.hue. After #144 these will become color.l, color.c, color.h being shortcuts for color.lch.l etc. As I'm working on #144 and #112, I wonder: should we really have these shortcuts? We are moving away from LCH being the gold standard for these kinds of manipulations (OKLCH is now considered better). Once we release Color.js, we will never be able to change the color space of these, especially not to something as incompatible as OKLCH (which has completely different ranges).

So perhaps we should not have these at all?

@svgeesus
Copy link
Member

Well we can change them, as can regular users, because

Object.assign(Color, {
	deltaE,
	util,
	hooks,
	WHITES,
	Space: ColorSpace,
	spaces: ColorSpace.registry,

	// These will be available as getters and setters on EVERY color instance.
	// They refer to LCH by default, but can be set to anything
	// and you can add more by calling Color.defineShortcut()
	shortcuts: {
		"l": "lch.l",
		"c": "lch.c",
		"h": "lch.h",
	},

	// Global defaults one may want to configure
	defaults: {
		gamutMapping: "lch.c",
		precision: 5,
		deltaE: "76", // Default deltaE method
		fallbackSpaces: ["p3", "srgb"]
	}
});

but yes, it is arguable whether we should have those default shortcuts at all.

@svgeesus
Copy link
Member

Also (as we just discussed irl) these sort of customizable defaults make for hard to maintain, hard to share code.

@LeaVerou
Copy link
Member Author

Ok, RESOLVED then. Man, it will feel good to get rid of all this code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants