aboutsummaryrefslogtreecommitdiff
path: root/src/Utils.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2023-11-17 13:04:26 -0500
committerbobzel <zzzman@gmail.com>2023-11-17 13:04:26 -0500
commit96d27379d77b77f7496a1b2c5f30824cc04370c0 (patch)
tree42a2ff40bacdeef89791d974aa1d19fc9708c9b3 /src/Utils.ts
parentf027832dd2e3267b70e94c1e60d1703ff86d7fe2 (diff)
from last
Diffstat (limited to 'src/Utils.ts')
-rw-r--r--src/Utils.ts7
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;
}