generated from erangel1/generic-template
initial commit. phase 1 complete
This commit is contained in:
+24
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
RGB to HWB converter
|
||||
--------------------
|
||||
|
||||
References:
|
||||
* https://drafts.csswg.org/css-color/#hwb-to-rgb
|
||||
* https://en.wikipedia.org/wiki/HWB_color_model
|
||||
* http://alvyray.com/Papers/CG/HWB_JGTv208.pdf
|
||||
*/
|
||||
|
||||
import convertRgbToHsv from '../hsv/convertRgbToHsv.js';
|
||||
|
||||
export default function convertRgbToHwb(rgba) {
|
||||
let hsv = convertRgbToHsv(rgba);
|
||||
if (hsv === undefined) return undefined;
|
||||
let res = {
|
||||
mode: 'hwb',
|
||||
w: (1 - hsv.s) * hsv.v,
|
||||
b: 1 - hsv.v
|
||||
};
|
||||
if (hsv.h !== undefined) res.h = hsv.h;
|
||||
if (hsv.alpha !== undefined) res.alpha = hsv.alpha;
|
||||
return res;
|
||||
}
|
||||
Reference in New Issue
Block a user