Water tool · project 02 of 19

Follow the water.

How a treatment plant really works, one step at a time.

Open the project ↗Get the skill and the code
Follow the water, screenshot

How to use it

  1. Choose the source: river intake or groundwater wells.
  2. Press Next to move through the plant one process at a time. Each animation plays once and holds.
  3. Use Replay to watch a step again, Back to return, and Reset to start over from the intake.
  4. On a phone, switch between Current step and Full process.

Where it helps most

  • Plant tours, public meetings and school visits, when people ask "what happens to the water?"
  • Onboarding new staff who need the treatment order before the details.
  • A pattern for any step-by-step walkthrough of a process: a factory line, a permit, a recipe.

The idea

I wanted a way to show anyone how a drinking-water plant really works: both source routes, river intake and groundwater wells, through every stage in the right engineering order, drawn as equipment connected by pipes rather than boxes full of words.

The build

Claude drew the equipment schematics, wrote the step-by-step walkthrough with Back, Next, Replay and Reset, built separate phone and desktop layouts, added tests for the treatment order, and deployed it on sghadimi.com.

Free to take

Build your own.

Copy the skill, paste it into your own AI, and say what you want different. How to use a skill, step by step ›

Get the skillThe instructions your AI follows. Works in Claude, ChatGPT, Gemini or any other

You are a front-end engineer and a water-treatment process engineer. Build an interactive, single-page walkthrough of a drinking-water treatment plant that a non-engineer can follow.

Requirements:
1. Two selectable sources: river intake with screens, and groundwater wells. Groundwater may bypass surface-water steps and join at blending.
2. Stages in this order: intake, pretreatment/pre-oxidation, rapid mix/coagulation, flocculation, sedimentation, ozone contact, filtration, pumping/blending, final chemical addition, chlorine contact, delivery. Ask me to confirm or edit the list for my plant before you start.
3. An overall process flow diagram drawn as SVG equipment symbols joined by pipes and arrows, with short captions. Highlight the current stage.
4. A detail panel per stage: what happens, what comes out. Each stage animation plays once (about 12 s) and holds. Visitors move with Back / Next; Pause/Play/Replay and Reset (back to the intake).
5. Phone layout with 'Current step' and 'Full process' tabs, large touch targets and bottom controls clear of the safe area. Respect prefers-reduced-motion by starting with still art.
6. Plain HTML, CSS and JavaScript, no libraries, no external requests, keyboard accessible.

Deliver one self-contained HTML file. Then list how you checked the stage order, the source switch and the phone layout.
Get the code3 files, exactly as they run on this site
process-flow.js90 lines

Raw file

