An AI skill that turns books into animated, narrated, interactive web experiences
JavaScript ai-agentsai-educationanimationclaudeclaude-codeclaude-skillsedtecheducationinteractive-textbookscormtext-to-video
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Converting Measurements — Elementary Mathematics</title><link rel="stylesheet" href="../lib/engine.css"><link rel="expect" href="#bar" blocking="render"><style>.band .prompt{font-size:27px}.side .keys{font-size:19px}.screen .blanks .bline{gap:12px}.screen .blanks .box{width:9ch!important}.screen .blanks .why{font-size:22px}.screen .blanks .bline svg tspan{font-style:normal}</style></head><body>
<script src="../lib/engine.js"></script><script src="audio/en/timings.js"></script><script>
'use strict';
const CHAPTER={number:18,title:'Converting Measurements',minutes:13,language:'en', next: '../ch19/' };
// Entrances from ch17. Blue marks conserved quantities; amber marks new unit readings.
const cvText=(p,s,x,y,t=0,size=30,col=COL.chalk,anchor='start')=>{const e=T(p,s,{x,y,size,fill:col,anchor,o:0});show(e,t);return e;};
const cvMath=(p,s,x,y,t=0,size=52,col=COL.chalk)=>{const e=M(p,Array.isArray(s)?s:[s],{x,y,size,fill:col,anchor:'middle',o:0});e.querySelectorAll('tspan').forEach(span=>{if(!/^[xy]$/.test(span.textContent))span.setAttribute('font-style','normal');});show(e,t);return e;};
const cvTitle=(p,s,sub='')=>{cvText(p,s,100,110,.1,43);if(sub)cvText(p,sub,100,165,.15,27,COL.dim);};
function cvTape(p,x,y,w,n,label,t=0,right=false){const g=G(p,{x,y,o:0});g.dataset.quantity=label;const bar=mk('rect',{x:0,y:0,width:w,height:65,fill:mix(COL.board,COL.whole,.3),stroke:COL.whole,'stroke-width':3},g);for(let i=1;i<n;i++)path(g,`M${i*w/n} 0V65`,{stroke:COL.whole,'stroke-width':2});T(g,label,right?{x:w+30,y:45,size:34,anchor:'start',fill:COL.whole}:{x:w/2,y:110,size:34,anchor:'middle',fill:COL.whole});show(g,t);return {g,bar,w,x,y};}
function cvCuts(v,n,t,col=COL.task){const g=G(v.g,{o:0});g.dataset.parts=String(n);for(let i=0;i<=n;i++){const e=path(g,`M${i*v.w/n} -10V75`,{stroke:col,'stroke-width':2});e.dataset.cut=String(i);e.dataset.position=String(i*v.w/n);}show(g,t,.9);return g;}
function cvLiquid(p,n=48,layout='loose',size=36){return Array.from({length:n},(_,i)=>{const xy=cvPosition(i,layout),g=G(p,{x:xy[0],y:xy[1]});g.dataset.cellId='fluid-'+i;g.dataset.flOz='1';mk('rect',{width:size,height:size,fill:mix(COL.board,COL.whole,.45),stroke:COL.whole,'stroke-width':2},g);return g;});}
function cvPosition(i,layout){const cup=Math.floor(i/8),j=i%8;if(layout==='one')return [370+j%2*64,280+Math.floor(j/2)*64];if(layout==='loose')return [672+Math.floor(cup/2)*88+j%2*44,245+cup%2*176+Math.floor(j/2)*44];if(layout==='cups')return [360+Math.floor(cup/2)*400+j%2*44,245+cup%2*255+Math.floor(j/2)*44];const k=Math.floor(i/16),n=i%16;return [360+k*400+n%2*44,245+Math.floor(n/2)*44];}
function cvRegroup(cells,layout,t){cells.forEach((e,i)=>{const [x,y]=cvPosition(i,layout);tw(e,{x,y},t,3,io);});}
function cvGroups(p,n,layout,t){return Array.from({length:n},(_,k)=>{const [x,y]=cvPosition(k*(layout==='cups'?8:16),layout),w=98,h=layout==='cups'?186:362,g=G(p,{o:t>0?0:1});mk('rect',{x:x-9,y:y-9,width:w,height:h,rx:10,fill:'none',stroke:COL.task,'stroke-width':3},g);T(g,(layout==='cups'?'1 cup':'1 pint'),{x:x+40,y:y+h+26,size:32,fill:COL.task,anchor:'middle'});if(t>0)show(g,t);return g;});}
// One pound outline around the gathered counters, its label right under it.
function cvPound(p,t,tl=t){const g=G(p,{o:t>0?0:1}),l=G(p,{o:tl>0?0:1});mk('rect',{x:605,y:265,width:235,height:235,rx:16,fill:'none',stroke:COL.task,'stroke-width':3},g);T(l,'1 lb = 16 oz',{x:722.5,y:560,size:41,fill:COL.task,anchor:'middle'});if(t>0)show(g,t);if(tl>0)show(l,tl);}
function cvOz(p,grouped=false){return Array.from({length:16},(_,i)=>{const g=G(p,{x:(grouped?640:300)+i%4*(grouped?55:95),y:300+Math.floor(i/4)*(grouped?55:95)});g.dataset.ounceId='mass-'+i;mk('circle',{r:18,fill:mix(COL.board,COL.whole,.4),stroke:COL.whole,'stroke-width':2},g);return g;});}
function cvRows(p,rows,x,y,t,size=32,gap=65){rows.forEach((s,i)=>cvText(p,s,x,y+i*gap,t+i*.35,size));}
const BEATS=[
['intro','Converting measurements',(m,D)=>{const g=G(scene,{o:0,y:24});T(g,'Unit 2 · Ratios, Proportions, and Percents · Chapter 18',{x:800,y:200,size:28,fill:COL.dim,anchor:'middle'});T(g,'Converting',{x:800,y:345,size:90,weight:600,anchor:'middle'});T(g,'Measurements',{x:800,y:450,size:90,weight:600,anchor:'middle'});cvTape(g,440,545,720,2,'2 feet = 24 inches');tw(g,{o:1,y:0},.2,1,out);cvText(g,'Same quantity · new unit',800,775,m('sub'),39,COL.task,'middle');hide(g,D-.8,.7);}],
['length','Same tape, smaller units',m=>{const p=panel(0);cvTitle(p,'Two feet stays two feet','US customary length · subdivisions change, physical length stays fixed');S.cvTape=cvTape(p,260,325,960,2,'2 ft');cvCuts(S.cvTape,24,m('inches'));cvText(p,'12 inches in each foot · 24 inches altogether',800,545,m('inches',1),37,COL.task,'middle');cvText(p,'12 in = 1 ft',600,650,m('yards',-2.5),36);cvRows(p,['3 ft = 1 yd','1,760 yd = 1 mi'],600,710,m('yards'),36,60);}],
['larger','Group into larger units',m=>{const p=panel(0);cvTitle(p,'36 inches · 3 feet · 1 yard','Same fixed tape; larger units mean fewer units.');S.cvTape=cvTape(p,260,310,1080,36,'36 in');S.cvFootCuts=cvCuts(S.cvTape,3,m('feet'));cvText(p,'3 feet',800,535,m('feet',1),48,COL.task,'middle');const bracket=path(p,'M260 590V615H1340V590',{stroke:COL.task,'stroke-width':4},{d:0});draw(bracket,m('yard'),1);cvText(p,'1 yard',800,685,m('yard',1),48,COL.task,'middle');cvText(p,'36 ÷ 12 = 3 3 ÷ 3 = 1',800,820,m('yard',2),38,COL.chalk,'middle');}],
['weight','Mass ounces, pounds and short tons',m=>{const p=panel(0);cvTitle(p,'16 ounces = 1 pound','Each counter represents 1 oz of mass; every counter stays.');S.cvOz=cvOz(p);S.cvOz.forEach((e,i)=>tw(e,{x:640+i%4*55,y:300+Math.floor(i/4)*55},m('gather'),3,io));cvPound(p,m('gather',3),m('gather',4.5));cvText(p,'1 US short ton = 2,000 lb',800,700,m('ton'),46,COL.chalk,'middle');cvText(p,'Metric grams and kilograms measure MASS.',800,815,m('ton',2),32,COL.dim,'middle');}],
['capacity','US liquid capacity chain',m=>{const p=panel(0);cvTitle(p,'1 cup = 8 fluid ounces','US liquid measures · each cell represents 1 fl oz');S.cvLiquid=cvLiquid(p,8,'one',56);mk('rect',{x:354,y:264,width:152,height:280,rx:14,fill:'none',stroke:COL.task,'stroke-width':3},p);cvText(p,'1 cup · 8 fl oz',430,600,0,40,COL.task,'middle');cvRows(p,['3 tsp = 1 tbsp','2 tbsp = 1 fl oz','8 fl oz = 1 cup','2 cups = 1 pt','2 pt = 1 qt','4 qt = 1 US gal'],850,275,m('chain'),34,68);cvText(p,'oz: mass fl oz: liquid volume',800,825,m('different'),37,COL.task,'middle');}],
['q1','Choose the matching inch tape',()=>{const p=panel(0);cvTitle(p,'Match this 2-foot tape','All tapes use the same length scale.');cvTape(p,680,225,240,2,'2 ft');S.cvChoices=[24,12,36].map((n,i)=>{const x=110+i*520,g=G(p);const tape=cvTape(g,x,440,n*10,n,n+' in');g.dataset.inches=String(n);return {el:g,box:[x-30,410,445,220],label:n+' inches',bar:tape.bar};});},{ask:done=>quiz(BAND,[{id:'c-length',prompt:'Which inch tape has the same length as 2 feet?',build:pickEls(S.cvChoices,0,'2 × 12 = 24 inches. The 24-inch tape matches the 2-foot tape.',i=>i===1?'12 inches is only 1 foot. Two feet need two groups of twelve.':'36 inches equals 3 feet, so that tape is too long.')}],done)}],
['proportion','A proportion keeps units aligned',m=>{const p=panel(0);cvTitle(p,'How many quarts are in 14 pints?','Every cell below represents 1 pint.');S.cvPints=Array.from({length:14},(_,i)=>{const g=G(p,{x:170+i*88,y:330});g.dataset.pintId='pint-'+i;mk('rect',{width:60,height:70,fill:mix(COL.board,COL.whole,.35),stroke:COL.whole,'stroke-width':2},g);tw(g,{x:170+Math.floor(i/2)*175+i%2*60},m('pair'),2,io);return g;});for(let i=0;i<7;i++){const g=G(p,{o:0});mk('rect',{x:165+i*175,y:320,width:130,height:90,rx:8,fill:'none',stroke:COL.task,'stroke-width':2},g);T(g,'1 qt',{x:230+i*175,y:455,size:28,fill:COL.task,anchor:'middle'});show(g,m('pair',2));}cvMath(p,[F('x quarts','14 pints'),' = ',F('1 quart','2 pints')],800,620,m('ratio'),52);cvMath(p,'2x = 14 x = 7 quarts',800,800,m('solve'),47,COL.task);}],
['chain','48 fluid ounces into cups',m=>{const p=panel(0);cvTitle(p,'Start with 48 fl oz','Every original square = 1 fl oz; square sizes never change.');S.cvLiquid=cvLiquid(p);cvRegroup(S.cvLiquid,'cups',m('cups'));cvGroups(p,6,'cups',m('cups',3));cvText(p,'48 fl oz ÷ (8 fl oz/cup) = 6 cups',800,800,m('step'),43,COL.task,'middle');}],
['chainpints','Six cups into three pints',m=>{const p=panel(0);cvTitle(p,'Same 48 fl oz · regroup the same squares','Six groups of 8 become three groups of 16.');S.cvLiquid=cvLiquid(p,48,'cups');cvGroups(p,6,'cups',0).forEach(g=>hide(g,m('pints')));cvRegroup(S.cvLiquid,'pints',m('pints'));cvGroups(p,3,'pints',m('pints',3));cvText(p,'48 fl oz = 6 cups = 3 pints',800,720,m('chain'),50,COL.task,'middle');cvText(p,'48 ÷ 8 = 6 6 ÷ 2 = 3',800,825,m('chain',2),40,COL.chalk,'middle');}],
['q2','Choose the conserved liquid amount',()=>{const p=panel(0);cvTitle(p,'Match 48 fluid ounces','Every small square = 1 fl oz; each outlined group = 1 US liquid pint.');S.cvChoices=[3,6,2].map((n,i)=>{const x=115+i*520,g=G(p);for(let k=0;k<n;k++){const xx=x+k%3*110,yy=295+Math.floor(k/3)*145;mk('rect',{x:xx-6,y:yy-6,width:88,height:88,rx:7,fill:'none',stroke:COL.task,'stroke-width':2},g);for(let j=0;j<16;j++){const e=mk('rect',{x:xx+j%4*19,y:yy+Math.floor(j/4)*19,width:16,height:16,fill:mix(COL.board,COL.whole,.4),stroke:COL.whole,'stroke-width':1},g);e.dataset.flOz='1';}}cvText(g,n+' pints',x+170,605,0,38,COL.whole,'middle');g.dataset.pints=String(n);return {el:g,box:[x-25,260,440,380],label:n+' pints'};});},{ask:done=>quiz(BAND,[{id:'c-liquid',prompt:'Which picture has exactly 48 fl oz?',build:pickEls(S.cvChoices,0,'3 pints × 16 fl oz/pint = 48 fl oz. Every original fluid-ounce cell fits.',i=>i===1?'Six pints contain 96 fl oz. Six CUPS, not six pints, equal 48 fl oz.':'Two pints contain 32 fl oz. You need three groups of sixteen.')}],done)}],
['metric','Metric length units',m=>{const p=panel(0);cvTitle(p,'1 centimeter · 10 millimeters','The 1 cm section is drawn larger to see its divisions.');S.cvTape=cvTape(p,350,300,900,1,'1 cm');cvCuts(S.cvTape,10,m('split'));cvText(p,'10 mm = 1 cm',800,550,m('split',1),49,COL.task,'middle');cvRows(p,['100 cm = 1 m','1,000 m = 1 km'],580,695,m('metre'),44,100);}],
['metricmass','Metric mass units',m=>{const p=panel(0);cvTitle(p,'Ten 100-gram blocks · 1 kilogram','Same blocks, same mass.');S.cvMass=Array.from({length:10},(_,i)=>{const g=G(p,{x:290+i*100,y:300});g.dataset.grams='100';mk('rect',{width:85,height:90,fill:mix(COL.board,COL.whole,.4),stroke:COL.whole,'stroke-width':2},g);hide(T(g,'100 g',{x:42,y:140,size:25,fill:COL.whole,anchor:'middle'}),m('grams'),.4);return g;});S.cvMass.forEach((g,i)=>tw(g,{x:375+i*85},m('grams'),3,io));const kg=(x0,x1,y,t)=>{const b=G(p,{o:0});path(b,`M${x0} ${y}V${y+20}H${x1}V${y}`,{stroke:COL.task,'stroke-width':4,fill:'none'});T(b,'1 kg',{x:(x0+x1)/2,y:y+70,size:42,fill:COL.task,anchor:'middle'});show(b,t);return b;};hide(kg(290,1275,465,m('grams',-2.5)),m('grams'),.4);kg(375,1225,410,m('grams',3));cvText(p,'1 kg = 1,000 g',800,600,m('grams',1.5),52,COL.task,'middle');cvText(p,'1,000 mg = 1 g',800,730,m('milli'),47,COL.chalk,'middle');cvText(p,'½ kg = 500 g · mass stays mass',800,835,m('milli',3),32,COL.dim,'middle');}],
['metricchain','Kilometers through meters to centimeters',m=>{const p=panel(0);cvTitle(p,'A fixed 3-kilometer tape','Readout changes; this physical length never changes.');S.cvTape=cvTape(p,300,300,1000,3,'3 km');cvMath(p,'3 km × (1,000 m/km) = 3,000 m',800,555,m('metres'),47);cvMath(p,'3,000 m × (100 cm/m) = 300,000 cm',800,700,m('centimetres'),44,COL.task);cvText(p,'Same tape: 3 km = 3,000 m = 300,000 cm',800,830,m('check'),33,COL.whole,'middle');}],
['q3','Choose the matching metric tape',()=>{const p=panel(0);cvTitle(p,'Match the 3-kilometer reference','All bars use the same length scale.');cvTape(p,350,215,450,3,'3 km',0,true);S.cvChoices=[300000,3000,30000].map((n,i)=>{const x=350,y=365+i*105,g=G(p);const tape=cvTape(g,x,y,n*.0015,1,n.toLocaleString('en-US')+' cm',0,true);g.dataset.centimeters=String(n);return {el:g,box:[x-25,y-17,720,99],label:n+' centimeters',bar:tape.bar};});},{ask:done=>quiz(BAND,[{id:'c-metric',prompt:'Which centimeter bar represents the same 3 km?',build:pickEls(S.cvChoices,0,'3 × 1,000 × 100 = 300,000 cm. The same-scale bar matches.',i=>i===1?'3,000 is the number of METERS. Multiply by 100 to convert those meters to centimeters.':'30,000 cm is only 300 meters. Each kilometer is 100,000 centimeters.')}],done)}],
['crosslength','Exact and rounded length factors',m=>{const p=panel(0);cvTitle(p,'3 inches = 7.62 centimeters exactly','Two scales mark the same conserved physical segment.');S.cvTape=cvTape(p,350,305,762,3,'3 in');const metric=G(p,{o:0});for(let i=0;i<=7;i++){path(metric,`M${350+i*100} 440V465`,{stroke:COL.task,'stroke-width':3});T(metric,String(i),{x:350+i*100,y:505,size:27,fill:COL.task,anchor:'middle'});}path(metric,'M1112 430V470',{stroke:COL.task,'stroke-width':4});T(metric,'7.62 cm',{x:1190,y:505,size:31,fill:COL.task,anchor:'middle'});show(metric,m('cm'));cvText(p,'1 in = 2.54 cm 1 yd = 0.9144 m',800,610,m('cm',1),42,COL.chalk,'middle');cvText(p,'1 m ≈ 3.28 ft 1 mi ≈ 1.61 km',800,735,m('rounded'),41,COL.task,'middle');cvText(p,'= exact ≈ approximate',800,835,m('rounded',2),33,COL.dim,'middle');}],
['crossmass','Mass conversion factors',m=>{const p=panel(0);cvTitle(p,'Same 1-pound mass','Same original 16 mass-ounce counters; new readout.');S.cvOz=cvOz(p,true);cvPound(p,0);cvText(p,'1 lb ≈ 453.592 g',920,350,m('grams'),43);cvText(p,'1 lb ≈ 0.454 kg',920,440,m('grams',6.1),43);cvText(p,'1 oz ≈ 28.350 g',800,690,m('ounce'),43,COL.task,'middle');cvText(p,'Rounded factors: state the factor and round the final result.',800,845,m('ounce',2),30,COL.dim,'middle');}],
['crosscapacity','US liquid units to metric volume',m=>{const p=panel(0);cvTitle(p,'One US liquid pint · same liquid','Capacity conversions use fl oz, never mass oz.');const g=G(p);path(g,'M260 260H600L570 625H290Z',{fill:'none',stroke:COL.whole,'stroke-width':4});path(g,'M276 420H584L566 620H294Z',{fill:mix(COL.board,COL.whole,.4),stroke:COL.whole,'stroke-width':2});cvText(p,'1 US pint of liquid',430,705,0,33,COL.whole,'middle');cvRows(p,['1 pt ≈ 473.177 mL','1 pt ≈ 0.473 L','1 fl oz ≈ 29.574 mL','1 US gal ≈ 3.785 L'],810,300,m('metric'),38,105);cvText(p,'Same container · same volume',800,845,m('same'),37,COL.task,'middle');}],
['litres','Nine liters into US gallons',m=>{const p=panel(0);cvTitle(p,'9 liters · how many US liquid gallons?','Given rounded factor: 1 US gal ≈ 3.785 L');S.cvTape=cvTape(p,260,290,1080,1,'9 L');S.cvGallonCuts=G(p,{o:0});[0,3.785,7.57,9].forEach((v,i)=>{const x=260+v*120,e=path(S.cvGallonCuts,`M${x} 270V375`,{stroke:COL.task,'stroke-width':3});e.dataset.liters=String(v);e.dataset.position=String(x);});show(S.cvGallonCuts,m('divide'));cvText(p,'1 gallon',487.1,465,m('divide',1),32,COL.task,'middle');cvText(p,'1 gallon',941.3,465,m('divide',1),32,COL.task,'middle');cvText(p,'part',1254.2,465,m('divide',1),30,COL.task,'middle');cvMath(p,'x ≈ 9 ÷ 3.785 ≈ 2.38 US gal',800,590,m('rounded'),49,COL.task);cvMath(p,[F('1 gal','3.785 L'),' ≈ ',F('x gal','9 L')],800,745,m('rounded',6.6),53);}],
['wrap','Four habits for conversions',m=>{const p=panel(0);cvTitle(p,'Same amount · new unit');[['Keep length, mass and capacity in their own unit chains.','w1'],['Write units; match their positions in proportions.','w2'],['Use known factors; check larger unit versus smaller count.','w3'],['Exact: = Rounded: ≈ Follow requested decimal places.','w4']].forEach(([s,key],i)=>{const g=G(p,{x:-16,y:285+i*145,o:0});mk('circle',{cx:130,cy:-10,r:26,fill:COL.task},g);T(g,String(i+1),{x:130,y:0,size:30,anchor:'middle',fill:COL.board});T(g,s,{x:195,size:31});tw(g,{x:0,o:1},m(key),.6);});}],
['final1','Chapter practice',()=>panel(0),{ask:done=>quiz(SCREEN,[{id:'p-customary',prompt:'US customary units. Give exact answers.',build:blanks([
{parts:['18 feet = ',{box:'216'},' inches'],why:'18 × 12 = 216 inches. The length stays fixed.'},
{parts:[{box:'9'},' US gallons = 36 quarts'],why:'36 ÷ 4 = 9 US liquid gallons.'},
{parts:['42 teaspoons = ',{box:'7'},' fluid ounces'],why:'3 tsp/tbsp × 2 tbsp/fl oz = 6 tsp/fl oz; 42 ÷ 6 = 7 fl oz.'},
{parts:['2.75 miles = ',{box:'14520'},' feet'],why:'1 mile = 1,760 × 3 = 5,280 feet; 2.75 × 5,280 = 14,520 feet.'}
])}],done,'Chapter practice · set 1 of 3')}],
['final2','Chapter practice',()=>panel(0),{ask:done=>quiz(SCREEN,[{id:'p-metric',prompt:'Use the stated factors. Round only the final answer as requested.',build:blanks([
{parts:['0.06 km = ',{box:'60000'},' mm (exact)'],why:'0.06 × 1,000 m/km × 1,000 mm/m = 60,000 mm.'},
{parts:['25 cm ≈ ',{box:'9.84'},' in; 1 in = 2.54 cm (2 decimal places)'],why:'25 ÷ 2.54 = 9.8425…; nearest hundredth: approximately 9.84 inches.'},
{parts:['12 oz ≈ ',{box:'340.2'},' g; 1 oz ≈ 28.35 g (1 decimal place)'],why:'Using the stated rounded factor: 12 × 28.35 = 340.2; approximately 340.2 g.'},
{parts:['3.5 US pt ≈ ',{box:'1.6555'},' L; 1 pt ≈ 0.473 L (4 decimal places)'],why:'3.5 × 0.473 = 1.6555; approximately 1.6555 liters using the rounded factor.'}
])}],done,'Chapter practice · set 2 of 3')}],
['final3','Chapter practice',()=>panel(0),{ask:done=>quiz(SCREEN,[{id:'p-context',prompt:'Convert first, then compare. For the hills use 1 m ≈ 3.28 ft; round to 1 decimal place.',build:blanks([
{parts:['5-mile hike; already walked 8,200 ft. Remaining: ',{box:'18200'},' ft'],why:'5 × 5,280 = 26,400 ft total; 26,400 − 8,200 = 18,200 ft remain.'},
{parts:['Hill heights: 1,375 m and 920 m. Difference ≈ ',{box:'1492.4'},' ft'],why:'1,375 − 920 = 455 m; using 1 m ≈ 3.28 ft gives 455 × 3.28 ≈ 1,492.4 ft. Round to one decimal place.',hint:'For the hills use 1 m ≈ 3.28 ft; round the final answer to 1 decimal place.'}
])}],done,'Chapter practice · set 3 of 3')}],
['finish','Finished',()=>panel(0),{ask:finishCard}]
].map(([id,title,run,extra])=>({id,title,run,...extra}));
boot();
</script></body></html>