mirror of
https://github.com/penpot/penpot-plugins.git
synced 2025-01-07 15:39:49 -05:00
fix: get luminosity
This commit is contained in:
parent
c9b21e47ab
commit
d2382e0c0f
1 changed files with 5 additions and 5 deletions
|
@ -19,11 +19,11 @@ export class AppElement extends HTMLElement {
|
||||||
|
|
||||||
getLuminosity(color: string) {
|
getLuminosity(color: string) {
|
||||||
const rgb = this.hexToRgb(color);
|
const rgb = this.hexToRgb(color);
|
||||||
return (
|
const a = rgb.map((v) => {
|
||||||
0.2126 * (rgb[0] / 255) +
|
v /= 255;
|
||||||
0.7152 * (rgb[1] / 255) +
|
return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);
|
||||||
0.0722 * (rgb[2] / 255)
|
});
|
||||||
);
|
return 0.2126 * a[0] + 0.7152 * a[1] + 0.0722 * a[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
hexToRgb(hex: string) {
|
hexToRgb(hex: string) {
|
||||||
|
|
Loading…
Reference in a new issue