/* Overall PFD plus a passive, source-aware treatment walkthrough. */
(() => {
  'use strict';
  const stages=[
    {id:'intake',name:'Intake and raw-water pumping',short:'Intake',river:'River water enters an intake. A screen intercepts larger debris, and raw-water pumps convey it to pretreatment.',groundwater:'Wells lift groundwater from the aquifer. Influent pumping brings it to the treatment plant.',result:'Raw water reaches the treatment train.'},
    {id:'pretreat',name:'Pretreatment / pre-oxidation',short:'Pretreat',river:'Pre-oxidation conditions river water before coagulation. Chemical choice and application depend on source-water quality.',groundwater:'Sodium hypochlorite oxidizes arsenite As(III) to arsenate As(V), preparing it for removal.',result:'Water chemistry is conditioned before coagulation.'},
    {id:'rapid',name:'Rapid mix / coagulation',short:'Rapid mix',description:'Ferric chloride is rapidly mixed with the water to prepare fine particles for aggregation and separation.',result:'Coagulant is dispersed through the water.'},
    {id:'floc',name:'Flocculation',short:'Flocculation',description:'Gentle mixing and anionic polymer help small particles gather into larger floc.',result:'Larger floc forms for settling.'},
    {id:'settle',name:'Sedimentation',short:'Sedimentation',description:'Floc settles below the clarified water. Water leaves from the upper outlet; sludge goes to thickening and drying beds.',result:'Most settleable solids leave the main water stream.'},
    {id:'ozone',name:'Ozone contact',short:'Ozone contact',illustrative:true,description:'Ozone contacts the settled water before GAC filtration. This contactor is a retained conceptual addition.',result:'Ozone contact occurs before the filter.'},
    {id:'filter',name:'GAC filtration',short:'GAC filtration',description:'GAC traps floc carried over from sedimentation. Nonionic polymer is added before filtration; effluent flows to the pump station.',result:'Filtered water is collected for pumping.'},
    {id:'blend',name:'Pumping and blending',short:'Blending',river:'Filtered water is pumped to the finished-water system. Blending requires compatible water; the groundwater bypass applies only to the groundwater route.',groundwater:'Pumped filter effluent blends with groundwater bypass to meet the finished-water arsenic target.',result:'The combined stream proceeds to final treatment.'},
    {id:'final',name:'Final chemical addition',short:'Final treatment',description:'Sodium hypochlorite is added for final disinfection. Phosphate is added for corrosion control in the distribution system.',result:'Final chlorine addition precedes chlorine contact.'},
    {id:'contact',name:'Chlorine contact',short:'Chlorine contact',illustrative:true,description:'After final chlorination, water follows the contact channel before delivery. This basin is a retained conceptual addition.',result:'Chlorine contact is downstream of final chlorination.'},
    {id:'tap',name:'Pumping and delivery',short:'Delivery',river:'Finished water is conveyed through the planned finished-water pumping and distribution system to customers.',groundwater:'Finished water leaves for Canutillo Booster Station and onward through the distribution system to customers.',result:'Water reaches the distribution system.'}
  ];
  const positions={pretreat:[260,140],rapid:[420,140],floc:[580,140],settle:[740,140],ozone:[900,140],filter:[900,350],blend:[740,350],final:[580,350],contact:[420,350],tap:[260,350]};
  const esc=t=>String(t).replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/"/g,'&quot;');
  const txt=(label,x,y,size=15,color='#bdd2d7')=>'<text x="'+x+'" y="'+y+'" text-anchor="middle" fill="'+color+'" font-family="Arial,sans-serif" font-size="'+size+'">'+esc(label)+'</text>';
  // Uploaded vessel artwork plus equipment-specific vector symbols. Text is a caption, not the process block.
  function equipment(id,source,x,y,w=126,h=88){
    let body='';
    const assets={rapid:'./equipment/mixing-tank.png',floc:'./equipment/floc-tank.png',filter:'./equipment/media-filter.png'};
    const tank='<path d="M22 38L82 9L143 42V77L83 106L22 73Z" fill="#bad4cf"/><path d="M22 38L83 70L143 42M83 70V106" fill="none"/><path d="M22 38L82 9L143 42L83 70Z" fill="#dcece7"/>';
    const dose='<path d="M9 34V15H38V37L24 44Z" fill="#d8c99b"/><path d="M17 15V8H29V15M38 23H54V42" fill="none"/>';
    if(assets[id])body='<image href="'+assets[id]+'" x="8" y="2" width="144" height="106" preserveAspectRatio="xMidYMid meet"/>';
    else if(id==='intake'&&source==='river')body='<path d="M2 75Q18 62 35 75T68 75T102 75T154 75V100H2Z" fill="#89bdc5" stroke="none"/><path d="M3 69Q19 57 35 69T68 69T102 69T154 69" fill="none" stroke="#5f9ca7"/><path d="M60 29L99 10L135 29V68L99 87L60 68Z" fill="#d2d5bf"/><path d="M60 29L99 48L135 29M99 48V87" fill="none"/><path d="M65 43L94 57M65 52L94 66M65 61L94 75" stroke="#547c7e"/><path d="M133 49H150V70" fill="none" stroke="#527a82" stroke-width="7"/>';
    else if(id==='intake')body='<path d="M14 57L81 29L147 58V89L80 113L14 86Z" fill="#d3ccaf" stroke="none"/><path d="M14 78L80 103L147 79V95L80 119L14 94Z" fill="#7ab1bc" stroke="none"/><path d="M73 99V22L92 13H124V32" fill="none" stroke="#476d78" stroke-width="9"/><path d="M73 99V22L92 13H124V32" fill="none" stroke="#d6e6e1" stroke-width="3"/><path d="M68 69H78M68 77H78M68 85H78M68 93H78" stroke="#f4f8ec"/>';
    else if(id==='pretreat'||id==='final')body=tank+dose+'<path d="M59 44L83 56L123 37M83 56V86" fill="none" stroke="#629aa4"/>'+(id==='final'?'<path d="M126 17L141 10L153 17V39L139 46L126 39Z" fill="#c4bcce"/><path d="M137 15V5H145V12M126 31H112V45" fill="none"/>':'');
    else if(id==='settle')body='<path d="M8 46L86 8L153 41V75L75 111L8 78Z" fill="#b5ccc6"/><path d="M8 46L75 80L153 41L86 8Z" fill="#d7e8e1"/><path d="M8 46L75 80V111M75 80L153 41" fill="none"/><path d="M17 67L75 97L144 65L144 76L75 108L17 79Z" fill="#b8a27a" stroke="none"/><path d="M37 49L71 66L123 41M51 40L85 57L137 32" fill="none" stroke="#779e9a"/><path d="M75 108V119" fill="none" stroke-width="5"/>';
    else if(id==='ozone')body=tank+'<path d="M38 67L82 90L128 68M82 90V78" fill="none" stroke="#678f97" stroke-width="3"/>'+[[45,59],[59,58],[74,70],[86,54],[100,68],[119,53],[63,43],[105,42]].map(([a,b])=>'<circle cx="'+a+'" cy="'+b+'" r="3" fill="#e8f4ef" stroke="#629eab"/>').join('')+'<path d="M9 74V41H23" fill="none" stroke-width="4"/>';
    else if(id==='contact')body=tank+'<path d="M39 39L83 61L124 42M46 51L82 69L119 51M47 64L82 82L119 64" fill="none" stroke="#5e8f91" stroke-width="5"/>';
    else if(id==='blend')body='<path d="M20 49L80 20L141 50V77L81 106L20 76Z" fill="#b8d2cb"/><path d="M20 49L81 80L141 50L80 20Z" fill="#dbe9e0"/><path d="M81 80V106" fill="none"/><path d="M7 22H43V46M151 21H119V46M82 95V117" fill="none" stroke="#6f9faa" stroke-width="7"/><path d="M51 50L81 66L111 51" fill="none" stroke="#6f9faa"/>';
    else if(id==='tap')body='<path d="M13 47L47 29L80 47V87L47 104L13 87Z" fill="#d6d3bd"/><path d="M7 45L46 15L87 43L47 64Z" fill="#8da99b"/><path d="M47 64V104M27 65V80L38 85V70M58 76L69 70V85L58 91" fill="none"/><path d="M101 56V94M136 51V88M101 94H136M103 58L135 87M135 53L103 91" fill="none" stroke-width="3"/><path d="M96 20Q119 4 142 20V52Q119 67 96 52Z" fill="#aacbd0"/><ellipse cx="119" cy="20" rx="23" ry="9" fill="#dbe8df"/><path d="M80 88H103" fill="none" stroke="#6f9faa" stroke-width="5"/>';
    return '<svg class="pfd-equipment" x="'+(x-w/2)+'" y="'+(y-h/2)+'" width="'+w+'" height="'+h+'" viewBox="0 0 160 122" aria-hidden="true"><g stroke="#34484a" stroke-width="1.8" stroke-linejoin="round" stroke-linecap="round">'+body+'</g></svg>';
  }
  const captions={river:['River intake'],groundwater:['Groundwater wells'],pretreat:['Pre-oxidation'],rapid:['Rapid mix'],floc:['Flocculation'],settle:['Sedimentation'],ozone:['Ozone contact*'],filter:['GAC filter'],blend:['Pumping & blending'],final:['Final chemicals'],contact:['Chlorine contact*'],tap:['Delivery']};
  function schematicNode(id,x,y,number,selected,source,sourceId,mobile){
    const current=id==='intake'?selected==='intake'&&sourceId===source:selected===id,label=captions[sourceId||id];
    return '<g data-stage="'+id+'"'+(sourceId?' data-source="'+sourceId+'"':'')+' class="pfd-node'+(current?' is-current':'')+'" role="button" tabindex="0" aria-label="View '+esc(label.join(' '))+'"'+(current?' aria-current="step"':'')+'><rect class="pfd-hit-area" x="'+(x-72)+'" y="'+(y-49)+'" width="144" height="107" rx="14" fill="transparent" stroke="none"/><ellipse class="pfd-equipment-halo" cx="'+x+'" cy="'+y+'" rx="68" ry="43" fill="'+(current?'#f0dfae':'#e2ebe3')+'" fill-opacity="'+(current?'.9':'.38')+'" stroke="'+(current?'#af8844':'none')+'" stroke-width="1.5"/>'+equipment(id,sourceId||source,x,y,mobile?132:126,mobile?86:82)+txt(number,x-(sourceId?40:58),y-36,mobile?10:9,current?'#87621e':'#637d78')+label.map((t,i)=>txt(t,x,y+(mobile?54:53)+i*16,mobile?14:14,current?'#71521d':'#2e5357')).join('')+'</g>';
  }
  function map(index,source){
    const selected=stages[index].id,parts=[];
    parts.push('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1040 470" role="group" aria-label="Equipment schematic: river intake or groundwater wells, pre-oxidation, rapid mix, flocculation, sedimentation, ozone contact, GAC filtration, pumping and blending, final chemicals, chlorine contact and delivery."><defs><marker id="pfd-arrow" viewBox="0 0 10 10" refX="8" refY="5" markerWidth="6" markerHeight="6" orient="auto"><path d="M0 0L10 5L0 10Z" fill="#608c8d"/></marker></defs>');
    const pipe=(d,active=false)=>'<path d="'+d+'" class="pfd-pipe'+(active?' is-active':'')+'" fill="none" stroke="#7b9a99" stroke-width="2.5" marker-end="url(#pfd-arrow)"/>';
    parts.push(pipe('M144 80H172V140H188',source==='river'&&index<=1),pipe('M144 190H172V140H188',source==='groundwater'&&index<=1));
    for(let i=1;i<stages.length-1;i++){const a=positions[stages[i].id],b=positions[stages[i+1].id];const d=a[1]===b[1]?(a[0]<b[0]?'M'+(a[0]+70)+' '+a[1]+'H'+(b[0]-73):'M'+(a[0]-70)+' '+a[1]+'H'+(b[0]+73)):'M970 140H998V350H973';parts.push(pipe(d,selected===stages[i+1].id));}
    parts.push('<path d="M144 190H163V261H740V303" fill="none" stroke="'+(source==='groundwater'?'#8c7bb2':'#b6c3bf')+'" stroke-width="2" stroke-dasharray="6 5" marker-end="url(#pfd-arrow)"/>',txt('Groundwater bypass',450,250,12,'#796b99'));
    for(const [label,x] of [['Pre-oxidant',260],['Coagulant',420],['Polymer',580],['Ozone',900]])parts.push(txt(label,x,55,12,'#7d6a43')+'<path d="M'+x+' 63V91" stroke="#a58b56" fill="none"/>');
    parts.push(txt('Chlorine + phosphate',580,285,12,'#7d6a43')+'<path d="M580 293V305" stroke="#a58b56"/>');
    parts.push(schematicNode('intake',74,80,'SOURCE',selected,source,'river'),schematicNode('intake',74,190,'SOURCE',selected,source,'groundwater'));
    for(let i=1;i<stages.length;i++)parts.push(schematicNode(stages[i].id,...positions[stages[i].id],String(i).padStart(2,'0'),selected,source));
    parts.push(txt('→ Main water flow',120,446,12,'#527b78'),txt('* Conceptual contact stages',825,446,12,'#796b99'),'</svg>');return parts.join('');
  }
  function mapMobile(index,source){
    const selected=stages[index].id,parts=[],xy={pretreat:[90,174],rapid:[270,174],floc:[270,296],settle:[90,296],ozone:[90,418],filter:[270,418],blend:[270,540],final:[90,540],contact:[90,662],tap:[270,662]};
    parts.push('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 360 770" role="group" aria-label="Portrait equipment schematic of water treatment, from river or groundwater intake to delivery."><defs><marker id="pfd-mobile-arrow" viewBox="0 0 10 10" refX="8" refY="5" markerWidth="5" markerHeight="5" orient="auto"><path d="M0 0L10 5L0 10Z" fill="#608c8d"/></marker></defs>');
    const pipe=(d,active)=>'<path d="'+d+'" class="pfd-pipe'+(active?' is-active':'')+'" fill="none" stroke="#7b9a99" stroke-width="2.5" marker-end="url(#pfd-mobile-arrow)"/>';
    parts.push(pipe('M22 53H7V122H90V125',source==='river'&&index<=1),pipe('M202 53H178V122H90V125',source==='groundwater'&&index<=1));
    for(let i=1;i<stages.length-1;i++){const a=xy[stages[i].id],b=xy[stages[i+1].id];let d;if(a[1]===b[1])d=a[0]<b[0]?'M158 '+a[1]+'H197':'M202 '+a[1]+'H163';else d=a[0]>180?'M338 '+a[1]+'H346V'+b[1]+'H340':'M22 '+a[1]+'H14V'+b[1]+'H20';parts.push(pipe(d,selected===stages[i+1].id));}
    parts.push('<path d="M339 53H357V482H270V491" fill="none" stroke="'+(source==='groundwater'?'#8c7bb2':'#b6c3bf')+'" stroke-width="2" stroke-dasharray="5 4" marker-end="url(#pfd-mobile-arrow)"/>');
    parts.push(schematicNode('intake',90,53,'SOURCE',selected,source,'river',true),schematicNode('intake',270,53,'SOURCE',selected,source,'groundwater',true));
    for(let i=1;i<stages.length;i++)parts.push(schematicNode(stages[i].id,...xy[stages[i].id],String(i).padStart(2,'0'),selected,source,null,true));
    parts.push('<path d="M29 742H51" stroke="#8c7bb2" stroke-width="2" stroke-dasharray="5 4"/>',txt('Groundwater bypass',150,746,12,'#796b99'),txt('* Conceptual contact stages',180,766,12,'#796b99'),'</svg>');return parts.join('');
  }
  window.ProcessFlow={stages,map,mapMobile};
  window.initProcessWalkthrough=function(){
    const $=s=>document.querySelector(s),root=$('#process-walkthrough'),diagram=$('#pfd-map'),figure=$('#pfd-figure');
    const reduced=matchMedia('(prefers-reduced-motion: reduce)').matches;
    const duration=12000;
    let motionEnabled=!reduced;
    let index=0,source='river',playing=!reduced,disposed=false,raf=0,elapsed=reduced?duration:0,start=performance.now(),lastPaint=0;
    const tabs=['current','flow'];
    function setView(view){root.setAttribute('data-mobile-view',view);for(const id of tabs){const tab=$('#pfd-tab-'+id);tab.setAttribute('aria-selected',String(view===id));tab.setAttribute('tabindex',view===id?'0':'-1');}}
    for(const id of tabs)$('#pfd-tab-'+id).onclick=()=>setView(id);
    $('#pfd-mobile-tabs').onkeydown=e=>{if(!['ArrowLeft','ArrowRight','Home','End'].includes(e.key))return;e.preventDefault();const view=e.key==='Home'?'current':e.key==='End'?'flow':e.target.id==='pfd-tab-current'?'flow':'current';setView(view);$('#pfd-tab-'+view).focus();};
    function draw(){figure.innerHTML=window.ProcessArt.scene(stages[index].id,Math.min(1,elapsed/duration),elapsed/1000*.4,source);$('#pfd-stage-progress').style.width=Math.min(100,elapsed/duration*100)+'%';}
    function render(){const s=stages[index];diagram.innerHTML='<div class="pfd-map-desktop">'+map(index,source)+'</div><div class="pfd-map-mobile">'+mapMobile(index,source)+'</div>';$('#pfd-stage-count').textContent=(index+1)+' / '+stages.length;$('#pfd-stage-label').textContent=s.illustrative?'CONCEPTUAL CONTACT STAGE':'CURRENT PROCESS';const title=index===0?(source==='river'?'River intake and pumping':'Groundwater wells and pumping'):s.name;$('#pfd-stage-title').textContent=title;$('#pfd-mobile-stage-title').textContent=title;$('#pfd-mobile-stage-index').textContent='STEP '+String(index+1).padStart(2,'0')+' / '+stages.length+(s.illustrative?' · CONCEPTUAL':'');$('#pfd-description').textContent=s[source]||s.description;$('#pfd-result').textContent=s.result;$('#pfd-previous').disabled=index===0;$('#pfd-next').disabled=index===stages.length-1;$('#pfd-play').textContent=playing?'Pause':elapsed>=duration?'Replay':'Play';$('#pfd-play').setAttribute('aria-label',playing?'Pause current animation':elapsed>=duration?'Replay current process animation':'Play current process animation');$('#pfd-play').setAttribute('aria-pressed',String(playing));root.classList.toggle('is-playing',playing);for(const id of ['river','groundwater'])$('#pfd-source-'+id).setAttribute('aria-pressed',String(source===id));draw();}
    function frame(now){if(disposed||!playing||document.hidden)return;elapsed=Math.min(duration,now-start);if(elapsed>=duration){playing=false;raf=0;render();return;}if(now-lastPaint>90){draw();lastPaint=now;}raf=requestAnimationFrame(frame);}
    function schedule(){cancelAnimationFrame(raf);raf=0;if(playing&&!document.hidden)raf=requestAnimationFrame(frame);}
    function select(i){cancelAnimationFrame(raf);index=Math.max(0,Math.min(stages.length-1,i));playing=motionEnabled;elapsed=playing?0:duration;start=performance.now()-elapsed;lastPaint=0;render();schedule();}
    $('#pfd-play').onclick=()=>{if(playing){elapsed=Math.min(duration,performance.now()-start);playing=false;motionEnabled=false;}else{if(elapsed>=duration)elapsed=0;playing=true;motionEnabled=true;start=performance.now()-elapsed;}render();schedule();};$('#pfd-previous').onclick=()=>select(index-1);$('#pfd-next').onclick=()=>select(index+1);
    $('#pfd-reset').onclick=()=>{motionEnabled=!reduced;select(0);setView('current');};
    for(const id of ['river','groundwater'])$('#pfd-source-'+id).onclick=()=>{source=id;select(0);};
    const activate=e=>{const n=e.target.closest('[data-stage]');if(!n)return;if(n.dataset.source)source=n.dataset.source;select(stages.findIndex(s=>s.id===n.dataset.stage));setView('current');$('#pfd-tab-current').focus();};diagram.onclick=activate;diagram.onkeydown=e=>{if(e.key==='Enter'||e.key===' '){e.preventDefault();activate(e);}};
    const visibility=()=>{if(document.hidden){if(playing)elapsed=Math.min(duration,performance.now()-start);cancelAnimationFrame(raf);raf=0;}else{start=performance.now()-elapsed;schedule();}};document.addEventListener('visibilitychange',visibility);setView('current');render();schedule();
    return()=>{disposed=true;cancelAnimationFrame(raf);document.removeEventListener('visibilitychange',visibility);diagram.onclick=diagram.onkeydown=null;$('#pfd-mobile-tabs').onkeydown=null;};
  };
})();
process-art.js83 lines

