UNPKG

@typecad/typecad

Version:

🤖programmatically 💥create 🛰️hardware

1 lines 7.87 kB
import{generateUuid}from'./pcb_utils';import a12_0x4a8c19 from'chalk';import a12_0xe0ec52 from'node:fs';export function pcbLine(_0x41ef52,_0x162c53){function _0x205ffb(_0x44ae39,_0x44f0ba){return a12_0x2a2b(_0x44ae39-0x352,_0x44f0ba);}const {start:_0xb83e24,end:_0x25f0a9,layer:layer='F.SilkS',width:width=0.15,locked:locked=![]}=_0x162c53,_0x4bc41a={'type':'line','uuid':generateUuid(),'layer':layer,'strokeWidth':width,'start':_0xb83e24,'end':_0x25f0a9,'locked':locked};_0x41ef52[_0x205ffb(0x352,0x358)]['push'](_0x4bc41a);}export function pcbCircle(_0x115c64,_0xebeee5){const {center:_0x74af0a,radius:_0x11f07b,end:_0x3a47db,layer:layer='F.SilkS',width:width=0.15,fill:fill=![],locked:locked=![]}=_0xebeee5;let _0x3654f0;function _0x172ead(_0x3fcb04,_0x4f6761){return a12_0x2a2b(_0x3fcb04- -0x7d,_0x4f6761);}if(_0x11f07b!==undefined)_0x3654f0={'x':_0x74af0a['x']+_0x11f07b,'y':_0x74af0a['y']};else{if(_0x3a47db!==undefined)_0x3654f0=_0x3a47db;else{const _0x2a292e=_0x115c64[_0x172ead(-0x7c,-0x7a)](),_0x47e3b5=_0x2a292e?_0x172ead(-0x7b,-0x81)+_0x2a292e['file']+':'+_0x2a292e['line']+')':'';console['error'](a12_0x4a8c19[_0x172ead(-0x7a,-0x7e)]('[PCB\x20CIRCLE]\x20ERROR:\x20Must\x20provide\x20either\x20\x27radius\x27\x20or\x20\x27end\x27\x20parameter'+_0x47e3b5));return;}}const _0x1e35df={'type':'circle','uuid':generateUuid(),'layer':layer,'strokeWidth':width,'center':_0x74af0a,'end':_0x3654f0,'fill':fill,'locked':locked};_0x115c64['grCircles'][_0x172ead(-0x79,-0x72)](_0x1e35df);}export function pcbRect(_0x21241a,_0x7f9db4){const {x:_0x1b800f,y:_0x3ea4a7,width:_0x362a9a,height:_0xa44a30,start:_0x4c4f3c,end:_0x18987d,layer:layer=_0x26f9ea(0x3a6,0x3a0),strokeWidth:strokeWidth=0.15,fill:fill=![],locked:locked=![]}=_0x7f9db4;let _0x57f0e5,_0x46db21;if(_0x4c4f3c!==undefined&&_0x18987d!==undefined)_0x57f0e5=_0x4c4f3c,_0x46db21=_0x18987d;else{if(_0x1b800f!==undefined&&_0x3ea4a7!==undefined&&_0x362a9a!==undefined&&_0xa44a30!==undefined)_0x57f0e5={'x':_0x1b800f,'y':_0x3ea4a7},_0x46db21={'x':_0x1b800f+_0x362a9a,'y':_0x3ea4a7+_0xa44a30};else{const _0x25dccd=_0x21241a['getCallSite'](),_0x24c443=_0x25dccd?'\x20(called\x20from\x20'+_0x25dccd['file']+':'+_0x25dccd['line']+')':'';console[_0x26f9ea(0x39c,0x3a1)](a12_0x4a8c19['red']('[PCB\x20RECT]\x20ERROR:\x20Must\x20provide\x20either\x20(x,\x20y,\x20width,\x20height)\x20or\x20(start,\x20end)\x20parameters'+_0x24c443));return;}}const _0x3da5de={'type':_0x26f9ea(0x39e,0x3a2),'uuid':generateUuid(),'layer':layer,'strokeWidth':strokeWidth,'start':_0x57f0e5,'end':_0x46db21,'fill':fill,'locked':locked};function _0x26f9ea(_0x1cbb1e,_0x456d7b){return a12_0x2a2b(_0x456d7b-0x39b,_0x1cbb1e);}_0x21241a['grRects']['push'](_0x3da5de);}export function pcbPoly(_0x135883,_0x2fc588){const {points:_0x16eb19,layer:layer='F.SilkS',width:width=0.15,fill:fill=![],locked:locked=![]}=_0x2fc588;function _0x2db484(_0x1586b0,_0x381a6f){return a12_0x2a2b(_0x1586b0-0x229,_0x381a6f);}if(!_0x16eb19||_0x16eb19['length']<0x3){const _0x457194=_0x135883[_0x2db484(0x22a,0x224)](),_0x1f4d2a=_0x457194?'\x20(called\x20from\x20'+_0x457194[_0x2db484(0x231,0x22e)]+':'+_0x457194['line']+')':'';console['error'](a12_0x4a8c19['red']('[PCB\x20POLY]\x20ERROR:\x20Polygon\x20must\x20have\x20at\x20least\x203\x20points'+_0x1f4d2a));return;}const _0x331baf={'type':'poly','uuid':generateUuid(),'layer':layer,'strokeWidth':width,'points':_0x16eb19,'fill':fill,'locked':locked};_0x135883['grPolys'][_0x2db484(0x22d,0x228)](_0x331baf);}function a12_0x3118(){const _0x4aa463=['grLines','getCallSite','\x20(called\x20from\x20','red','push','F.SilkS','error','rect','file','readFileSync','utf8','line','match','cos','sin'];a12_0x3118=function(){return _0x4aa463;};return a12_0x3118();}function a12_0x2a2b(_0x3118af,_0x2a2b0b){const _0x9cfa=a12_0x3118();return a12_0x2a2b=function(_0xdc82f6,_0x25e14c){_0xdc82f6=_0xdc82f6-0x0;let _0x6763e8=_0x9cfa[_0xdc82f6];return _0x6763e8;},a12_0x2a2b(_0x3118af,_0x2a2b0b);}export function pcbOutline(_0x159c41,_0xbbfba0,_0x124c51,_0x10e7a9,_0x3ea9fe,_0x1507a2=0x0,_0x1edcf1){const _0x294051=_0x159c41[_0x4105f3(-0x127,-0x126)]();let _0x449590=_0x294051?{'file':_0x294051['file'],'line':_0x294051['line'],'column':_0x294051['column']}:undefined;if(_0x294051&&_0x449590)try{const _0x555fe8=a12_0xe0ec52[_0x4105f3(-0x11f,-0x125)](_0x294051['file'],_0x4105f3(-0x11e,-0x11b)),_0x4b0706=_0x555fe8['split']('\x0a'),_0x4a9f80=_0x4b0706[_0x294051[_0x4105f3(-0x11d,-0x11d)]-0x1],_0x590f8a=_0x4a9f80[_0x4105f3(-0x11c,-0x11a)](/^\s*(?:(const|let|var)\s+(\w+)\s*=\s*)?(\w+)\.outline\s*\(\s*(.+?)\s*\)\s*;?\s*$/);_0x590f8a&&(_0x590f8a[0x2]&&(_0x449590['variable']=_0x590f8a[0x2]),_0x449590['params']={'x':_0xbbfba0,'y':_0x124c51,'width':_0x10e7a9,'height':_0x3ea9fe,'filletRadius':_0x1507a2,..._0x1edcf1?{'conceptualUuidFromUser':_0x1edcf1}:{}});}catch(_0x122b70){}const _0x25e17d=_0x1edcf1||generateUuid(),_0x4ac063=[],_0x5d527e=0.05,_0x2f1346='Edge.Cuts',_0x567be9=()=>{return generateUuid();},_0x124800=Math['max'](0x0,_0x1507a2),_0x16af45=_0xbbfba0,_0x20a8fe=_0x124c51,_0x44884f=_0xbbfba0+_0x10e7a9,_0x32d44e=_0x124c51+_0x3ea9fe,_0xf6ae90={'x':_0x16af45+_0x124800,'y':_0x20a8fe};function _0x4105f3(_0x579abe,_0xaedc15){return a12_0x2a2b(_0x579abe- -0x128,_0xaedc15);}const _0x23f15c={'x':_0x44884f-_0x124800,'y':_0x20a8fe},_0x260683={'x':_0x44884f,'y':_0x20a8fe+_0x124800},_0x2a2090={'x':_0x44884f,'y':_0x32d44e-_0x124800},_0x5c3a7b={'x':_0x44884f-_0x124800,'y':_0x32d44e},_0x557271={'x':_0x16af45+_0x124800,'y':_0x32d44e},_0x25b25c={'x':_0x16af45,'y':_0x32d44e-_0x124800},_0x32ffdb={'x':_0x16af45,'y':_0x20a8fe+_0x124800};_0xf6ae90['x']<_0x23f15c['x']&&_0x4ac063[_0x4105f3(-0x124,-0x128)]({'type':'line','uuid':_0x567be9(),'layer':_0x2f1346,'strokeWidth':_0x5d527e,'start':_0xf6ae90,'end':_0x23f15c,'locked':![]});_0x260683['y']<_0x2a2090['y']&&_0x4ac063['push']({'type':'line','uuid':_0x567be9(),'layer':_0x2f1346,'strokeWidth':_0x5d527e,'start':_0x260683,'end':_0x2a2090,'locked':![]});_0x557271['x']<_0x5c3a7b['x']&&_0x4ac063['push']({'type':'line','uuid':_0x567be9(),'layer':_0x2f1346,'strokeWidth':_0x5d527e,'start':_0x5c3a7b,'end':_0x557271,'locked':![]});_0x32ffdb['y']<_0x25b25c['y']&&_0x4ac063['push']({'type':'line','uuid':_0x567be9(),'layer':_0x2f1346,'strokeWidth':_0x5d527e,'start':_0x25b25c,'end':_0x32ffdb,'locked':![]});if(_0x124800>0x0){const _0x644e73={'x':_0x44884f-_0x124800,'y':_0x20a8fe+_0x124800},_0x5a0139={'x':_0x44884f-_0x124800,'y':_0x32d44e-_0x124800},_0x23a4c8={'x':_0x16af45+_0x124800,'y':_0x32d44e-_0x124800},_0x4c748f={'x':_0x16af45+_0x124800,'y':_0x20a8fe+_0x124800};_0x4ac063[_0x4105f3(-0x124,-0x121)]({'type':'arc','uuid':_0x567be9(),'layer':_0x2f1346,'strokeWidth':_0x5d527e,'start':_0x23f15c,'mid':{'x':_0x644e73['x']+_0x124800*Math['cos'](Math['PI']*1.75),'y':_0x644e73['y']+_0x124800*Math['sin'](Math['PI']*1.75)},'end':_0x260683}),_0x4ac063['push']({'type':'arc','uuid':_0x567be9(),'layer':_0x2f1346,'strokeWidth':_0x5d527e,'start':_0x2a2090,'mid':{'x':_0x5a0139['x']+_0x124800*Math['cos'](Math['PI']*0.25),'y':_0x5a0139['y']+_0x124800*Math['sin'](Math['PI']*0.25)},'end':_0x5c3a7b}),_0x4ac063['push']({'type':'arc','uuid':_0x567be9(),'layer':_0x2f1346,'strokeWidth':_0x5d527e,'start':_0x557271,'mid':{'x':_0x23a4c8['x']+_0x124800*Math[_0x4105f3(-0x11b,-0x118)](Math['PI']*0.75),'y':_0x23a4c8['y']+_0x124800*Math['sin'](Math['PI']*0.75)},'end':_0x25b25c}),_0x4ac063['push']({'type':'arc','uuid':_0x567be9(),'layer':_0x2f1346,'strokeWidth':_0x5d527e,'start':_0x32ffdb,'mid':{'x':_0x4c748f['x']+_0x124800*Math[_0x4105f3(-0x11b,-0x114)](Math['PI']*1.25),'y':_0x4c748f['y']+_0x124800*Math[_0x4105f3(-0x11a,-0x112)](Math['PI']*1.25)},'end':_0xf6ae90});}const _0x4383cc={'uuid':_0x25e17d,'x':_0xbbfba0,'y':_0x124c51,'width':_0x10e7a9,'height':_0x3ea9fe,'filletRadius':_0x124800,'elements':_0x4ac063,'sourceInfo':_0x449590};_0x159c41['stagedOutlines'][_0x4105f3(-0x124,-0x127)](_0x4383cc);}