diff options
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; } |