MCPcopy Create free account
hub / github.com/openscopeproject/InteractiveHtmlBom / netHitScan

Function netHitScan

InteractiveHtmlBom/web/render.js:759–785  ·  view source on GitHub ↗
(layer, x, y)

Source from the content-addressed store, hash-verified

757}
758
759function netHitScan(layer, x, y) {
760 // Check track segments
761 if (settings.renderTracks && pcbdata.tracks) {
762 for (var track of pcbdata.tracks[layer]) {
763 if ('radius' in track) {
764 if (pointWithinDistanceToArc(x, y, ...track.center, track.radius, track.startangle, track.endangle, track.width / 2)) {
765 return track.net;
766 }
767 } else {
768 if (pointWithinDistanceToSegment(x, y, ...track.start, ...track.end, track.width / 2)) {
769 return track.net;
770 }
771 }
772 }
773 }
774 // Check pads
775 if (settings.renderPads) {
776 for (var footprint of pcbdata.footprints) {
777 for (var pad of footprint.pads) {
778 if (pad.layers.includes(layer) && pointWithinPad(x, y, pad)) {
779 return pad.net;
780 }
781 }
782 }
783 }
784 return null;
785}
786
787function pointWithinFootprintBbox(x, y, bbox) {
788 var v = [x - bbox.pos[0], y - bbox.pos[1]];

Callers 1

handleMouseClickFunction · 0.85

Calls 3

pointWithinDistanceToArcFunction · 0.85
pointWithinPadFunction · 0.85

Tested by

no test coverage detected