How to use the @csstools/convert-colors.rgb2hue function in @csstools/convert-colors

To help you get started, we’ve selected a few @csstools/convert-colors examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jonathantneal / postcss-color-mod-function / lib / color.js View on Github external
channel => {
			// detect channel
			const isHue = channel === 'hue';
			const isRGB = !isHue && blueGreenRedMatch.test(channel);

			// normalized value of the channel
			const value = normalize(channels[channel], channel);

			// assign channel to new object
			color[channel] = value;

			if (isRGB) {
				// conditionally preserve the hue
				color.hue = rgb2hue(color.red, color.green, color.blue, base.hue || 0);
			}
		}
	);
github jonathantneal / postcss-color-mod-function / lib / color.js View on Github external
constructor(color) {
		this.color = Object(Object(color).color || color);

		this.color.colorspace = this.color.colorspace
			? this.color.colorspace
		: 'red' in color && 'green' in color && 'blue' in color
			? 'rgb'
		: 'hue' in color && 'saturation' in color && 'lightness' in color
			? 'hsl'
		: 'hue' in color && 'whiteness' in color && 'blackness' in color
			? 'hwb'
		: 'unknown';

		if (color.colorspace === 'rgb') {
			this.color.hue = rgb2hue(color.red, color.green, color.blue, color.hue || 0);
		}
	}