@@ -11,9 +11,7 @@ const themeConfig = computed(
|
|||||||
() => STRIP_THEME_MAP[props.theme] || STRIP_THEME_MAP[DEFAULT_STRIP_THEME_ID],
|
() => STRIP_THEME_MAP[props.theme] || STRIP_THEME_MAP[DEFAULT_STRIP_THEME_ID],
|
||||||
)
|
)
|
||||||
const borderColor = computed(() => themeConfig.value?.borderColor || '#ffffff')
|
const borderColor = computed(() => themeConfig.value?.borderColor || '#ffffff')
|
||||||
const stripShadow = computed(
|
const stripShadow = computed(() => themeConfig.value?.shadow || '0 24px 60px rgba(0, 0, 0, 0.18)')
|
||||||
() => themeConfig.value?.shadow || '0 24px 60px rgba(0, 0, 0, 0.18)',
|
|
||||||
)
|
|
||||||
|
|
||||||
const stripSize = computed(() => themeConfig.value.size)
|
const stripSize = computed(() => themeConfig.value.size)
|
||||||
const frames = computed(() => themeConfig.value.slots || [])
|
const frames = computed(() => themeConfig.value.slots || [])
|
||||||
@@ -52,28 +50,82 @@ function clipStyle(rect) {
|
|||||||
>
|
>
|
||||||
<template v-if="photos[index]">
|
<template v-if="photos[index]">
|
||||||
<template v-if="rect.radius || rect.clipPath">
|
<template v-if="rect.radius || rect.clipPath">
|
||||||
<svg :width="Math.max(rect.width - 16, 0)" :height="Math.max(rect.height - 16, 0)" :viewBox="`0 0 ${Math.max(rect.width - 16, 0)} ${Math.max(rect.height - 16, 0)}`" preserveAspectRatio="none" xmlns="http://www.w3.org/2000/svg">
|
<svg
|
||||||
|
:width="Math.max(rect.width - 16, 0)"
|
||||||
|
:height="Math.max(rect.height - 16, 0)"
|
||||||
|
:viewBox="`0 0 ${Math.max(rect.width - 16, 0)} ${Math.max(rect.height - 16, 0)}`"
|
||||||
|
preserveAspectRatio="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
>
|
||||||
<defs>
|
<defs>
|
||||||
<clipPath :id="`clip-${props.theme}-${index}`">
|
<clipPath :id="`clip-${props.theme}-${index}`">
|
||||||
<template v-if="rect.clipPath">
|
<template v-if="rect.clipPath">
|
||||||
<path :d="rect.clipPath" />
|
<path :d="rect.clipPath" />
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<rect x="0" y="0" :width="Math.max(rect.width - 16, 0)" :height="Math.max(rect.height - 16, 0)" :rx="rect.radius" :ry="rect.radius" />
|
<rect
|
||||||
|
x="0"
|
||||||
|
y="0"
|
||||||
|
:width="Math.max(rect.width - 16, 0)"
|
||||||
|
:height="Math.max(rect.height - 16, 0)"
|
||||||
|
:rx="rect.radius"
|
||||||
|
:ry="rect.radius"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
</clipPath>
|
</clipPath>
|
||||||
</defs>
|
</defs>
|
||||||
<image :href="(photos[index].preview !== undefined) ? (photos[index].preview || photos[index].src) : ((photos[index].src !== undefined) ? photos[index].src : photos[index])" x="0" y="0" :width="Math.max(rect.width - 16, 0)" :height="Math.max(rect.height - 16, 0)" :clip-path="`url(#clip-${props.theme}-${index})`" preserveAspectRatio="xMidYMid slice" />
|
<image
|
||||||
|
:href="
|
||||||
|
photos[index].preview !== undefined
|
||||||
|
? photos[index].preview || photos[index].src
|
||||||
|
: photos[index].src !== undefined
|
||||||
|
? photos[index].src
|
||||||
|
: photos[index]
|
||||||
|
"
|
||||||
|
x="0"
|
||||||
|
y="0"
|
||||||
|
:width="Math.max(rect.width - 16, 0)"
|
||||||
|
:height="Math.max(rect.height - 16, 0)"
|
||||||
|
:clip-path="`url(#clip-${props.theme}-${index})`"
|
||||||
|
preserveAspectRatio="xMidYMid slice"
|
||||||
|
/>
|
||||||
<template v-if="rect.clipPath">
|
<template v-if="rect.clipPath">
|
||||||
<path :d="rect.clipPath" fill="none" :stroke="borderColor" stroke-width="12" stroke-linejoin="round" />
|
<path
|
||||||
|
:d="rect.clipPath"
|
||||||
|
fill="none"
|
||||||
|
:stroke="borderColor"
|
||||||
|
stroke-width="12"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<rect x="6" y="6" :width="Math.max(rect.width - 28, 0)" :height="Math.max(rect.height - 28, 0)" :rx="Math.max((rect.radius || 0) - 2, 0)" :ry="Math.max((rect.radius || 0) - 2, 0)" fill="none" :stroke="borderColor" stroke-width="10" />
|
<rect
|
||||||
|
x="6"
|
||||||
|
y="6"
|
||||||
|
:width="Math.max(rect.width - 28, 0)"
|
||||||
|
:height="Math.max(rect.height - 28, 0)"
|
||||||
|
:rx="Math.max((rect.radius || 0) - 2, 0)"
|
||||||
|
:ry="Math.max((rect.radius || 0) - 2, 0)"
|
||||||
|
fill="none"
|
||||||
|
:stroke="borderColor"
|
||||||
|
stroke-width="10"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
</svg>
|
</svg>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<img :src="(photos[index].preview !== undefined) ? (photos[index].preview || photos[index].src) : ((photos[index].src !== undefined) ? photos[index].src : photos[index])" :alt="`Captured photo ${index + 1}`" class="frame-photo" :style="clipStyle(rect)" />
|
<img
|
||||||
|
:src="
|
||||||
|
photos[index].preview !== undefined
|
||||||
|
? photos[index].preview || photos[index].src
|
||||||
|
: photos[index].src !== undefined
|
||||||
|
? photos[index].src
|
||||||
|
: photos[index]
|
||||||
|
"
|
||||||
|
:alt="`Captured photo ${index + 1}`"
|
||||||
|
class="frame-photo"
|
||||||
|
:style="clipStyle(rect)"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+25
-3
@@ -44,7 +44,12 @@ function handleApply(payload) {
|
|||||||
// payload: { dataUrl, transform }
|
// payload: { dataUrl, transform }
|
||||||
const { dataUrl, transform } = payload
|
const { dataUrl, transform } = payload
|
||||||
if (editorIndex.value >= 0) {
|
if (editorIndex.value >= 0) {
|
||||||
const original = (store.photos[editorIndex.value] && (store.photos[editorIndex.value].src || store.photos[editorIndex.value])) || (previewPhotos.value[editorIndex.value] && (previewPhotos.value[editorIndex.value].src || previewPhotos.value[editorIndex.value])) || null
|
const original =
|
||||||
|
(store.photos[editorIndex.value] &&
|
||||||
|
(store.photos[editorIndex.value].src || store.photos[editorIndex.value])) ||
|
||||||
|
(previewPhotos.value[editorIndex.value] &&
|
||||||
|
(previewPhotos.value[editorIndex.value].src || previewPhotos.value[editorIndex.value])) ||
|
||||||
|
null
|
||||||
const obj = { src: original, preview: dataUrl, transform }
|
const obj = { src: original, preview: dataUrl, transform }
|
||||||
previewPhotos.value[editorIndex.value] = obj
|
previewPhotos.value[editorIndex.value] = obj
|
||||||
// persist to store as well
|
// persist to store as well
|
||||||
@@ -84,7 +89,19 @@ function handleApply(payload) {
|
|||||||
<ThemeSelector />
|
<ThemeSelector />
|
||||||
<RouterLink class="primary" to="/result">Generate strip</RouterLink>
|
<RouterLink class="primary" to="/result">Generate strip</RouterLink>
|
||||||
</section>
|
</section>
|
||||||
<ImageEditor v-if="editorIndex >= 0" :src="(store.photos[editorIndex] && (store.photos[editorIndex].src || store.photos[editorIndex])) || previewPhotos[editorIndex]" :initialTransform="(store.photos[editorIndex] && store.photos[editorIndex].transform) || null" :outputWidth="440" :outputHeight="290" @cancel="handleCancel" @apply="handleApply" />
|
<ImageEditor
|
||||||
|
v-if="editorIndex >= 0"
|
||||||
|
:src="
|
||||||
|
(store.photos[editorIndex] &&
|
||||||
|
(store.photos[editorIndex].src || store.photos[editorIndex])) ||
|
||||||
|
previewPhotos[editorIndex]
|
||||||
|
"
|
||||||
|
:initialTransform="(store.photos[editorIndex] && store.photos[editorIndex].transform) || null"
|
||||||
|
:outputWidth="440"
|
||||||
|
:outputHeight="290"
|
||||||
|
@cancel="handleCancel"
|
||||||
|
@apply="handleApply"
|
||||||
|
/>
|
||||||
</main>
|
</main>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -129,7 +146,12 @@ function handleApply(payload) {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 6px;
|
gap: 6px;
|
||||||
}
|
}
|
||||||
.edit-thumb img { width: 84px; height: 64px; object-fit: cover; border-radius: 8px }
|
.edit-thumb img {
|
||||||
|
width: 84px;
|
||||||
|
height: 64px;
|
||||||
|
object-fit: cover;
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
.options-panel {
|
.options-panel {
|
||||||
display: grid;
|
display: grid;
|
||||||
|
|||||||
Reference in New Issue
Block a user