0.4.0: clipart drawer, animation paths, bezier keyframes

- Clipart library: new left-edge drawer (5px idle, expands on hover,
  400px when open). User picks a local folder via the File System Access
  API in settings; directory handle is persisted in IndexedDB so the
  library survives reloads. Dragging a thumbnail onto the stage creates
  an image asset + layer at the drop point.
- Animation paths on the stage: selecting a keyframe draws the tween
  path from the previous keyframe to the selected one as a solid
  polyline with per-frame draggable dots. All other segments on the
  same position-track render as dashed ghost lines so the full curve
  progression is visible.
- Path dots grow on hover (2.5 → 6 px), show a grab cursor, and have a
  wider hit area so they're easier to grab.
- Bezier-curved position interpolation: keyframes gain optional
  ctrlX/ctrlY fields. When set, x/y tween along a quadratic bezier
  through the control point instead of a straight line. Dragging a
  path dot solves for the control so the curve passes through the
  drag point at its frame progress. Mirrored across all four render
  pipelines.
- Tests: new suites for polygon actions, freeform drawing lifecycle,
  polygon + stroke rendering (15 new tests). Fixed the mask-render
  tests that relied on a default-transparent canvas background.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
thandClaude Opus 4.7 committed 2026-04-20 10:35:43 +02:00
1 parent 276d621d20
commit 869b67458a
16 files changed
+1379 -15

No files matched your search

