|
|
@@ -1,14 +1,14 @@
|
|
|
<template>
|
|
|
<el-dialog draggable append-to-body v-model="show" title="背景颜色" width="440px">
|
|
|
+ <div class="flex flex-col items-center">
|
|
|
+ <el-segmented v-if="useType === 'both'" v-model="type" :options="typeOptions" />
|
|
|
+ <div v-if="type !== 'pure'" class="w-full flex flex-col items-center mt-16px">
|
|
|
+ <h4 class="m-0 mb-12px">预览</h4>
|
|
|
+ <div class="w-full h-60px rounded-4px mb-10px" :style="previewGradient"></div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
<el-scrollbar height="400px">
|
|
|
<div class="w-full flex flex-col items-center">
|
|
|
- <el-segmented v-if="useType === 'both'" v-model="type" :options="typeOptions" />
|
|
|
-
|
|
|
- <div v-if="type !== 'pure'" class="w-full flex flex-col items-center">
|
|
|
- <h4 class="m-0">预览</h4>
|
|
|
- <div class="w-80% h-60px rounded-4px mb-10px" :style="previewGradient"></div>
|
|
|
- </div>
|
|
|
-
|
|
|
<!-- 纯色 -->
|
|
|
<div v-if="type === 'pure'" class="mt-20px">
|
|
|
<ColorPicker
|
|
|
@@ -161,6 +161,28 @@
|
|
|
</input-number>
|
|
|
</div>
|
|
|
</el-form-item>
|
|
|
+ <el-form-item label="椭圆范围">
|
|
|
+ <div class="w-full flex items-center gap-8px">
|
|
|
+ <input-number
|
|
|
+ v-model="focalExtentX"
|
|
|
+ :min="0"
|
|
|
+ :max="width"
|
|
|
+ size="small"
|
|
|
+ style="flex: 1"
|
|
|
+ >
|
|
|
+ <template #prefix>X</template>
|
|
|
+ </input-number>
|
|
|
+ <input-number
|
|
|
+ v-model="focalExtentY"
|
|
|
+ :min="0"
|
|
|
+ :max="height"
|
|
|
+ size="small"
|
|
|
+ style="flex: 1"
|
|
|
+ >
|
|
|
+ <template #prefix>Y</template>
|
|
|
+ </input-number>
|
|
|
+ </div>
|
|
|
+ </el-form-item>
|
|
|
</template>
|
|
|
|
|
|
<!-- 锥形渐变:中心点 + 角度 -->
|
|
|
@@ -366,6 +388,7 @@ watch(
|
|
|
)
|
|
|
|
|
|
watch(type, (val) => {
|
|
|
+ ensureGradient()
|
|
|
if (!internalGradient.value) return
|
|
|
internalGradient.value.gradientType = val === 'gradient' ? 'gradient' : 'advanced'
|
|
|
// 保留前2个渐变点
|
|
|
@@ -589,6 +612,33 @@ const centerY = computed({
|
|
|
}
|
|
|
})
|
|
|
|
|
|
+// 径向渐变:结束点
|
|
|
+const focalExtentX = computed({
|
|
|
+ get() {
|
|
|
+ ensureGradient()
|
|
|
+ return internalGradient.value?.focal_extent?.x ?? 50
|
|
|
+ },
|
|
|
+ set(val: number) {
|
|
|
+ ensureGradient()
|
|
|
+ if (!internalGradient.value) return
|
|
|
+ if (!internalGradient.value.focal_extent) internalGradient.value.focal_extent = { x: 50, y: 50 }
|
|
|
+ internalGradient.value.focal_extent.x = Math.max(0, val)
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+const focalExtentY = computed({
|
|
|
+ get() {
|
|
|
+ ensureGradient()
|
|
|
+ return internalGradient.value?.focal_extent?.y ?? 50
|
|
|
+ },
|
|
|
+ set(val: number) {
|
|
|
+ ensureGradient()
|
|
|
+ if (!internalGradient.value) return
|
|
|
+ if (!internalGradient.value.focal_extent) internalGradient.value.focal_extent = { x: 50, y: 50 }
|
|
|
+ internalGradient.value.focal_extent.y = Math.max(0, val)
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
// 锥形渐变:角度 0~3600
|
|
|
const coneStartAngle = computed({
|
|
|
get() {
|
|
|
@@ -666,6 +716,7 @@ const removePoint = (index: number) => {
|
|
|
internalGradient.value.points.splice(index, 1)
|
|
|
}
|
|
|
|
|
|
+// 高级渐变类型切换
|
|
|
const onChangeAdvancedType = (val) => {
|
|
|
ensureGradient()
|
|
|
if (!internalGradient.value) return
|
|
|
@@ -676,8 +727,12 @@ const onChangeAdvancedType = (val) => {
|
|
|
}
|
|
|
} else {
|
|
|
internalGradient.value.center = {
|
|
|
- x: (props.width || 100) / 2,
|
|
|
- y: (props.height || 100) / 2
|
|
|
+ x: Math.round((props.width || 100) / 2),
|
|
|
+ y: Math.round((props.height || 100) / 2)
|
|
|
+ }
|
|
|
+ internalGradient.value.focal_extent = {
|
|
|
+ x: Math.round((props.width || 100) / 2),
|
|
|
+ y: Math.round((props.height || 100) / 2)
|
|
|
}
|
|
|
}
|
|
|
}
|