animot-presenter 0.6.4 → 0.6.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,6 +20,7 @@
20
20
  import EmbedPlayer from './EmbedPlayer.svelte';
21
21
  import { easeInOutCubic, getEasingFn, getBackgroundStyle, gradientShapeToCss, hashFraction, getFloatAnimName, getIdleAnimName, computeFloatAmp, computeFloatSpeed, entranceRuntimeKeyframe, exitRuntimeKeyframe, emphasisKeyframeName } from './engine/utils';
22
22
  import { drawElementToPath } from './utils/freehand';
23
+ import { freehandDrawReveal } from './utils/freehand-draw-reveal';
23
24
  import { makePathInterpolator, makeMorphParts, fitPathToBox, resolveElementPath, resolveElementPathParts, shapeToPath, extractCombinedPath, extractFill, type PathInterpolator, type MorphPart } from './utils/path-morph';
24
25
  import type {
25
26
  AnimotProject, AnimotPresenterProps, CanvasElement, CodeElement, TextElement,
@@ -2150,13 +2151,13 @@
2150
2151
  {@const arrowHeadPath = `M ${arrowEl.endPoint.x - headSize * Math.cos(endAngle - headAngle)} ${arrowEl.endPoint.y - headSize * Math.sin(endAngle - headAngle)} L ${arrowEl.endPoint.x} ${arrowEl.endPoint.y} L ${arrowEl.endPoint.x - headSize * Math.cos(endAngle + headAngle)} ${arrowEl.endPoint.y - headSize * Math.sin(endAngle + headAngle)}`}
2151
2152
  {@const arrowAnimMode = arrowEl.animation?.mode ?? 'none'}
2152
2153
  {@const arrowAnimDuration = arrowEl.animation?.duration ?? 500}
2153
- {@const isStyledArrow = arrowEl.style !== 'solid'}
2154
2154
  {@const isDrawType = arrowAnimMode === 'draw' || arrowAnimMode === 'undraw' || arrowAnimMode === 'draw-undraw' || arrowAnimMode === 'flow'}
2155
2155
  {@const baseDashArray = arrowEl.style === 'dashed' ? '10,5' : arrowEl.style === 'dotted' ? '2,5' : 'none'}
2156
2156
  <svg class="animot-arrow-element" class:arrow-animate-grow={arrowAnimMode === 'grow'} viewBox="0 0 {arrowEl.size.width} {arrowEl.size.height}" preserveAspectRatio="none" style="--arrow-anim-duration: {arrowAnimDuration}ms;" use:arrowClipDraw={{ enabled: isDrawType, mode: arrowAnimMode, duration: arrowAnimDuration, startX: arrowEl.startPoint.x, startY: arrowEl.startPoint.y, endX: arrowEl.endPoint.x, endY: arrowEl.endPoint.y, loop: !!arrowEl.animation?.loop, reverse: arrowEl.animation?.direction === 'reverse', slideDuration: currentSlide?.duration, key: `arrow-${currentSlideIndex}` }}>
2157
2157
  <path class="arrow-path" d={pathD} fill="none" stroke={arrowEl.color} stroke-width={arrowEl.strokeWidth} stroke-dasharray={baseDashArray} stroke-linecap="round" stroke-linejoin="round" />
2158
2158
  {#if arrowEl.showHead !== false}
2159
- <path class="arrow-head" class:arrow-head-styled-draw={isDrawType && isStyledArrow} class:arrow-head-undraw={arrowAnimMode === 'undraw'} class:arrow-head-draw-undraw={arrowAnimMode === 'draw-undraw'} d={arrowHeadPath} fill="none" stroke={arrowEl.color} stroke-width={arrowEl.strokeWidth} stroke-linecap="round" stroke-linejoin="round" style={isDrawType && isStyledArrow ? `--arrow-anim-duration: ${arrowAnimDuration}ms;` : ''} />
2159
+ <!-- Head opacity during draw/undraw is driven by arrowClipDraw (JS), in step with the path-length reveal. -->
2160
+ <path class="arrow-head" d={arrowHeadPath} fill="none" stroke={arrowEl.color} stroke-width={arrowEl.strokeWidth} stroke-linecap="round" stroke-linejoin="round" />
2160
2161
  {/if}
2161
2162
  {#if arrowEl.flowMarkers?.enabled}
2162
2163
  <FlowMarkers config={arrowEl.flowMarkers} start={arrowEl.startPoint} end={arrowEl.endPoint} controlPoints={cp} slideDuration={currentSlide?.duration} />
@@ -2274,11 +2275,19 @@
2274
2275
  {@const morphProg = dkpm ? kpmProg : pmProg}
2275
2276
  {@const drawMorph = dkpm ?? ((dpm && pmProg > 0 && pmProg < 1) ? dpm : restingKfMorph(element))}
2276
2277
  {@const drawPath = drawElementToPath(drawEl)}
2278
+ {@const drawMode = drawEl.animation?.mode ?? 'none'}
2279
+ {@const drawReveal = !drawMorph && (drawMode === 'draw' || drawMode === 'undraw' || drawMode === 'draw-undraw')}
2277
2280
  <svg class="animot-draw-element" width="100%" height="100%" viewBox={drawMorph?.viewBox ?? drawPath.viewBox} preserveAspectRatio="none" style="display:block;overflow:visible;" xmlns="http://www.w3.org/2000/svg">
2278
2281
  {#if drawMorph}
2279
2282
  {#each (drawMorph.parts ?? [{ interp: drawMorph.interp, fromColor: drawMorph.fromColor, toColor: drawMorph.toColor }]) as part}
2280
2283
  <path d={part.interp(Math.max(0, Math.min(1, morphProg)))} fill={(element as any).morphColor ?? part.toColor} fill-rule="evenodd" />
2281
2284
  {/each}
2285
+ {:else if drawReveal}
2286
+ <!-- freehandDrawReveal owns `d` (rebuilds the partial outline each frame). -->
2287
+ <path
2288
+ fill={drawEl.color}
2289
+ use:freehandDrawReveal={{ enabled: true, mode: drawMode, duration: drawEl.animation?.duration ?? 800, el: drawEl, loop: !!drawEl.animation?.loop, reverse: drawEl.animation?.direction === 'reverse', slideDuration: currentSlide?.duration, key: `draw-${currentSlideIndex}-${drawMode}-${drawEl.animation?.duration}-${drawEl.animation?.loop}-${drawEl.animation?.direction}` }}
2290
+ />
2282
2291
  {:else}
2283
2292
  <path d={drawPath.d} fill={drawEl.color} />
2284
2293
  {/if}