Raw file

/* Passive process illustrations. No manipulation or completion actions. */
(() => {
  const units=[{id:'intake'},{id:'pretreat'},{id:'rapid'},{id:'floc'},{id:'settle',path:[[175,150],[540,150]]},{id:'ozone'},{id:'filter',path:[[320,82],[320,330]]},{id:'blend'},{id:'final'},{id:'contact',path:[[135,75],[495,75],[495,145],[145,145],[145,215],[495,215],[495,285],[145,285],[145,345],[540,345]]},{id:'tap'}];
  const clamp=(v,a=0,b=1)=>Math.max(a,Math.min(b,v));
  function at(path,p){const lengths=path.slice(1).map((b,i)=>Math.hypot(b[0]-path[i][0],b[1]-path[i][1]));let d=clamp(p)*lengths.reduce((a,b)=>a+b,0);for(let i=0;i<lengths.length;i++){if(d<=lengths[i]||i===lengths.length-1){const t=clamp(d/lengths[i]);return[path[i][0]+(path[i+1][0]-path[i][0])*t,path[i][1]+(path[i+1][1]-path[i][1])*t];}d-=lengths[i];}return path[0];}
  const line=(points,color='#254b5c',width=52)=>'<polyline points="'+points.map(p=>p.join(',')).join(' ')+'" fill="none" stroke="'+color+'" stroke-width="'+width+'" stroke-linejoin="round" stroke-linecap="round"/>';
  const pipe=points=>line(points,'#87a8ad',64)+line(points,'#143140',48);
  const text=(t,x,y,color='#a9c7cd',size=12)=>'<text x="'+x+'" y="'+y+'" text-anchor="middle" fill="'+color+'" font-family="Arial,sans-serif" font-size="'+size+'">'+String(t).replace(/&/g,'&amp;').replace(/</g,'&lt;')+'</text>';
  function droplet(x,y,p=0,small=false){const color=p<.3?'#a7bbac':p<.65?'#acd2c0':'#9ae3d9';return '<g transform="translate('+x+' '+y+') scale('+(small?.52:.75)+')"><path d="M0 -39C-7 -25 -25 -9 -25 7A25 25 0 0 0 25 7C25 -9 7 -25 0 -39Z" fill="'+color+'" stroke="#e2f5da" stroke-width="2"/><path d="M-16 10A16 16 0 0 0 -3 23" fill="none" stroke="#fff" stroke-opacity=".5" stroke-width="3" stroke-linecap="round"/></g>';}
  function tank(x,y,w,h,water='#2e5960'){return '<path d="M'+x+' '+y+'V'+(y+h)+'H'+(x+w)+'V'+y+'" fill="'+water+'" fill-opacity=".62" stroke="#9bb8bc" stroke-width="6"/>';}
  function scene(id,p=.65,time=0,source='river'){const s=units.find(x=>x.id===id);const u=clamp(p),rotation=s.id==='rapid'?time*65:s.id==='floc'?time*18:0;let body='';
    if(s.id==='intake'){
      if(source==='river'){
        body='<path d="M0 170Q75 148 150 170T300 170V330H0Z" fill="#38666a"/><path d="M0 203Q75 188 150 203T300 203M0 247Q75 230 150 247T300 247" fill="none" stroke="#85bcbd" stroke-width="3" opacity=".5"/>'+pipe([[150,240],[545,240]])+'<path d="M245 207V273" stroke="#bdd4ca" stroke-width="6"/>';
        for(let i=0;i<6;i++)body+='<path d="M'+(223+i*7)+' 209V271" stroke="#bdd4ca" stroke-width="2"/>';
        body+='<circle cx="432" cy="240" r="36" fill="#284a56" stroke="#a4c3c5" stroke-width="5"/><path d="M414 224L451 240L414 256Z" fill="#bed9cc"/>'+droplet(300+u*240,239,.1,true)+text('RIVER INTAKE',145,115,'#c3e0da',18)+text('SCREEN',240,190)+text('RAW-WATER PUMP',430,315)+text('TO PRETREATMENT',520,175);
      }else{
        body='<path d="M0 160H640V420H0Z" fill="#2c4446"/><path d="M0 275Q150 250 320 275T640 275V420H0Z" fill="#285966"/>'+text('GROUND SURFACE',125,150,'#b1c6bc',12)+'<path d="M255 360V105H525" stroke="#adc8c3" stroke-width="38" fill="none"/><path d="M255 360V105H525" stroke="#173c4b" stroke-width="24" fill="none"/><circle cx="255" cy="245" r="25" fill="#335e69" stroke="#b7d5cd" stroke-width="4"/>';
        for(let i=0;i<8;i++)body+='<path d="M239 '+(305+i*7)+'h32" stroke="#b4d1c5" stroke-width="2"/>';
        body+=droplet(255,330-u*225,.1,true)+text('GROUNDWATER WELLS',340,47,'#c3e0da',18)+text('AQUIFER',470,330,'#a5c9cc',17)+text('WELL PUMP',374,246)+text('TO INFLUENT PUMPING',490,77);
      }
    }
    if(s.id==='pretreat'){
      body=pipe([[45,220],[595,220]])+'<rect x="255" y="40" width="130" height="67" rx="12" fill="#334b50" stroke="#a4bfb9" stroke-width="3"/>'+text('NaOCl',320,69,'#d6e8d8',17)+text('PRE-OXIDATION',320,92,'#a6c4bd',10)+'<path d="M320 107V220" stroke="#9ec5ba" stroke-width="7"/>';
      if(u>0)body+=line([[75,220],[95+u*460,220]],'#9dc9be',10);
      for(let i=0;i<14;i++)body+='<circle cx="'+(355+i*16)+'" cy="'+(213+(i%3)*7)+'" r="3" fill="'+(i/14<u?'#b4d3a5':'#c4a778')+'"/>';
      body+=droplet(90+u*460,220,.08)+''+text(source==='groundwater'?'GROUNDWATER':'RIVER WATER',130,170)+text('TO RAPID MIX',532,170)+text(source==='groundwater'?'As(III) → As(V)':'SOURCE-SPECIFIC PRE-OXIDATION',320,315,'#d1c48e',18)+text(source==='groundwater'?'OXIDATION, NOT REMOVAL':'CHEMISTRY DEPENDS ON THE SOURCE',320,346,'#a7bdc4',10);
    }
    if(s.id==='rapid'||s.id==='floc'){
      body=tank(130,150,380,190,'#6b7050')+'<rect x="128" y="141" width="384" height="11" rx="5" fill="#9db6b5"/><path d="M320 126V257" stroke="#a3c2c1" stroke-width="8"/><g transform="translate(320 250) rotate('+rotation+')"><ellipse rx="84" ry="13" fill="#acbdba"/><ellipse rx="13" ry="51" fill="#8eaaa6"/></g>';
      const growth=s.id==='floc'?u:0;
      for(let i=0;i<55;i++){const group=i%8,baseX=163+(i*67%310),baseY=177+(i*43%135),cx=178+(group*43%280),cy=184+(group*31%118),x=baseX+(cx-baseX)*growth+(1-growth)*Math.sin(time+i)*4,y=baseY+(cy-baseY)*growth;body+='<circle cx="'+x+'" cy="'+y+'" r="'+(1.8+growth*2.6)+'" fill="#ba9963" opacity=".9"/>';}
      body+='<path d="M70 160H130" stroke="#c6bd8b" stroke-width="6"/><rect x="25" y="137" width="68" height="46" rx="6" fill="#5b6655" stroke="#a6b99b"/>'+text(s.id==='rapid'?'FeCl3':'POLYMER',59,165,'#e1ddb7',11);
      body+=droplet(430,207,.16,true)+''+text(s.id==='rapid'?'RAPID MIX · FERRIC CHLORIDE':'GENTLE MIX · FLOCCULATION',320,373);
    }
    if(s.id==='settle'){
      body=tank(95,110,405,220,'#406861')+pipe([[490,150],[590,150]])+'<rect x="100" y="299" width="395" height="27" fill="#8e714a" opacity=".8"/>';
      for(let i=0;i<7;i++)body+='<path d="M'+(200+i*28)+' 273l38 -75" stroke="#8eaaa7" stroke-width="4" opacity=".65"/>';
      const settled=clamp(time/1.8);for(let i=0;i<28;i++){const x=122+i*61%350,y=170+i*31%115,base=305+i%4*3;body+='<circle cx="'+x+'" cy="'+(y+(base-y)*settled)+'" r="'+(3+i%3)+'" fill="#bb975d"/>';}
      body+='<path d="M175 150H548" stroke="#abd5cc" stroke-width="2" stroke-dasharray="5 10"/>'+text('WATER OUT',549,109)+text('SLUDGE → THICKENER → DRYING BEDS',300,360,'#c6ab7c',11);
    }
    if(s.id==='blend'){
      body=pipe([[40,270],[320,270],[320,210],[570,210]])+pipe([[40,65],[190,65],[190,210],[320,210]])+'<circle cx="145" cy="270" r="32" fill="#315c65" stroke="#a4c4c4" stroke-width="5"/><path d="M126 255L165 270L126 285Z" fill="#c3e4d5"/><path d="M320 147V210" stroke="#b3cbc7" stroke-width="8"/>';
      body+=line([[45,270],[320,270],[320,210],[555,210]],'#8dd7cd',8);
      if(u>0)body+=line([[45,65],[190,65],[190,210],[320+u*230,210]],'#a8b9e7',u*10);
      body+=droplet(405+u*135,210,.85,true)+''+text(source==='groundwater'?'GROUNDWATER BYPASS':'OTHER COMPATIBLE FINISHED WATER',340,50,'#bdc9e8',12)+text('FILTER EFFLUENT PUMP',150,336)+text('TO FINAL TREATMENT',495,269)+text('ILLUSTRATIVE BLEND · NO OPERATING RATIO',320,385,'#a0bcc5',10);
    }
    if(s.id==='ozone'){
      body=tank(220,100,310,235,'#37626b')+pipe([[520,150],[595,150]])+'<rect x="55" y="113" width="100" height="94" rx="12" fill="#31434c" stroke="#8daab0" stroke-width="3"/>'+text('OZONE',105,155,'#c6dcdf')+text('FEED',105,176,'#c6dcdf')+'<path d="M105 205V230M105 310V325H320V305H470" stroke="#92c3c2" stroke-width="7" fill="none"/>';
      for(let i=0;i<Math.floor(u*35);i++){const x=260+(i*37%225),y=305-((time*75+i*31)%170);body+='<circle cx="'+x+'" cy="'+y+'" r="'+(3+i%3)+'" fill="none" stroke="#c1edf0" stroke-width="1.7" opacity=".8"/>';}
      for(let i=0;i<14;i++)body+='<circle cx="'+(250+i*31%235)+'" cy="'+(135+i*43%155)+'" r="4" fill="#bba2cb" opacity="'+(1-u)*.75+'"/>';
      body+=droplet(435,172,.5,true)+'';
      body+=text('SETTLED WATER → GAC FILTRATION',390,377,'#a8c9c8',11);
    }
    if(s.id==='filter'){
      body=pipe([[320,30],[320,105]])+tank(210,100,220,230,'#36626c')+pipe([[320,318],[320,372]])+'<rect x="213" y="157" width="214" height="64" fill="#292e2b"/><rect x="213" y="221" width="214" height="62" fill="#383a30"/><rect x="213" y="283" width="214" height="35" fill="#5f6660"/>';
      for(let i=0;i<100;i++)body+='<circle cx="'+(220+i*37%198)+'" cy="'+(163+i*53%146)+'" r="'+(1+i%2)+'" fill="#d2c4a3" opacity=".2"/>';
      for(let i=0;i<15;i++){const caught=u>i/23,cy=caught?174+(i%4)*10:112+(i*13%31);body+='<circle cx="'+(244+i*23%150)+'" cy="'+cy+'" r="3" fill="#c8a56d" opacity="'+(caught?1:.65)+'"/>';}
      body+=text('GAC',480,197)+text('GAC',480,254)+text('SUPPORT',480,307)+text('NONIONIC POLYMER',125,104,'#c4d7b4',10)+'<path d="M140 116L210 125" stroke="#c4d7b4" stroke-width="3"/>'; 
    }
    if(s.id==='final'){
      body=pipe([[45,235],[595,235]])+'<rect x="180" y="38" width="110" height="68" rx="10" fill="#354f50" stroke="#a1c2b8" stroke-width="3"/><rect x="350" y="38" width="110" height="68" rx="10" fill="#4b4e52" stroke="#a1b7ca" stroke-width="3"/>'+text('NaOCl',235,77,'#dceadc',16)+text('PHOSPHATE',405,77,'#dae0eb',12)+'<path d="M235 107V120H320V185M405 107V120H320M320 185V235" stroke="#afc7bb" stroke-width="7"/>';
      for(let i=0;i<Math.floor(u*18);i++)body+='<circle cx="'+(350+i*13)+'" cy="'+(228+i%3*7)+'" r="3" fill="'+(i%2?'#c4d9a0':'#b2cee1')+'"/>';
      body+=droplet(75+u*470,235,.95)+''+text('BLENDED WATER',120,293)+text('TO CHLORINE CONTACT',510,293)+text('FINAL DISINFECTION + CORROSION CONTROL',320,365,'#c4d9ce',12);
    }
    if(s.id==='contact'){
      body='<rect x="92" y="34" width="470" height="346" rx="22" fill="#173541" stroke="#9cb8bc" stroke-width="5"/>'+line(s.path,'#46727b',45)+line(s.path,'#acd8cf',2);
      for(let i=0;i<18;i++){const q=at(s.path,i/18),opacity=i/18<u?0:.8;body+='<circle cx="'+(q[0]+(i%2?8:-8))+'" cy="'+(q[1]+7)+'" r="3.2" fill="#c9b0cc" opacity="'+opacity+'"/>';}
      body+='<path d="M118 101H448M192 171H515M118 241H448M192 311H515" stroke="#73979d" stroke-width="9" stroke-linecap="round"/>';
      body+=text('IN',82,79)+text('OUT',584,348);
    }
    if(s.id==='tap'){
      body=pipe([[90,210],[300,210],[300,155],[440,155],[440,210]])+'<path d="M300 125V155" stroke="#b8d2d0" stroke-width="9"/><path d="M390 260L402 372H478L490 260" fill="#b5ddd911" stroke="#a4c5cb" stroke-width="4"/><ellipse cx="440" cy="260" rx="50" ry="8" fill="none" stroke="#a4c5cb" stroke-width="3"/>';
      if(u>0){body+='<path d="M440 215V'+(265+u*90)+'" stroke="#a2e7dc" stroke-width="'+(4+u*10)+'" stroke-linecap="round"/>'+'<path d="M399 '+(363-u*83)+'H481L476 368H404Z" fill="#79d2c8" opacity=".7"/>';body+=droplet(440,Math.min(336,245+u*95),1,true);}
      body+=''+text('CUSTOMERS',440,397)+text(source==='groundwater'?'VIA CANUTILLO BOOSTER':'PUMPING & DISTRIBUTION',140,275,'#9fbdc4',10);
    }
    if(s.path){const pos=at(s.path,u);body+='<g class="process-drop"><circle cx="'+pos[0]+'" cy="'+pos[1]+'" r="43" fill="transparent" pointer-events="all"/>'+droplet(...pos,s.id==='settle'?.38:s.id==='filter'?.65+u*.2:.9)+'</g>';if(u<.05){const q=at(s.path,.11);body+='<path d="M'+(q[0]-5)+' '+(q[1]-5)+'l6 5 -6 5" stroke="#f3d99c" stroke-width="2" fill="none"/>';}}
    return '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 420" aria-hidden="true"><rect width="640" height="420" fill="#0b202c"/>'+body+'</svg>';
  }

window.ProcessArt={scene};
})();
markup (index.html)11 lines

