aboutsummaryrefslogtreecommitdiff
path: root/src/Utils.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2021-09-24 09:10:57 -0400
committerbobzel <zzzman@gmail.com>2021-09-24 09:10:57 -0400
commit851647c8d399dc6e5d036ac11cbce4e8dd8c2eb9 (patch)
tree6aadfb3e43882bcf1e7532c2f57eeb4be33b28ea /src/Utils.ts
parenta4b3114f3792c80e20a3f40053ec4724729c1100 (diff)
parent643df77e6366b7164307ffe195ed9de83b68e5ae (diff)
Merge branch 'master' into temporalmedia-mehek
Diffstat (limited to 'src/Utils.ts')
-rw-r--r--src/Utils.ts11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/Utils.ts b/src/Utils.ts
index e11f1154e..7ec4f69f3 100644
--- a/src/Utils.ts
+++ b/src/Utils.ts
@@ -573,10 +573,19 @@ export function simulateMouseClick(element: Element | null | undefined, x: numbe
}
}
+export function DashColor(color: string) {
+ try {
+ return Color(color.toLowerCase());
+ } catch (e) {
+ console.log("COLOR error:", e);
+ return Color("red");
+ }
+}
+
export function lightOrDark(color: any) {
const nonAlphaColor = color.startsWith("#") ? (color as string).substring(0, 7) :
color.startsWith("rgba") ? color.replace(/,.[^,]*\)/, ")").replace("rgba", "rgb") : color;
- const col = Color(nonAlphaColor).rgb();
+ 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;
else return Colors.WHITE;