← Natura·Docs/Modules/Source

laws/blackbody-swatch.html

19 lines · in natura-src-1.0.0.zip as natura/laws/blackbody-swatch.html · a bench page for a laws module

<!doctype html>
<html><head><meta charset="utf-8"><title>blackbody locus swatch</title>
<style>body{margin:0;background:#111;color:#ccc;font:13px system-ui}h2{margin:14px 16px 4px}canvas{display:block;margin:0 16px}
.marks{margin:4px 16px;color:#888;font-size:12px;display:flex;justify-content:space-between;max-width:900px}</style>
</head><body>
<h2>the colour of heat &mdash; black-body temperature sweep 1000K &rarr; 15000K (the Planckian locus)</h2>
<canvas id="bb" width="900" height="80"></canvas>
<div class="marks"><span>1000K ember</span><span>2700K bulb</span><span>5800K sun</span><span>6500K</span><span>10000K</span><span>15000K star</span></div>
<script src="interference-colour.js"></script>
<script src="blackbody.js"></script>
<script>
const BB = window.NaturaLaws.blackbody;
const cv=document.getElementById('bb'), ctx=cv.getContext('2d'), W=cv.width, H=cv.height;
const Tmin=1000, Tmax=15000;
for(let x=0;x<W;x++){ const T=Tmin+(x/W)*(Tmax-Tmin); const c=BB.colourOf(T);
  ctx.fillStyle='rgb('+c[0]+','+c[1]+','+c[2]+')'; ctx.fillRect(x,0,1,H); }
window.__swatch={ ready:true, ember:BB.colourOf(1200), sun:BB.colourOf(5800), star:BB.colourOf(20000) };
</script>
</body></html>