Build a Self-Drawing SVG Lighthouse Line Animation in One HTML File

You get a single HTML page where a hand-built SVG lighthouse draws itself stroke by stroke with staggered timing, then fades in its colors, with replay and speed controls.

The prompt

Prompt
Act as a senior front-end developer and illustrator who animates SVG by hand.

Build a single-page piece called Harbor Light: an inline SVG lighthouse scene that draws itself like an ink sketch and then washes in color. The scene is built from about 30 simple shapes: a rounded sky frame, a sun, two clouds, birds, two light beams, a cliff with a grass cap, a keeper's cottage, a red and white striped tower, a gallery with railing, a glowing lantern room, a roof with a finial, a small rock and a wavy sea with foam lines.

Rules:
1. Measure every shape with getTotalLength, set stroke-dasharray, and animate stroke-dashoffset in JavaScript with eased timing. Each shape starts 0.14 seconds after the previous one, and its duration scales with its length.
2. After the last stroke finishes, fade in each shape's fill with a short stagger. Once complete, the beams pulse gently.
3. Controls: Replay, Pause or Play, and speed buttons for 0.5x, 1x and 2x. Add a progress bar and a status line that reads Drawing stroke N of M. Keys: Space pauses, R replays, 1 to 3 set speed. Clicking the art replays it once finished.
4. Palette: warm paper background, navy ink, brick red, sea blue and lamp yellow. Use a clear type scale and generous spacing, and the layout must fit 360 to 1280px wide.
5. With prefers-reduced-motion, show the finished drawing on load and stop the pulse.

Output format: one complete HTML file in a single code block, then 3 short ideas to extend it.

Example output

One HTML file. Save it and open it in any browser.Open full screen

Example: Harbor Light, a lighthouse sketch that inks itself and then fills with color.

On load, navy strokes trace the frame, sun, clouds, beams, cliff, cottage and striped tower one after another. Brick red, sea blue and lamp yellow then wash in, and the beams start to pulse. Press Space to pause, R to replay and 1–3 to change speed, or use the buttons. Try 0.5× to watch each dash offset unwind.

Written by AI from this prompt. Your results will vary.

Tips and common edits

Why this works

  • Measuring each shape with getTotalLength means dash lengths are always exact, so every stroke draws fully with no gaps or jumps.
  • A single JavaScript timeline drives strokes and fills together, which makes pause, replay and speed changes reliable.
  • Fills only start after all strokes finish, so the sketch-then-paint reveal reads clearly and looks polished.

Paste the prompt into ChatGPT, Claude or Gemini. Save the returned code as harbor-light.html and open it in any browser, or run it in the chat's preview or canvas panel.

Common edits

  • Swap the lighthouse for another scene, such as a windmill or a cabin: keep the class on each shape and give it its own fill color.
  • Change the stagger and length divisor to make the drawing faster or slower, or add a soft pen-scratch sound with Web Audio noise.

Prompt details

By
Prompts-GPT editors
Published

Did this prompt work?

Keep exploring

More in Animations & Effects