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
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
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 like this
Build an Animated Beating Heart Diagram With Blood Flow in One HTML File
A ready-to-paste prompt that builds an animated heart cross-section with color-coded blood flow, opening and closing valves, a heart rate slider and a soft synthesized lub-dub.
Build an Animated SVG World Clock with Sweeping Hands and Five Time Zones
A single HTML file with a crisp SVG analog clock whose hands glide continuously and ease smoothly between five world cities, each with a labeled UTC offset.
Build an Animated Water Cycle Diagram for a Science Lesson in HTML
A single HTML page with an animated SVG water cycle that labels evaporation, condensation, precipitation and collection, with step-through buttons and narration notes for teachers.
Build a CSS Cubic-Bezier Easing Curve Visualizer with Draggable Handles
A single HTML file with a draggable bezier curve editor that races test boxes against CSS built-in easings and gives you a ready-to-paste cubic-bezier value.
Build an Animated Number Counter and Progress Ring Stats Dashboard in HTML
You get a single HTML stats section where numbers ease up to their targets and SVG progress rings fill on scroll, with an editor panel and screen-reader announcements.
Build an Animated SVG Wave and Liquid Fill Background Generator
A single HTML file that generates layered, seamlessly looping SVG waves with live controls and exports ready-to-use animated SVG and CSS code.