Raw file

<template id="tpl-drop">
    <div class="workspace-head process-head"><div><span class="overline">WATER TREATMENT</span><h1>Follow the water<span class="gold-point">.</span></h1></div><a class="process-explorer-link" href="#/water">Alternatives explorer ↗</a></div>
    <section class="process-walkthrough" id="process-walkthrough" aria-label="Water treatment walkthrough at your pace">
      <div class="pfd-toolbar"><div class="pfd-source-select" role="group" aria-label="Water source"><span>SOURCE</span><button type="button" id="pfd-source-river" aria-pressed="true">River intake</button><button type="button" id="pfd-source-groundwater" aria-pressed="false">Groundwater wells</button></div><div class="pfd-playback"><span class="pfd-auto-label">Next when ready · Reset starts over</span><button type="button" id="pfd-previous" aria-label="Previous process" disabled>←<span class="pfd-button-word"> Back</span></button><button type="button" id="pfd-play" aria-pressed="true">Pause</button><button type="button" id="pfd-next" aria-label="Next process"><span class="pfd-button-word">Next </span>→</button><button type="button" id="pfd-reset" aria-label="Reset walkthrough to the selected water intake">Reset</button></div></div>
      <div class="pfd-mobile-tabs" id="pfd-mobile-tabs" role="tablist" aria-label="Walkthrough view"><button type="button" id="pfd-tab-current" role="tab" aria-selected="true" aria-controls="pfd-detail-panel">Current step</button><button type="button" id="pfd-tab-flow" role="tab" aria-selected="false" aria-controls="pfd-overview-panel" tabindex="-1">Full process</button></div>
      <div class="pfd-dashboard"><div class="pfd-overview" id="pfd-overview-panel" role="region" aria-label="Full process"><div class="pfd-map-heading"><div><span class="overline">THE WHOLE PROCESS</span><p>The highlight follows the current step.</p></div><span id="pfd-stage-count">1 / 11</span></div><div class="pfd-map-scroll"><div id="pfd-map"></div></div><div class="pfd-support"><span><b>Solids</b> · sedimentation → thickener → drying beds</span><span><b>Backwash</b> · filter wash / drains → equalization → recycle or residuals</span></div></div>
        <div class="pfd-detail" id="pfd-detail-panel" role="region" aria-label="Current process"><div class="pfd-mobile-stage-heading"><span id="pfd-mobile-stage-index">STEP 01 / 11</span><h2 id="pfd-mobile-stage-title">River intake and pumping</h2></div><div class="pfd-illustration"><div class="pfd-figure-label">INSIDE THE CURRENT PROCESS</div><div id="pfd-figure" aria-hidden="true"></div><div class="pfd-timing" aria-hidden="true"><span id="pfd-stage-progress"></span></div></div><div class="pfd-explanation"><span class="overline" id="pfd-stage-label">CURRENT PROCESS</span><h2 id="pfd-stage-title">River intake and pumping</h2><p id="pfd-description"></p><div class="pfd-result"><span>RESULT</span><p id="pfd-result"></p></div></div></div>
      </div>
    </section><p class="disclosure process-disclosure">Conceptual PFD · Upper Valley reference for groundwater · River treatment is source-specific · Ozone and chlorine-contact basins are retained conceptual additions.</p>
  </template>

Have an idea of your own?

Look around your day, find the thing that wastes your time, and build the fix. Everything here is free to help you start. If you would rather I built it, or you just want to talk an idea through, write to me.

Write to me Email meHow to use what is here