diff options
author | bobzel <zzzman@gmail.com> | 2023-11-17 13:04:26 -0500 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2023-11-17 13:04:26 -0500 |
commit | 96d27379d77b77f7496a1b2c5f30824cc04370c0 (patch) | |
tree | 42a2ff40bacdeef89791d974aa1d19fc9708c9b3 /src/Utils.ts | |
parent | f027832dd2e3267b70e94c1e60d1703ff86d7fe2 (diff) |
from last
Diffstat (limited to 'src/Utils.ts')
-rw-r--r-- | src/Utils.ts | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/Utils.ts b/src/Utils.ts index 9499aaf2f..4e4414a93 100644 --- a/src/Utils.ts +++ b/src/Utils.ts @@ -754,12 +754,9 @@ export function DashColor(color: string) { } export function lightOrDark(color: any) { - if (color === 'transparent' || !color) return Colors.DARK_GRAY; + if (color === 'transparent' || !color) return Colors.BLACK; if (color.startsWith?.('linear')) return Colors.BLACK; - const nonAlphaColor = color.startsWith('#') ? (color as string).substring(0, 7) : color.startsWith('rgba') ? color.replace(/,.[^,]*\)/, ')').replace('rgba', 'rgb') : color; - const col = DashColor(nonAlphaColor).rgb(); - const colsum = col.red() + col.green() + col.blue(); - if (colsum / col.alpha() > 400 || col.alpha() < 0.25) return Colors.DARK_GRAY; + if (DashColor(color).isLight()) return Colors.BLACK; return Colors.WHITE; } |