SVG Path Morphing (SMIL).
Animate an SVG path’s d attribute between two matching command sequences.
View code
<svg width="150" viewBox="0 0 200 200" role="img" aria-label="Hexagon morphing into an angular shape">
<path fill="currentColor" d="M100 20 L175 62 L175 138 L100 180 L25 138 L25 62 Z">
<animate attributeName="d" values="M100 20 L175 62 L175 138 L100 180 L25 138 L25 62 Z;M100 7 L124 76 L191 86 L136 126 L151 183 L72 151 Z;M100 20 L175 62 L175 138 L100 180 L25 138 L25 62 Z" dur="3s" repeatCount="indefinite"/>
</path>
</svg>:root { color-scheme: dark; font: 15px system-ui, sans-serif; color: #dbff55; }
* { box-sizing: border-box; }
body { margin: 0; height: 100dvh; display: grid; place-items: center; overflow: hidden; background: transparent; }
.tile { display: grid; place-items: center; width: 68px; aspect-ratio: 1; border-radius: 18px; background: currentColor; }
.tile { background: #dbff55; color: #202415; font-size: 30px; }
canvas { display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; }
button { font: inherit; color: #f3f1e9; background: #191919; border: 1px solid #ffffff66; padding: 8px 14px; border-radius: 24px; cursor: pointer; }
:focus-visible { outline: 2px solid #dbff55; outline-offset: -3px; }
.notice { max-width: 34ch; padding: 16px; color: #fff; }
@media (prefers-reduced-motion: reduce) { .sprite { animation-play-state: paused; } }// Matching path commands let SVG interpolate the coordinates.
if (matchMedia('(prefers-reduced-motion: reduce)').matches) {
document.querySelector('svg').pauseAnimations();
}