Background
While at Heptone, I needed a motion graphic for the hero section of the company homepage. Drawing it in code instead of dropping in a video file keeps it light. It stays crisp at any resolution and can be varied by changing parameters. These two studies were how I built that sense.
First Experiment — A Hand-Plotted Star
I started with the most primitive approach. I computed the ten vertices of a star by hand and drew the outline as a path. Then I sent five dots around that path.
The motion needs no JavaScript at all; SMIL's animateMotion handles it. Give each dot the same path and offset its begin by 1.4 seconds, and the five dots orbit in formation at even intervals.
<circle r="7" fill="#000000">
<animateMotion dur="7s" repeatCount="indefinite" rotate="auto" begin="1.4s">
<mpath href="#starPath"/>
</animateMotion>
</circle>mpathreferences the shape's ownpath, so the path doubles as the animation track. The outline and the trajectory can never drift apart- For the stagger, divide
durby the number of dots (7s ÷ 5 = 1.4s) and multiply by the index for even spacing
But hand-plotted coordinates meant that moving a single vertex required editing the path and ten circles together. That friction is why I started the next experiment.
Second Experiment — A Heptagon Drawn by Code
A seven-sided figure, to match the name Heptone. This time, instead of plotting coordinates by hand, JavaScript computes the vertices from a radius and an angle and generates every element.
const points = [];
const R = 360;
for (let i = 0; i < 7; i++) {
const angle = (2 * Math.PI / 7) * i - Math.PI / 2;
points.push([R * Math.cos(angle), R * Math.sin(angle)]);
}Once the geometry lived in code, things that were unthinkable by hand became a few lines each.
- Connect every 2nd or every 3rd vertex and you get a star-shaped path, a heptagram.
(i * 3) % 7does it in one line - A double loop lays down all 21 diagonals between the 7 vertices as faint guide lines, forming a complete graph
- Stack five circles on the same path, offset
beginby 0.015s each while fadingopacityfrom 0.5 to 0.1, and you get a comet-tail trail - A single filter merging
feGaussianBlurwith the source adds a glow for the neon look - One more heptagonal path, slightly larger than the outline, carries the repeating "HEPTONE •" text on a
textPath
// Skipping every 3rd vertex draws a 7/3 heptagram
for (let i = 0; i < 8; i++) {
const [x, y] = points[(i * 3) % 7];
innerPathData += `${x},${y} `;
}What I Learned
Key point
The real difference between the two experiments was who owns the coordinates. In the star, the markup owned them, so every change was manual labor. In the heptagon, the code owned them, so parameters like R or the number of sides became design tools. For hero motion graphics, work that demands constant variation and tuning, geometry should be generated in code from the start.
In both experiments the motion itself was animateMotion's job. Declarative animation asks only for a path, a duration, and a stagger, with no frame math. That simplicity freed the time to think about what geometry to build rather than how to move it.