+304
View File
@@ -0,0 +1,304 @@
<script setup lang="ts">
import { onBeforeUnmount, onMounted } from 'vue'
import { PhArrowClockwise, PhCaretLeft, PhCaretRight, PhImagesSquare } from '@phosphor-icons/vue'
import { useClipartStore } from '@/stores/clipart'
import { t } from '@/i18n'
const clipart = useClipartStore()
onMounted(() => {
clipart.initialize()
})
onBeforeUnmount(() => {
clipart.disposeItems()
})
function onItemDragStart(e: DragEvent, index: number) {
if (!e.dataTransfer) return
const item = clipart.items[index]
if (!item) return
e.dataTransfer.effectAllowed = 'copy'
e.dataTransfer.setData('application/x-animatr-clipart', String(index))
e.dataTransfer.setData('text/plain', item.name)
// Use the actual image as drag ghost
const ghost = document.createElement('img')
ghost.src = item.url
ghost.style.position = 'absolute'
ghost.style.top = '-1000px'
ghost.style.left = '-1000px'
ghost.style.width = '96px'
ghost.style.height = '96px'
ghost.style.objectFit = 'contain'
document.body.appendChild(ghost)
try {
e.dataTransfer.setDragImage(ghost, 48, 48)
} catch {
/* ignore */
}
setTimeout(() => ghost.remove(), 0)
}
</script>
<template>
<aside class="clipart-drawer" :class="{ open: clipart.open }">
<button
class="drawer-tab"
:title="clipart.open ? t('clipart.close') : t('clipart.open')"
@click="clipart.toggle()"
>
<component :is="clipart.open ? PhCaretLeft : PhCaretRight" :size="14" />
</button>
<div v-if="clipart.open" class="drawer-panel">
<header class="drawer-header">
<PhImagesSquare :size="14" class="title-icon" />
<h3>{{ t('clipart.title') }}</h3>
<button
v-if="clipart.handle"
class="refresh-btn"
:title="t('clipart.refresh')"
:disabled="clipart.loading"
@click="clipart.refresh()"
>
<PhArrowClockwise :size="13" />
</button>
</header>
<div v-if="clipart.folderName" class="folder-row">
<span class="folder-name">{{ clipart.folderName }}</span>
<span class="count">{{ clipart.items.length }}</span>
</div>
<p v-if="!clipart.supported" class="empty-state">
{{ t('clipart.unsupported') }}
</p>
<p v-else-if="!clipart.handle" class="empty-state">
{{ t('clipart.empty') }}
</p>
<p v-else-if="clipart.error" class="error-state">{{ clipart.error }}</p>
<p v-else-if="clipart.loading" class="empty-state">{{ t('clipart.loading') }}</p>
<p v-else-if="clipart.items.length === 0" class="empty-state">
{{ t('clipart.noFiles') }}
</p>
<div v-else class="tile-grid">
<div
v-for="(item, i) in clipart.items"
:key="item.name + i"
class="tile"
:title="item.name"
draggable="true"
@dragstart="onItemDragStart($event, i)"
>
<img :src="item.url" :alt="item.name" />
<span class="tile-label">{{ item.name }}</span>
</div>
</div>
</div>
</aside>
</template>
<style scoped>
.clipart-drawer {
display: flex;
align-items: stretch;
flex-shrink: 0;
height: 100%;
width: 5px;
transition: width 220ms var(--ease);
background: var(--border);
border-right: 1px solid var(--border);
position: relative;
}
.clipart-drawer:hover {
width: 24px;
background: var(--panel);
}
.clipart-drawer.open {
width: 424px;
background: var(--panel);
}
.drawer-tab {
flex: 0 0 100%;
width: 100%;
min-width: 0;
padding: 0;
border: none;
background: transparent;
color: var(--text-dim);
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
writing-mode: vertical-rl;
overflow: hidden;
transition: background 140ms var(--ease);
}
.drawer-tab :deep(svg) {
opacity: 0;
transition: opacity 140ms var(--ease);
}
.clipart-drawer:hover .drawer-tab :deep(svg),
.clipart-drawer.open .drawer-tab :deep(svg) {
opacity: 1;
}
.clipart-drawer:hover .drawer-tab {
background: var(--panel-alt);
color: var(--text);
}
.clipart-drawer.open .drawer-tab {
flex: 0 0 24px;
width: 24px;
background: var(--panel);
}
.drawer-panel {
flex: 1;
min-width: 0;
width: 400px;
display: flex;
flex-direction: column;
border-left: 1px solid var(--border);
overflow: hidden;
}
.drawer-header {
display: flex;
align-items: center;
gap: 8px;
padding: 10px 12px;
border-bottom: 1px solid var(--border);
}
.title-icon {
color: var(--text-dim);
flex-shrink: 0;
}
.drawer-header h3 {
flex: 1;
margin: 0;
font-size: 13px;
font-weight: 600;
}
.refresh-btn {
width: 24px;
height: 24px;
padding: 0;
border: 1px solid var(--border);
background: transparent;
border-radius: var(--radius-sm);
color: var(--text-dim);
display: inline-flex;
align-items: center;
justify-content: center;
cursor: pointer;
}
.refresh-btn:hover:not(:disabled) {
color: var(--text);
background: var(--panel-alt);
}
.refresh-btn:disabled {
opacity: 0.5;
cursor: wait;
}
.folder-row {
display: flex;
align-items: center;
gap: 8px;
padding: 6px 12px;
font-size: 11px;
color: var(--text-dim);
border-bottom: 1px solid var(--border);
background: var(--panel-alt);
}
.folder-name {
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-variant-numeric: tabular-nums;
}
.count {
font-variant-numeric: tabular-nums;
padding: 1px 6px;
border-radius: 999px;
background: var(--border);
color: var(--text-dim-strong);
font-size: 10px;
}
.empty-state {
margin: 0;
padding: 16px 14px;
color: var(--text-dim);
font-size: 12px;
font-style: italic;
}
.error-state {
margin: 0;
padding: 16px 14px;
color: var(--danger);
font-size: 12px;
}
.tile-grid {
flex: 1;
overflow-y: auto;
padding: 10px;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
gap: 8px;
align-content: start;
}
.tile {
display: flex;
flex-direction: column;
align-items: center;
gap: 4px;
padding: 6px;
border: 1px solid var(--border);
border-radius: var(--radius-sm);
background: var(--bg);
cursor: grab;
transition: border-color 140ms var(--ease), background 140ms var(--ease);
}
.tile:hover {
border-color: var(--accent);
background: var(--panel-alt);
}
.tile:active {
cursor: grabbing;
}
.tile img {
width: 72px;
height: 72px;
object-fit: contain;
pointer-events: none;
user-select: none;
}
.tile-label {
font-size: 10px;
color: var(--text-dim);
max-width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
</style>