← Commit history

cross-highlight symbol + footprint viewers

Ray ·6767a74e46 ·2mo ago ·parent 9bad1ba
2 files changed +130
viewers/footprint.htmladded+65
@@ -0,0 +1,65 @@+<!doctype html><html lang=en><head><meta charset=utf-8>+<meta name=viewport content="width=device-width,initial-scale=1"><title>WS2812B footprint</title>+<style>+:root{--bg:#0d1117;--panel:#161b22;--edge:#30363d;--ink:#e6edf3;--mut:#8b949e;--acc:#00b8b0;--accb:#00e6dc;--hi:#6ea8fe}+*{box-sizing:border-box;margin:0}html,body{height:100%}+body{background:var(--bg);color:var(--ink);font-family:'Satoshi',system-ui,sans-serif;display:flex;flex-direction:column}+.bar{display:flex;flex-wrap:wrap;align-items:center;gap:8px;padding:8px 11px;border-bottom:1px solid var(--edge);flex:none}+.bar .h{font-size:11px;text-transform:uppercase;letter-spacing:.06em;color:var(--mut);font-weight:700}+.bar .sp{flex:1}+.lyrtog{display:inline-flex;align-items:center;gap:6px;font-size:11px;color:var(--mut);background:#1a2130;border:1px solid var(--edge);border-radius:999px;padding:3px 9px;cursor:pointer;user-select:none}+.lyrtog.on{color:var(--ink);border-color:#485162}.lyrtog:not(.on){opacity:.5}+.lyrtog .d{width:8px;height:8px;border-radius:50%;background:#485162}+.stage{flex:1;min-height:0;position:relative;overflow:hidden;background:var(--bg);cursor:grab;touch-action:none}+.stage.drag{cursor:grabbing}+.stage svg{position:absolute;inset:0;width:100%;height:100%}+.pingroup,.pad{cursor:pointer}+.pingroup.hi .pinvis{stroke:var(--hi)!important;stroke-width:7}+rect.pad.hi{stroke:var(--hi);stroke-width:.15;paint-order:stroke}+.lyr-off{display:none}+#tip{position:fixed;z-index:99;pointer-events:none;display:none;max-width:250px;background:#0d1117;border:1px solid var(--acc);border-radius:8px;padding:7px 10px;box-shadow:0 8px 26px #000a}+#tip .tn{font:700 12px ui-monospace,monospace;color:var(--accb)}+#tip .tt{font-size:10px;text-transform:uppercase;letter-spacing:.04em;color:var(--mut);margin-top:1px}+#tip .td{font-size:11px;color:var(--ink);margin-top:5px;line-height:1.4}+</style></head><body>+<div class=bar><span class=h>PCB footprint</span><span class=sp></span><button class="lyrtog on" data-lyr="copper"><span class="d" style="background:#e35d5d"></span>Copper</button><button class="lyrtog on" data-lyr="silk"><span class="d" style="background:#e6edf3"></span>Silkscreen</button><button class="lyrtog" data-lyr="fab"><span class="d" style="background:#8b949e"></span>Fab</button><button class="lyrtog" data-lyr="courtyard"><span class="d" style="background:#bc8cff"></span>Courtyard</button></div>+<div class=stage id=stage><svg xmlns='http://www.w3.org/2000/svg' viewBox='-3.900 -3.150 7.800 6.300' style='width:100%;height:100%'><line class='ly-silk' x1='-3.500' y1='-2.750' x2='-3.500' y2='2.750' stroke='#d8b4fe' stroke-width='0.120'/><line class='ly-silk' x1='-3.500' y1='-2.750' x2='3.500' y2='-2.750' stroke='#d8b4fe' stroke-width='0.120'/><line class='ly-silk' x1='-3.500' y1='2.750' x2='3.050' y2='2.750' stroke='#d8b4fe' stroke-width='0.120'/><line class='ly-silk' x1='-2.700' y1='0.900' x2='-2.700' y2='-0.900' stroke='#d8b4fe' stroke-width='0.120'/><line class='ly-silk' x1='2.700' y1='0.900' x2='2.700' y2='-0.900' stroke='#d8b4fe' stroke-width='0.120'/><line class='ly-silk' x1='3.050' y1='2.750' x2='3.500' y2='2.300' stroke='#d8b4fe' stroke-width='0.120'/><line class='ly-silk' x1='3.500' y1='2.300' x2='3.500' y2='-2.750' stroke='#d8b4fe' stroke-width='0.120'/><line class='ly-courtyard' x1='-3.450' y1='-2.750' x2='-3.450' y2='2.750' stroke='#4ade80' stroke-width='0.050'/><line class='ly-courtyard' x1='-3.450' y1='2.750' x2='3.450' y2='2.750' stroke='#4ade80' stroke-width='0.050'/><line class='ly-courtyard' x1='3.450' y1='-2.750' x2='-3.450' y2='-2.750' stroke='#4ade80' stroke-width='0.050'/><line class='ly-courtyard' x1='3.450' y1='2.750' x2='3.450' y2='-2.750' stroke='#4ade80' stroke-width='0.050'/><line class='ly-fab' x1='-2.500' y1='-2.500' x2='-2.500' y2='2.500' stroke='#f472b6' stroke-width='0.100'/><line class='ly-fab' x1='-2.500' y1='2.500' x2='2.500' y2='2.500' stroke='#f472b6' stroke-width='0.100'/><line class='ly-fab' x1='2.500' y1='-2.500' x2='-2.500' y2='-2.500' stroke='#f472b6' stroke-width='0.100'/><line class='ly-fab' x1='2.500' y1='1.500' x2='1.500' y2='2.500' stroke='#f472b6' stroke-width='0.100'/><line class='ly-fab' x1='2.500' y1='2.500' x2='2.500' y2='-2.500' stroke='#f472b6' stroke-width='0.100'/><circle class='ly-fab' cx='0.000' cy='0.000' r='2.000' fill='none' stroke='#f472b6' stroke-width='0.100'/><rect class='ly-copper pad' data-num='1' data-name='VDD' x='-3.200' y='-2.100' width='1.500' height='0.900' rx='0.225' fill='#f59e0b' stroke='#00000033' stroke-width='0.03' opacity='0.94'/><text class='padnum' x='-2.450' y='-1.650' font-size='0.540' fill='#1c1206' text-anchor='middle' dominant-baseline='central' pointer-events='none' font-family='ui-monospace,monospace' font-weight='700'>1</text><rect class='ly-copper pad' data-num='2' data-name='DOUT' x='-3.200' y='1.200' width='1.500' height='0.900' rx='0.225' fill='#f59e0b' stroke='#00000033' stroke-width='0.03' opacity='0.94'/><text class='padnum' x='-2.450' y='1.650' font-size='0.540' fill='#1c1206' text-anchor='middle' dominant-baseline='central' pointer-events='none' font-family='ui-monospace,monospace' font-weight='700'>2</text><rect class='ly-copper pad' data-num='3' data-name='VSS' x='1.700' y='1.200' width='1.500' height='0.900' rx='0.225' fill='#f59e0b' stroke='#00000033' stroke-width='0.03' opacity='0.94'/><text class='padnum' x='2.450' y='1.650' font-size='0.540' fill='#1c1206' text-anchor='middle' dominant-baseline='central' pointer-events='none' font-family='ui-monospace,monospace' font-weight='700'>3</text><rect class='ly-copper pad' data-num='4' data-name='DIN' x='1.700' y='-2.100' width='1.500' height='0.900' rx='0.225' fill='#f59e0b' stroke='#00000033' stroke-width='0.03' opacity='0.94'/><text class='padnum' x='2.450' y='-1.650' font-size='0.540' fill='#1c1206' text-anchor='middle' dominant-baseline='central' pointer-events='none' font-family='ui-monospace,monospace' font-weight='700'>4</text></svg></div>+<div id=tip></div>+<script>+var KIND="footprint", MPN="WS2812B", PINS=[{"desc":"Power supply for the internal controller and the RGB LED.","name":"VDD","number":"1","type":"Power"},{"desc":"Cascaded serial data output.","name":"DOUT","number":"2","type":"Output"},{"desc":"Ground reference (0 V) for the controller and the RGB LED drivers.","name":"VSS","number":"3","type":"Power"},{"desc":"Serial control-data input using a single-wire NZR protocol at 800 Kbps (bit period TH+TL = 1.25 us +/- 600 ns).","name":"DIN","number":"4","type":"Input"}];+var byNum={}; PINS.forEach(function(p){byNum[String(p.number)]=p;});+var stage=document.getElementById('stage'), svg=stage.querySelector('svg'), tip=document.getElementById('tip');+// ---- pan/zoom ----+var vb=(svg.getAttribute('viewBox')||'0 0 100 100').split(/\s+/).map(Number), base=vb.slice();+function setVB(){svg.setAttribute('viewBox',vb.join(' '));}+stage.addEventListener('wheel',function(e){e.preventDefault();var r=stage.getBoundingClientRect();var mx=(e.clientX-r.left)/r.width,my=(e.clientY-r.top)/r.height;var f=e.deltaY<0?0.88:1.14;var nw=vb[2]*f,nh=vb[3]*f;vb[0]+=(vb[2]-nw)*mx;vb[1]+=(vb[3]-nh)*my;vb[2]=nw;vb[3]=nh;setVB();},{passive:false});+var pan=null;+stage.addEventListener('pointerdown',function(e){pan={x:e.clientX,y:e.clientY};stage.classList.add('drag');stage.setPointerCapture(e.pointerId);});+stage.addEventListener('pointermove',function(e){if(!pan)return;var r=stage.getBoundingClientRect();vb[0]-=(e.clientX-pan.x)/r.width*vb[2];vb[1]-=(e.clientY-pan.y)/r.height*vb[3];pan={x:e.clientX,y:e.clientY};setVB();});+function endPan(){pan=null;stage.classList.remove('drag');}+stage.addEventListener('pointerup',endPan);stage.addEventListener('pointerleave',endPan);+stage.addEventListener('dblclick',function(){vb=base.slice();setVB();});+// ---- cross-highlight bus ----+function els(n){return [].slice.call(document.querySelectorAll('[data-num="'+n+'"]'));}+function clearHi(){[].slice.call(document.querySelectorAll('.hi')).forEach(function(e){e.classList.remove('hi');});}+function hi(n){els(n).forEach(function(e){e.classList.add('hi');});}+function post(n){try{parent.postMessage({type:'lbr-hover',pin:n===null?null:String(n),mpn:MPN},'*');}catch(_){}}+function showTip(n,x,y){var p=byNum[String(n)];if(!p)return;tip.innerHTML='<span class=tn></span><div class=tt></div><div class=td></div>';tip.querySelector('.tn').textContent=n+'  '+(p.name||'');tip.querySelector('.tt').textContent=p.type||'';var d=p.desc||'';if(d)tip.querySelector('.td').textContent=d;else tip.querySelector('.td').style.display='none';tip.style.display='block';tip.style.left=(x+14)+'px';tip.style.top=(y+12)+'px';}+[].slice.call(document.querySelectorAll('.pingroup,.pad')).forEach(function(g){+  var n=g.getAttribute('data-num');+  g.addEventListener('mouseenter',function(e){clearHi();hi(n);post(n);showTip(n,e.clientX,e.clientY);});+  g.addEventListener('mousemove',function(e){tip.style.left=(e.clientX+14)+'px';tip.style.top=(e.clientY+12)+'px';});+  g.addEventListener('mouseleave',function(){clearHi();post(null);tip.style.display='none';});+});+window.addEventListener('message',function(e){var d=e.data||{};if(d.type!=='lbr-hover')return;clearHi();if(d.pin!=null)hi(d.pin);});+// ---- footprint layer toggles ----+[].slice.call(document.querySelectorAll('.lyrtog')).forEach(function(b){+  function apply(on){[].slice.call(document.querySelectorAll('.ly-'+b.getAttribute('data-lyr'))).forEach(function(el){el.classList.toggle('lyr-off',!on);});}+  apply(b.classList.contains('on'));+  b.addEventListener('click',function(){apply(b.classList.toggle('on'));});+});+// ---- auto-grow the host readme iframe ----+function ph(){var h=Math.max(360,Math.min(16000,document.body.scrollHeight||420));parent.postMessage({type:'readme-height',height:h},'*');}+window.addEventListener('load',ph);setTimeout(ph,300);+</script>+</body></html>
viewers/symbol.htmladded+65
@@ -0,0 +1,65 @@+<!doctype html><html lang=en><head><meta charset=utf-8>+<meta name=viewport content="width=device-width,initial-scale=1"><title>WS2812B symbol</title>+<style>+:root{--bg:#0d1117;--panel:#161b22;--edge:#30363d;--ink:#e6edf3;--mut:#8b949e;--acc:#00b8b0;--accb:#00e6dc;--hi:#6ea8fe}+*{box-sizing:border-box;margin:0}html,body{height:100%}+body{background:var(--bg);color:var(--ink);font-family:'Satoshi',system-ui,sans-serif;display:flex;flex-direction:column}+.bar{display:flex;flex-wrap:wrap;align-items:center;gap:8px;padding:8px 11px;border-bottom:1px solid var(--edge);flex:none}+.bar .h{font-size:11px;text-transform:uppercase;letter-spacing:.06em;color:var(--mut);font-weight:700}+.bar .sp{flex:1}+.lyrtog{display:inline-flex;align-items:center;gap:6px;font-size:11px;color:var(--mut);background:#1a2130;border:1px solid var(--edge);border-radius:999px;padding:3px 9px;cursor:pointer;user-select:none}+.lyrtog.on{color:var(--ink);border-color:#485162}.lyrtog:not(.on){opacity:.5}+.lyrtog .d{width:8px;height:8px;border-radius:50%;background:#485162}+.stage{flex:1;min-height:0;position:relative;overflow:hidden;background:var(--bg);cursor:grab;touch-action:none}+.stage.drag{cursor:grabbing}+.stage svg{position:absolute;inset:0;width:100%;height:100%}+.pingroup,.pad{cursor:pointer}+.pingroup.hi .pinvis{stroke:var(--hi)!important;stroke-width:7}+rect.pad.hi{stroke:var(--hi);stroke-width:.15;paint-order:stroke}+.lyr-off{display:none}+#tip{position:fixed;z-index:99;pointer-events:none;display:none;max-width:250px;background:#0d1117;border:1px solid var(--acc);border-radius:8px;padding:7px 10px;box-shadow:0 8px 26px #000a}+#tip .tn{font:700 12px ui-monospace,monospace;color:var(--accb)}+#tip .tt{font-size:10px;text-transform:uppercase;letter-spacing:.04em;color:var(--mut);margin-top:1px}+#tip .td{font-size:11px;color:var(--ink);margin-top:5px;line-height:1.4}+</style></head><body>+<div class=bar><span class=h>Schematic symbol</span><span class=sp></span></div>+<div class=stage id=stage><svg xmlns='http://www.w3.org/2000/svg' viewBox='-350 -350 700 700' style='width:100%;height:100%'><polyline points='50.0,100.0 70.0,100.0' fill='none' stroke='#e35d5d' stroke-width='4'/><polyline points='50.0,140.0 70.0,140.0' fill='none' stroke='#e35d5d' stroke-width='4'/><polyline points='90.0,60.0 50.0,100.0 50.0,80.0' fill='none' stroke='#e35d5d' stroke-width='4'/><polyline points='90.0,100.0 50.0,140.0 50.0,120.0' fill='none' stroke='#e35d5d' stroke-width='4'/><polyline points='145.0,40.0 145.0,140.0 145.0,160.0' fill='none' stroke='#e35d5d' stroke-width='4'/><polyline points='185.0,60.0 105.0,60.0 145.0,140.0 185.0,60.0' fill='none' stroke='#e35d5d' stroke-width='4'/><polyline points='185.0,140.0 105.0,140.0' fill='none' stroke='#e35d5d' stroke-width='4'/><rect x='-200.0' y='-200.0' width='400.0' height='400.0' fill='#e35d5d22' stroke='#e35d5d' stroke-width='4'/><g class='pingroup' data-num='1' data-name='VDD'><line class='pinvis' x1='0.0' y1='-300.0' x2='0.0' y2='-200.0' stroke='#dfe4ec' stroke-width='4'/><line x1='0.0' y1='-300.0' x2='0.0' y2='-200.0' stroke='transparent' stroke-width='26' pointer-events='stroke'/></g><text x='-37.5' y='-250.0' font-size='50' fill='#9fb0c8' text-anchor='middle' dominant-baseline='central'>1</text><text x='0.0' y='-175.0' font-size='50' fill='#e6e9ef' text-anchor='middle' dominant-baseline='central'>VDD</text><g class='pingroup' data-num='2' data-name='DOUT'><line class='pinvis' x1='300.0' y1='-0.0' x2='200.0' y2='-0.0' stroke='#dfe4ec' stroke-width='4'/><line x1='300.0' y1='-0.0' x2='200.0' y2='-0.0' stroke='transparent' stroke-width='26' pointer-events='stroke'/></g><text x='250.0' y='-37.5' font-size='50' fill='#9fb0c8' text-anchor='middle' dominant-baseline='central'>2</text><text x='175.0' y='0.0' font-size='50' fill='#e6e9ef' text-anchor='end' dominant-baseline='central'>DOUT</text><g class='pingroup' data-num='3' data-name='VSS'><line class='pinvis' x1='0.0' y1='300.0' x2='0.0' y2='200.0' stroke='#dfe4ec' stroke-width='4'/><line x1='0.0' y1='300.0' x2='0.0' y2='200.0' stroke='transparent' stroke-width='26' pointer-events='stroke'/></g><text x='37.5' y='250.0' font-size='50' fill='#9fb0c8' text-anchor='middle' dominant-baseline='central'>3</text><text x='0.0' y='175.0' font-size='50' fill='#e6e9ef' text-anchor='middle' dominant-baseline='central'>VSS</text><g class='pingroup' data-num='4' data-name='DIN'><line class='pinvis' x1='-300.0' y1='-0.0' x2='-200.0' y2='-0.0' stroke='#dfe4ec' stroke-width='4'/><line x1='-300.0' y1='-0.0' x2='-200.0' y2='-0.0' stroke='transparent' stroke-width='26' pointer-events='stroke'/></g><text x='-250.0' y='37.5' font-size='50' fill='#9fb0c8' text-anchor='middle' dominant-baseline='central'>4</text><text x='-175.0' y='0.0' font-size='50' fill='#e6e9ef' text-anchor='start' dominant-baseline='central'>DIN</text></svg></div>+<div id=tip></div>+<script>+var KIND="symbol", MPN="WS2812B", PINS=[{"desc":"Power supply for the internal controller and the RGB LED.","name":"VDD","number":"1","type":"Power"},{"desc":"Cascaded serial data output.","name":"DOUT","number":"2","type":"Output"},{"desc":"Ground reference (0 V) for the controller and the RGB LED drivers.","name":"VSS","number":"3","type":"Power"},{"desc":"Serial control-data input using a single-wire NZR protocol at 800 Kbps (bit period TH+TL = 1.25 us +/- 600 ns).","name":"DIN","number":"4","type":"Input"}];+var byNum={}; PINS.forEach(function(p){byNum[String(p.number)]=p;});+var stage=document.getElementById('stage'), svg=stage.querySelector('svg'), tip=document.getElementById('tip');+// ---- pan/zoom ----+var vb=(svg.getAttribute('viewBox')||'0 0 100 100').split(/\s+/).map(Number), base=vb.slice();+function setVB(){svg.setAttribute('viewBox',vb.join(' '));}+stage.addEventListener('wheel',function(e){e.preventDefault();var r=stage.getBoundingClientRect();var mx=(e.clientX-r.left)/r.width,my=(e.clientY-r.top)/r.height;var f=e.deltaY<0?0.88:1.14;var nw=vb[2]*f,nh=vb[3]*f;vb[0]+=(vb[2]-nw)*mx;vb[1]+=(vb[3]-nh)*my;vb[2]=nw;vb[3]=nh;setVB();},{passive:false});+var pan=null;+stage.addEventListener('pointerdown',function(e){pan={x:e.clientX,y:e.clientY};stage.classList.add('drag');stage.setPointerCapture(e.pointerId);});+stage.addEventListener('pointermove',function(e){if(!pan)return;var r=stage.getBoundingClientRect();vb[0]-=(e.clientX-pan.x)/r.width*vb[2];vb[1]-=(e.clientY-pan.y)/r.height*vb[3];pan={x:e.clientX,y:e.clientY};setVB();});+function endPan(){pan=null;stage.classList.remove('drag');}+stage.addEventListener('pointerup',endPan);stage.addEventListener('pointerleave',endPan);+stage.addEventListener('dblclick',function(){vb=base.slice();setVB();});+// ---- cross-highlight bus ----+function els(n){return [].slice.call(document.querySelectorAll('[data-num="'+n+'"]'));}+function clearHi(){[].slice.call(document.querySelectorAll('.hi')).forEach(function(e){e.classList.remove('hi');});}+function hi(n){els(n).forEach(function(e){e.classList.add('hi');});}+function post(n){try{parent.postMessage({type:'lbr-hover',pin:n===null?null:String(n),mpn:MPN},'*');}catch(_){}}+function showTip(n,x,y){var p=byNum[String(n)];if(!p)return;tip.innerHTML='<span class=tn></span><div class=tt></div><div class=td></div>';tip.querySelector('.tn').textContent=n+'  '+(p.name||'');tip.querySelector('.tt').textContent=p.type||'';var d=p.desc||'';if(d)tip.querySelector('.td').textContent=d;else tip.querySelector('.td').style.display='none';tip.style.display='block';tip.style.left=(x+14)+'px';tip.style.top=(y+12)+'px';}+[].slice.call(document.querySelectorAll('.pingroup,.pad')).forEach(function(g){+  var n=g.getAttribute('data-num');+  g.addEventListener('mouseenter',function(e){clearHi();hi(n);post(n);showTip(n,e.clientX,e.clientY);});+  g.addEventListener('mousemove',function(e){tip.style.left=(e.clientX+14)+'px';tip.style.top=(e.clientY+12)+'px';});+  g.addEventListener('mouseleave',function(){clearHi();post(null);tip.style.display='none';});+});+window.addEventListener('message',function(e){var d=e.data||{};if(d.type!=='lbr-hover')return;clearHi();if(d.pin!=null)hi(d.pin);});+// ---- footprint layer toggles ----+[].slice.call(document.querySelectorAll('.lyrtog')).forEach(function(b){+  function apply(on){[].slice.call(document.querySelectorAll('.ly-'+b.getAttribute('data-lyr'))).forEach(function(el){el.classList.toggle('lyr-off',!on);});}+  apply(b.classList.contains('on'));+  b.addEventListener('click',function(){apply(b.classList.toggle('on'));});+});+// ---- auto-grow the host readme iframe ----+function ph(){var h=Math.max(360,Math.min(16000,document.body.scrollHeight||420));parent.postMessage({type:'readme-height',height:h},'*');}+window.addEventListener('load',ph);setTimeout(ph,300);+</script>+</body></html>