Create active channel tree map component
This commit is contained in:
@@ -91,3 +91,25 @@ export function detectWebGL() {
|
||||
return (gl && gl instanceof WebGLRenderingContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* https://gist.githubusercontent.com/rosszurowski/67f04465c424a9bc0dae/raw/90ee06c5aa84ab352eb5b233d0a8263c3d8708e5/lerp-color.js
|
||||
* A linear interpolator for hexadecimal colors
|
||||
* @param {String} a
|
||||
* @param {String} b
|
||||
* @param {Number} amount
|
||||
* @example
|
||||
* // returns #7F7F7F
|
||||
* lerpColor('#000000', '#ffffff', 0.5)
|
||||
* @returns {String}
|
||||
*/
|
||||
export function lerpColor(a: string, b: string, amount: number): string {
|
||||
const ah = parseInt(a.replace(/#/g, ''), 16),
|
||||
ar = ah >> 16, ag = ah >> 8 & 0xff, ab = ah & 0xff,
|
||||
bh = parseInt(b.replace(/#/g, ''), 16),
|
||||
br = bh >> 16, bg = bh >> 8 & 0xff, bb = bh & 0xff,
|
||||
rr = ar + amount * (br - ar),
|
||||
rg = ag + amount * (bg - ag),
|
||||
rb = ab + amount * (bb - ab);
|
||||
|
||||
return '#' + ((1 << 24) + (rr << 16) + (rg << 8) + rb | 0).toString(16).slice(1);
|
||||
}
|
||||
Reference in New Issue
Block a user