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.

You getone complete HTML file in a single code block, then 3 short ideas to extend it.

The prompt

Prompt
Act as a front-end developer and medical science illustrator. Build "Pulse Chambers", an animated cross-section of the human heart that shows how blood moves through it. Draw the heart in inline SVG with four labeled chambers, the vena cavae, pulmonary artery, pulmonary veins and aorta, plus four valves (tricuspid, mitral, pulmonary, aortic) that visibly open and close. Small arrow chevrons stream along the vessels and through the chambers: blue for oxygen-poor blood, red for oxygen-rich blood.

Rules:
1. Loop a cardiac cycle of atrial systole, ventricular systole and diastole. The atria and ventricles squeeze in turn, and a phase panel names the current phase with one plain-language sentence and a moving progress bar.
2. A heart rate slider from 40 to 180 bpm, with presets for asleep, resting, jogging and sprinting, changes the speed and updates beat length, litres pumped per minute and a short description of the rate.
3. Controls: Play/Pause and Next phase buttons, Space and arrow keys, and click, tap or Enter on a chamber to explain what it does.
4. Synthesize a soft lub-dub with the Web Audio API. Create the AudioContext on the first interaction, keep the volume low and show a visible mute toggle.
5. Use a dark navy page with red, blue and yellow accents and a two-column layout that stacks below 760px. With prefers-reduced-motion, start paused and shrink the squeeze.
6. No external files, libraries, storage or alerts.

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: Pulse Chambers, an animated heart cross-section that beats on its own.

Blue chevrons carry oxygen-poor blood from the vena cavae to the lungs, and red ones carry oxygen-rich blood out through the aorta. The yellow valves snap open and shut with each phase. Drag the heart rate slider or try the presets, press Next phase to step through the cycle, and click any chamber to read what it does. Turn the sound on to hear the lub-dub.

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

Tips and common edits

Why this works

  • Inline SVG with fixed coordinates keeps the anatomy crisp at any width, and particles follow hidden paths using getPointAtLength.
  • One cycle value drives the chamber squeeze, valve angles, sounds and the phase text, so everything stays in sync.
  • Exact colors, controls and accessibility rules leave the model nothing to guess, so the first output runs.

Paste into ChatGPT, Claude or Gemini. Save the code as pulse-chambers.html and open it in any browser, or run it in the chat's preview or canvas. It runs fully offline.

Common edits

  • Change the theme to a light classroom style, or swap red and blue for a colorblind-safe orange and teal.
  • Add a lungs panel where blue chevrons turn red as they pass the air sacs, or add an ECG trace synced to the phases.

Prompt details

By
Prompts-GPT editors
Published

Did this prompt work?

Keep exploring

More in Animations & Effects