on-codemerge
Version:
A WYSIWYG editor for on-codemerge is a user-friendly interface that allows users to edit and view their code in real time, exactly as it will appear in the final product
42 lines (41 loc) • 772 B
JavaScript
const s = [
"#3b82f6",
// Blue
"#ef4444",
// Red
"#10b981",
// Green
"#f59e0b",
// Yellow
"#6366f1",
// Indigo
"#ec4899",
// Pink
"#8b5cf6",
// Purple
"#14b8a6",
// Teal
"#f97316",
// Orange
"#06b6d4"
// Cyan
];
function f() {
return s[Math.floor(Math.random() * s.length)];
}
function i(t, e) {
if (t || (t = f()), t.startsWith("#")) {
const n = parseInt(t.slice(1, 3), 16), r = parseInt(t.slice(3, 5), 16), a = parseInt(t.slice(5, 7), 16);
return `rgba(${n}, ${r}, ${a}, ${e})`;
}
if (t.startsWith("rgb")) {
const n = t.match(/\d+/g);
return !n || n.length < 3 ? t : `rgba(${n[0]}, ${n[1]}, ${n[2]}, ${e})`;
}
return t;
}
export {
s as CHART_COLORS,
i as colorWithOpacity,
f as getRandomColor
};