How guillermolg00/morphicons works
morphicons is a zero-dependency icon-morphing library. An application changes an icon-data prop, supplies a controlled progress value, or calls an imperative handle; a framework binding initializes SVG output and delegates animation to the shared DOM driver. The core parses and normalizes paths, resamples them, computes correspondence and alignment, interpolates with spring timing, then serializes frames. It also offers vanilla/custom-element and canvas, mask, and SVG adapter capabilities. README documents Astro SSR; its implementation is not identified in the sampled tree. Edges are limited to relationships shown by excerpts, SOURCE INDEX references, or README; unsampled adapter and binding details are not inferred.
Main entry points: index.ts DOM animation driver · controller.ts Morph controller · normalize.ts Path normalization · resample.ts Arc-length sampling
Components 21
Framework bindings
- React binding
src/react/index.tsx - Vue binding
src/vue/index.ts - Svelte binding
src/svelte/MorphIcon.svelte - Svelte driver glue
src/svelte/shared.ts - React Native binding
src/react-native/index.tsx - Custom element
src/element/index.ts - Vanilla API
src/dom/controller.ts - Astro SSR shell
src
Morph engine
- Morph controller
src/dom/controller.ts - DOM animation driver
src/dom/index.ts - Path parser
src/core/parse.ts - Path normalization
src/core/normalize.ts - Arc-length sampling
src/core/resample.ts - Match and align
src/core/plan.ts - Polar interpolation
src/core/interpolate.ts - Spring timing
src/core/spring.ts - Path serialization
src/core/serialize.ts
Rendering adapters
- Canvas adapter
src/adapters/canvas.ts - Mask adapter
src/adapters/mask.ts - SVG adapter
src/adapters/svg.ts
Other components
- Application
Connections 27
- Application → React binding: sets icon
- Application → Vue binding: sets icon
- Application → Svelte binding: sets icon
- Application → React Native binding: sets icon
- React binding → DOM animation driver: creates morph
src/react/index.tsx - Vue binding → DOM animation driver: uses driver
src/vue/index.ts - Svelte binding → Svelte driver glue: uses shared logic
src/svelte/MorphIcon.svelte - Svelte driver glue → Morph controller: uses controller
src/svelte/shared.ts - React Native binding → DOM animation driver: creates morph
src/react-native/index.tsx - Custom element → Morph controller: uses controller
src/element/index.ts - Vanilla API → DOM animation driver: uses driver
src/dom/controller.ts - Morph controller → DOM animation driver: creates morph
src/dom/controller.ts - DOM animation driver → Path normalization: normalizes icon
src/dom/index.ts - Path normalization → Path parser: parses path
src/core/normalize.ts - DOM animation driver → Arc-length sampling: samples shapes
src/dom/index.ts - Arc-length sampling → Path normalization: converts to cubics
src/core/resample.ts - DOM animation driver → Match and align: builds plan
src/dom/index.ts - DOM animation driver → Polar interpolation: interpolates frames
src/dom/index.ts - DOM animation driver → Spring timing: advances progress
src/dom/index.ts - DOM animation driver → Path serialization: serializes frames
src/dom/index.ts - Morph controller → Match and align: builds frozen output
src/dom/controller.ts - Morph controller → Polar interpolation: interpolates frozen output
src/dom/controller.ts - Morph controller → Arc-length sampling: samples endpoints
src/dom/controller.ts - Morph controller → Path serialization: serializes output
src/dom/controller.ts - Canvas adapter → DOM animation driver: uses driver
src/adapters/canvas.ts - Mask adapter → DOM animation driver: uses driver
src/adapters/mask.ts - SVG adapter → Path normalization: normalizes paths
src/adapters/svg.ts