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>Percent — Elementary Mathematics</title><link rel="stylesheet" href="../lib/engine.css"><link rel="expect" href="#bar" blocking="render"><style>.band .prompt{font-size:27px}.screen .blanks .bline{gap:12px}.screen .blanks .box{width:8ch!important}.screen .blanks .why{font-size:21px}.screen .blanks .bline svg tspan{font-style:normal}.screen .blanks .bline svg.m{zoom:1.2}.screen .blanks .bline svg.m:has(path){zoom:1.45}</style></head><body>
<script src="../lib/engine.js"></script><script src="audio/en/timings.js"></script><script>
'use strict';
const CHAPTER={number:19,title:'Percent',minutes:13,language:'en', next: '../ch20/' };
// Fixed-area bars from ch06; hundredth cells from ch08. Blue always marks selected amount.
const pcText=(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 pcMath=(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});show(e,t);return e;};
const pcTitle=(p,s,sub='')=>{pcText(p,s,100,110,.1,43);if(sub)pcText(p,sub,100,165,.15,27,COL.dim);};
function pcGrid(p,x,y,size,n,t=0,id='cell'){
const g=G(p,{x,y,o:0}),cells=[];g.dataset.wholeArea=String(size*size);
for(let i=0;i<100;i++){const e=mk('rect',{x:i%10*size/10,y:Math.floor(i/10)*size/10,width:size/10,height:size/10,fill:i<n?COL.whole:COL.faint,'fill-opacity':i<n?.55:.14,stroke:COL.chalk,'stroke-width':1.3},g);e.dataset.cellId=id+'-'+i;e.dataset.selected=String(i<n);cells.push(e);}
show(g,t);return {g,cells,x,y,size};
}
function pcShade(model,n,t){model.cells.slice(0,n).forEach((e,i)=>tw(e,{'c_fill':COL.whole,'a_fill-opacity':.55},t+i*.025,.35));}
function pcBar(p,x,y,w,n,d=100,t=0,h=110){
const g=G(p,{x,y,o:0});g.dataset.fraction=n+'/'+d;const shade=mk('rect',{width:w*n/d,height:h,fill:COL.whole,'fill-opacity':.55},g);shade.dataset.area=String(w*n/d*h);
const outline=mk('rect',{width:w,height:h,fill:'none',stroke:COL.chalk,'stroke-width':3},g);const cuts=pcCuts({g,w,h},d,0,COL.dim);show(g,t);return {g,shade,outline,cuts,x,y,w,h,n,d};
}
function pcCuts(b,n,t,col=COL.task){const g=G(b.g,{o:0}),fine=n>50;g.dataset.parts=String(n);for(let i=1;i<n;i++){const e=path(g,`M${i*b.w/n} 0V${b.h}`,{stroke:fine?COL.dim:col,'stroke-width':fine?1:2,'stroke-opacity':fine?.5:1});e.dataset.cut=String(i);e.dataset.position=String(i*b.w/n);}show(g,t,.8);return g;}
function pcGridChoices(p,ns){return ns.map((n,i)=>{const x=170+i*480,g=G(p);const model=pcGrid(g,x,290,300,Math.floor(n));if(n%1){const e=mk('rect',{x:Math.floor(n)%10*30,y:Math.floor(n/10)*30,width:30*(n%1),height:30,fill:COL.whole,'fill-opacity':.55},model.g);e.dataset.partialHundredth=String(n%1);}
pcText(g,String.fromCharCode(65+i),x+150,262,0,33,COL.dim,'middle');g.dataset.percent=String(n);return {el:g,box:[x-20,225,340,385],label:n+' percent',model};});}
function pcMovePoint(p,digs,from,to,x,y,t,t1,zero){const g=G(p,{o:0}),s=34.5,dw=15.1,dir=Math.sign(to-from),pos=(i,d)=>x+i*s+(i>=d?dw:0);
const ds=[...digs].map((c,i)=>{const e=T(g,c,{x:pos(i,from),y,size:58,o:zero==='in'&&i===0?0:1});return e;});const dot=T(g,'.',{x:x+from*s,y,size:58,fill:COL.task});dot.dataset.t1=String(t1);
for(let k=0,d=from;d!==to;k++,d+=dir){const i=dir<0?d-1:d,t0=t1+k;tw(ds[i],{x:pos(i,d+dir)},t0,1,io);tw(dot,{x:x+(d+dir)*s},t0,1,io);tw(dot,{y:y-48},t0,.5,out);tw(dot,{y},t0+.5,.5,io);}
const tz=t1+Math.abs(to-from);if(zero==='in')show(ds[0],tz,.5);else if(zero==='out')hide(ds[0],tz,.5);show(g,t);return dot;}
const BEATS=[
['intro','Percent',(m,D)=>{const g=G(scene,{o:0,y:24});T(g,'Unit 2 · Ratios, Proportions, and Percents · Chapter 19',{x:800,y:220,size:28,fill:COL.dim,anchor:'middle'});T(g,'Percent',{x:800,y:380,size:94,weight:600,anchor:'middle'});pcMath(g,['37% = ',F('37','100'),' = 0.37'],800,525,.3,65,COL.whole);tw(g,{o:1,y:0},.2,1,out);pcText(g,'Three forms · one amount',800,715,m('sub'),40,COL.task,'middle');hide(g,D-.8,.7);}],
['hundred','Per hundred',m=>{const p=panel(0);pcTitle(p,'Percent means per hundred','One square = one whole · 100 equal cells');S.pcHundred=pcGrid(p,210,250,460,0,0,'garden');pcShade(S.pcHundred,37,m('shade'));pcMath(p,['37% = ',F('37','100')],1110,375,m('names'),60,COL.whole);pcMath(p,'= 0.37',1110,510,m('names',2),60);pcText(p,'100% = 1 0% = 0',1110,680,m('whole'),36,COL.task,'middle');pcText(p,'The whole sets the meaning of 100%.',800,825,m('whole',2),34,COL.dim,'middle');}],
['fraction','Simplify without changing area',m=>{const p=panel(0);pcTitle(p,'40% · forty of one hundred cells','The same forty original cells stay shaded.');S.pcForty=pcGrid(p,210,250,460,40,0,'forty');S.pcGroups=G(p,{o:0});for(let i=0;i<5;i++){const e=mk('rect',{x:210,y:250+i*92,width:460,height:92,fill:'none',stroke:COL.task,'stroke-width':4},S.pcGroups);e.dataset.groupCells='20';}show(S.pcGroups,m('groups'));pcMath(p,['40% = ',F('40','100')],1110,340,0,57,COL.whole);pcMath(p,[F('40 ÷ 20','100 ÷ 20'),' = ',F('2','5')],1110,515,m('simplify'),54);pcText(p,'Two of five equal groups',1110,650,m('groups',4.5),32,COL.task,'middle');pcText(p,'Percent as fraction: number over 100, then simplify.',800,825,m('rule'),34,COL.dim,'middle');}],
['q1','Choose forty percent',()=>{const p=panel(0);pcTitle(p,'Each square is ONE whole','Same size · 100 equal cells in every square');S.pcChoices=pcGridChoices(p,[40,4,60]);},{ask:done=>quiz(BAND,[{id:'c-hundred',prompt:'Which picture shows 40% of one whole?',build:pickEls(S.pcChoices,0,'40% means forty of one hundred equal cells. Picture A fills four complete rows.',i=>i===1?'Four cells out of one hundred is 4%, not 40%. Forty needs four full rows.':'Sixty cells is 60%. For 40%, fill forty and leave sixty unfilled.')}],done)}],
['equivalent','Build an equivalent fraction',m=>{const p=panel(0);pcTitle(p,'Seven twentieths · same strip, smaller pieces');S.pcEquivalent=pcBar(p,220,290,1120,7,20);S.pcSubcuts=pcCuts(S.pcEquivalent,100,m('split'));pcText(p,'20 × 5 = 100 equal pieces',800,520,m('split',1),38,COL.task,'middle');pcMath(p,[F('7','20'),' = ',F('7 × 5','20 × 5'),' = ',F('35','100'),' = 35%'],800,680,m('result'),61,COL.whole);pcText(p,'Same blue area. Both fraction numbers get the same factor.',800,825,m('check'),32,COL.dim,'middle');}],
['divide','Any fraction can use division',m=>{const p=panel(0);pcTitle(p,'Three eighths is exactly 37.5%','One strip = 1 whole · the half-hundredth is real');S.pcEighth=pcBar(p,220,240,1120,3,8,0,100);const e1=pcMath(p,[F('3','8'),' = 3 ÷ 8 = 0.375'],800,500,m('decimal'),54),e2=pcMath(p,'0.375 × 100 = 37.5 → 37.5%',800,650,m('percent'),52,COL.whole);[e1,e2].forEach(e=>tw(e,{x:470},m('cuts',.3),1.2,io));pcCuts(S.pcEighth,100,m('cuts'));
const z=G(p,{o:0});mk('rect',{x:612,y:240,width:44.8,height:100,fill:'none',stroke:COL.task,'stroke-width':3},z);path(z,'M612 340L880 520M656.8 340L1320 520',{stroke:COL.task,'stroke-width':2,'stroke-opacity':.6});S.pcZoom=pcBar(z,880,520,440,2.5,4,0,110);for(let i=0;i<=4;i++)T(z,(35+i)+'%',{x:880+i*110,y:670,size:26,fill:COL.dim,anchor:'middle'});show(z,m('cuts',1.5));pcText(p,'37 complete hundredths + ½ of the next',800,825,m('cuts',1),35,COL.task,'middle');}],
['decimal','Percent to decimal',m=>{const p=panel(0);pcTitle(p,'68% battery · the same charge in decimal form');S.pcBattery=pcBar(p,220,260,1120,68);mk('rect',{x:1342,y:288,width:20,height:54,rx:5,fill:COL.chalk},p);pcMath(p,['68% = ',F('68','100')],520,530,m('fraction'),55);pcMath(p,'68 ÷ 100 = 0.68',1080,530,m('divide'),55,COL.whole);S.pcLeftDot=pcMovePoint(p,'068',3,1,600,700,m('divide'),m('divide',3.9),'in');pcText(p,'÷ 100 · two places LEFT',800,700,m('divide',3.9),34,COL.task);pcText(p,'The amount stays 68 hundredths of ONE whole.',800,835,m('same'),33,COL.dim,'middle');}],
['q2','Choose six percent',()=>{const p=panel(0);pcTitle(p,'Match 0.06 of one whole','One square = 1 · a partial cell must have its true area');S.pcChoices=pcGridChoices(p,[6,60,.6]);},{ask:done=>quiz(BAND,[{id:'c-decimal',prompt:'Which picture equals the decimal 0.06?',build:pickEls(S.pcChoices,0,'0.06 is six hundredths, so it equals 6%. Six of the hundred cells are filled.',i=>i===1?'Sixty hundredths is 0.60, or 60%. That is ten times the asked share.':'0.6% is six tenths of ONE hundredth cell. Its decimal is 0.006, ten times smaller than 0.06.')}],done)}],
['back','Decimal to percent',m=>{const p=panel(0);pcTitle(p,'0.42 of one whole · forty-two hundredths');S.pcBack=pcBar(p,220,270,1120,42);pcMath(p,'0.42 × 100 = 42 → 42%',800,520,m('percent'),62,COL.whole);S.pcRightDot=pcMovePoint(p,'042',1,3,500,670,m('moves'),m('moves',.6),'out');pcText(p,'× 100 · two places RIGHT',690,670,m('moves'),34,COL.task);pcText(p,'0.07 = 7% 1.2 = 120%',800,770,m('moves',3),40);pcText(p,'Decimal and percent are names for the same ratio.',800,845,m('meaning'),31,COL.dim,'middle');}],
['partial','A percent with a decimal point',m=>{const p=panel(0);pcTitle(p,'2.5% means two and a half hundredths','Top strip: one whole = 100%');S.pcSmall=pcBar(p,260,250,1000,0);tw(S.pcSmall.shade,{'a_width':25},m('fill'),1.5,io);const inset=G(p,{o:0});S.pcInset=pcBar(inset,260,505,600,2.5,3,0,135);show(inset,m('zoom'));pcText(p,'ENLARGED: first three 1% cells',560,475,m('zoom'),28,COL.task,'middle');pcText(p,'Each inset cell = 1% of the whole',560,700,m('zoom',1),29,COL.dim,'middle');pcMath(p,'2.5% = 0.025',1160,550,m('convert'),47,COL.whole);pcMath(p,[F('2.5','100'),' = ',F('25','1000'),' = ',F('1','40')],1160,700,m('convert',2),49);pcText(p,'Divide by 100 even when the percent has a decimal point.',800,835,m('convert',4),32,COL.dim,'middle');}],
['tiny','A tiny percent',m=>{const p=panel(0);pcTitle(p,'0.004% · keep the leading zeros');pcMath(p,'0.004% = 0.004 ÷ 100 = 0.00004',800,300,m('convert'),58,COL.whole);const g=G(p,{o:0});path(g,'M260 555H1260',{stroke:COL.chalk,'stroke-width':3});for(let i=0;i<=5;i++){path(g,`M${260+i*200} 540V570`,{stroke:COL.dim,'stroke-width':2});T(g,(i*.002).toFixed(3)+'%',{x:260+i*200,y:620,size:26,anchor:'middle'});}S.pcTinyDot=mk('circle',{cx:660,cy:555,r:13,fill:COL.whole},g);S.pcTinyDot.dataset.percent='.004';T(g,'0.004%',{x:660,y:505,size:34,fill:COL.whole,anchor:'middle'});show(g,m('scale'));pcText(p,'MAGNIFIED SCALE: 0% to 0.01% only',800,430,m('scale'),32,COL.task,'middle');pcMath(p,['0.00004 = ',F('1','25000')],800,735,m('fraction'),54);pcText(p,'Below 1% means below 0.01 of a whole.',800,835,m('fraction',2),34,COL.dim,'middle');}],
['beyond','More than one hundred percent',m=>{const p=panel(0);pcTitle(p,'160% · one whole plus sixty hundredths','Every full strip is the same reference whole.');S.pcFull=pcBar(p,150,280,600,100);S.pcExtra=pcBar(p,850,280,600,60,100,m('extra'));pcText(p,'100%',450,450,0,40,COL.whole,'middle');pcText(p,'60%',1150,450,m('extra'),40,COL.whole,'middle');pcMath(p,['160% = ',F('160','100'),' = ',F('8','5'),' = 1',F('3','5'),' = 1.6'],800,620,m('names'),62);pcText(p,'1.6 kilometers is 160% of a 1-kilometer reference.',800,770,m('context'),33,COL.task,'middle');pcText(p,'100% identifies the reference whole; it is not always a maximum.',800,840,m('context',2),30,COL.dim,'middle');}],
['q3','Choose one hundred sixty percent',()=>{const p=panel(0);pcTitle(p,'Reference: one full strip = 100%','All strips use the same length scale.');pcBar(p,710,215,180,100,100,0,90);S.pcChoices=[160,16,60].map((n,i)=>{const x=[170,710,1150][i],g=G(p),w=n>100?380:180;pcBar(g,x,420,180,Math.min(n,100),100,0,90);if(n>100)pcBar(g,x+200,420,180,n-100,100,0,90);pcText(g,String.fromCharCode(65+i),x+w/2,385,0,32,COL.dim,'middle');g.dataset.percent=String(n);return {el:g,box:[x-20,345,w+40,190],label:n+' percent'};});},{ask:done=>quiz(BAND,[{id:'c-beyond',prompt:'Which picture represents 160% of the reference whole?',build:pickEls(S.pcChoices,0,'160% is 1.6 wholes: one complete strip plus sixty hundredths of another equal strip.',i=>i===1?'0.16 of a whole is 16%. Divide 160 by 100 to get 1.6, not 0.16.':'0.6 of a whole is only 60%. Include the complete first whole as well.')}],done)}],
['context','Observed shares',m=>{const p=panel(0);pcTitle(p,'9 of 12 seeds sprouted','One strip = all 12 seeds · blue = sprouted');S.pcSeeds=pcBar(p,200,280,1200,9,12);pcCuts(S.pcSeeds,4,m('groups'));pcMath(p,[F('9','12'),' = ',F('3','4'),' = ',F('75','100'),' = 75%'],800,565,m('hundred'),61,COL.whole);pcMath(p,[F('3','12'),' = ',F('1','4'),' = 25%'],800,710,m('rest'),53);pcText(p,'Sprouted 75% + not sprouted 25% = 100%',800,830,m('rest',2),37,COL.task,'middle');}],
['rounding','Rounding a percent',m=>{const p=panel(0);pcTitle(p,'5 of 9 sketches use watercolors','Exact share: five ninths · round only the final percent');S.pcRound=pcBar(p,220,230,900,5,9,0,100);pcMath(p,[F('5','9'),' = 0.',OV('5')],1290,295,m('decimal'),55);pcMath(p,['0.',OV('5'),' × 100 = 55.',OV('5'),' → 55.',OV('5'),'%'],800,665,m('percent'),54);const guide=G(p,{o:0});path(guide,'M724 215V345',{stroke:COL.task,'stroke-width':3});mk('rect',{x:706,y:230,width:36,height:100,fill:'none',stroke:COL.task,'stroke-width':2},guide);path(guide,'M706 330L484 420M742 330L964 420',{stroke:COL.task,'stroke-width':2,'stroke-opacity':.6});S.pcRoundInset=pcBar(guide,484,420,480,14/9,4,0,100);path(guide,'M724 405V535',{stroke:COL.task,'stroke-width':4});for(let i=0;i<=4;i++)T(guide,(54+i)+'%',{x:484+i*120,y:572,size:26,fill:i===2?COL.task:COL.dim,anchor:'middle'});show(guide,m('round'));S.pcRoundGuide=guide;pcMath(p,'≈ 56% (nearest whole percent)',800,755,m('round'),50,COL.task);pcText(p,'Exact blue endpoint: 55.555…% · rounded guide: 56%',800,840,m('round',2),32,COL.dim,'middle');}],
['wrap','Four percent connections',m=>{const p=panel(0);pcTitle(p,'Three forms · one amount');[['Percent means per hundred. First identify ONE whole.','w1'],['Percent as a fraction: number over 100; simplify.','w2'],['Percent ÷ 100 = decimal. Decimal × 100 = percent number.','w3'],['Fraction: divide top by bottom. Round only when asked.','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-from',prompt:'Convert. Fractions must be in lowest terms; decimals exact.',build:blanks([
{parts:['32% = ',{box:'8/25',lowest:true},' (fraction)'],why:'32/100 simplifies by dividing numerator and denominator by 4: 8/25.'},
{parts:['180% = ',{box:'9/5',lowest:true},' (fraction)'],why:'180/100 = 9/5 = 1 4/5. Values above 100% are greater than one whole.'},
{parts:['7.2% = ',{box:'0.072'},' (decimal)'],why:'7.2 ÷ 100 = 0.072. The decimal point moves two places left.'},
{parts:['0.006% = ',{box:'0.00006'},' (decimal)'],why:'0.006 ÷ 100 = 0.00006. Keep the leading zeros.'}
])}],done,'Chapter practice · set 1 of 3')}],
['final2','Chapter practice',()=>panel(0),{ask:done=>quiz(SCREEN,[{id:'p-to',prompt:'Write each as a percent. Type the number before the printed % sign.',build:blanks([
{parts:[F('7','20'),' = ',{box:'35'},'%'],why:'7/20 = 35/100 = 35%.'},
{parts:[F('7','16'),' = ',{box:'43.75'},'%'],why:'7 ÷ 16 = 0.4375; multiply by 100 to get 43.75%.'},
{parts:['0.009 = ',{box:'0.9'},'%'],why:'0.009 × 100 = 0.9, so the percent is 0.9%.'},
{parts:['1.35 = ',{box:'135'},'%'],why:'1.35 × 100 = 135, so it is 135% of the reference whole.'}
])}],done,'Chapter practice · set 2 of 3')}],
['final3','Chapter practice',()=>panel(0),{ask:done=>quiz(SCREEN,[{id:'p-shares',prompt:'Describe each share. Only the vote question asks for rounding.',build:blanks([
{parts:['12 of 15 puzzles solved: ',{box:'80'},'% solved'],why:'12/15 = 4/5 = 0.8 = 80%.'},
{parts:['14 of 20 tiles blue: ',{box:'30'},'% NOT blue'],why:'20 − 14 = 6 tiles are not blue; 6/20 = 0.3 = 30%.'},
{parts:['4 of 7 votes: ≈ ',{box:'57'},'% (nearest whole percent)'],why:'4/7 × 100 = 57.142857…; nearest whole percent is approximately 57%.'},
{parts:['1.5% = ',{box:'3/200',lowest:true},' of a whole (lowest terms)'],why:'1.5/100 = 15/1000 = 3/200. A decimal percent is still per hundred.'}
])}],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>