← Natura·Docs/Modules/Source

laws/interference-colour-swatch.html

21 lines · in natura-src-1.0.0.zip as natura/laws/interference-colour-swatch.html · a bench page for a laws module

<!doctype html>
<html><head><meta charset="utf-8"><title>interference-colour 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}</style>
</head><body>
<h2>thin film (reflected) &mdash; thickness sweep, n=1.33 &nbsp; [black film -&gt; grey/white -&gt; straw -&gt; red/magenta -&gt; blue -&gt; green -&gt; higher-order pastels]</h2>
<canvas id="film" width="900" height="70"></canvas>
<h2>birefringence (crossed polars) &mdash; Michel-L&eacute;vy retardation sweep &nbsp; [0=black, ~551nm sensitive-tint magenta]</h2>
<canvas id="biref" width="900" height="70"></canvas>
<script src="interference-colour.js"></script>
<script>
const IC = window.NaturaLaws.interferenceColour;
function strip(id, maxV, fn){
  const cv=document.getElementById(id), ctx=cv.getContext('2d'), W=cv.width, H=cv.height;
  for(let x=0;x<W;x++){ const v = (x/W)*maxV; const c = fn(v);
    ctx.fillStyle='rgb('+c[0]+','+c[1]+','+c[2]+')'; ctx.fillRect(x,0,1,H); }
}
strip('film', 1400, d => IC.thinFilm({d:d, n:1.33}));         // thickness 0..1400nm
strip('biref', 1800, g => IC.birefringence({retardation:g})); // retardation 0..1800nm
window.__swatch = { ready:true, tintAt551: IC.birefringence({retardation:551}), blackFilm: IC.thinFilm({d:0}) };
</script>
</body></html>