This commit is contained in:
2024-10-22 09:09:41 +08:00
parent ef869c5ab1
commit 3a9b2d55c6
99 changed files with 4506 additions and 3465 deletions

View File

@@ -132,7 +132,10 @@ const _sfc_main = defineComponent({
alpha.value = a;
});
watch([red, green, blue], (newValue) => {
emit("update:modelValue", rgba2hex(red.value, green.value, blue.value, alpha.value));
emit(
"update:modelValue",
rgba2hex(red.value, green.value, blue.value, alpha.value)
);
let { h, s, v } = rgb2hsv(red.value, green.value, blue.value);
hue.value = h;
saturation.value = s;
@@ -141,7 +144,10 @@ const _sfc_main = defineComponent({
hueSliderStyle.value = `left: ${hue.value / 360 * 100}%;`;
});
watch(alpha, () => {
emit("update:modelValue", rgba2hex(red.value, green.value, blue.value, alpha.value));
emit(
"update:modelValue",
rgba2hex(red.value, green.value, blue.value, alpha.value)
);
alphaSliderStyle.value = `left: ${alpha.value >= 1 ? "calc(100% - 6px)" : alpha.value * 100 + "%"};`;
});
let colorObj = computed(() => {
@@ -278,7 +284,9 @@ const _sfc_main = defineComponent({
if (color) {
let r, g, b, a;
if (typeof color === "string") {
if (/^#?([0-9a-fA-F]{6}|[0-9a-fA-F]{8}|[0-9a-fA-F]{3}|[0-9a-fA-F]{4})$/.test(color)) {
if (/^#?([0-9a-fA-F]{6}|[0-9a-fA-F]{8}|[0-9a-fA-F]{3}|[0-9a-fA-F]{4})$/.test(
color
)) {
return hex2rgba(color);
}
} else {