gerber-to-svg
Advanced tools
Comparing version 0.0.9 to 0.0.10
@@ -1112,3 +1112,3 @@ !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.gerberToSvg=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
},{"./unique-id":9}],7:[function(require,module,exports){ | ||
var Macro, Parser, Plotter, parseAD, tool, unique; | ||
var HALF_PI, Macro, Parser, Plotter, THREEHALF_PI, TWO_PI, parseAD, rectangleStrokePath, tool, unique; | ||
@@ -1123,2 +1123,8 @@ Parser = require('./gerber-parser'); | ||
HALF_PI = Math.PI / 2; | ||
THREEHALF_PI = 3 * HALF_PI; | ||
TWO_PI = 2 * Math.PI; | ||
parseAD = function(block) { | ||
@@ -1230,2 +1236,24 @@ var ad, am, code, def, mods, name, params, _ref, _ref1, _ref2; | ||
rectangleStrokePath = function(start, end, width, height) { | ||
var exm, exp, eym, eyp, sxm, sxp, sym, syp, theta; | ||
sxm = start.x - width / 2; | ||
sxp = start.x + width / 2; | ||
sym = start.y - height / 2; | ||
syp = start.y + height / 2; | ||
exm = end.x - width / 2; | ||
exp = end.x + width / 2; | ||
eym = end.y - height / 2; | ||
eyp = end.y + height / 2; | ||
theta = Math.atan2(end.y - start.y, end.x - start.x); | ||
if ((0 <= theta && theta < HALF_PI)) { | ||
return "M" + sxm + " " + sym + "L" + sxp + " " + sym + "L" + exp + " " + eym + "L" + exp + " " + eyp + "L" + exm + " " + eyp + " L" + sxm + " " + syp + "Z"; | ||
} else if ((HALF_PI <= theta && theta < Math.PI)) { | ||
return "M" + sxm + " " + sym + "L" + sxp + " " + sym + "L" + sxp + " " + syp + "L" + exp + " " + eyp + "L" + exm + " " + eyp + " L" + exm + " " + eym + "Z"; | ||
} else if ((-Math.PI <= theta && theta < -HALF_PI)) { | ||
return "M" + sxp + " " + sym + "L" + sxp + " " + syp + "L" + sxm + " " + syp + "L" + exm + " " + eyp + "L" + exm + " " + eym + " L" + exp + " " + eym + "Z"; | ||
} else if ((-HALF_PI <= theta && theta < 0)) { | ||
return "M" + sxm + " " + sym + "L" + exm + " " + eym + "L" + exp + " " + eym + "L" + exp + " " + eyp + "L" + sxp + " " + syp + " L" + sxm + " " + syp + "Z"; | ||
} | ||
}; | ||
Plotter = (function() { | ||
@@ -1499,3 +1527,3 @@ function Plotter(file) { | ||
Plotter.prototype.operate = function(block) { | ||
var c, cen, code, coord, cx, cy, dist, end, large, obj, op, r, rTool, start, sweep, t, theta, thetaE, thetaS, valid, xMax, xMin, yMax, yMin, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref10, _ref11, _ref12, _ref13, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9; | ||
var c, cen, code, coord, cx, cy, dist, end, height, large, obj, op, r, rTool, start, sweep, t, theta, thetaE, thetaS, valid, width, xMax, xMin, xn, xp, yMax, yMin, yn, yp, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6; | ||
valid = false; | ||
@@ -1569,2 +1597,5 @@ code = block.slice(0, 3); | ||
} else if (op === '1') { | ||
if (!this.trace.region && !this.tools[this.currentTool].stroke) { | ||
throw new Error("tool " + this.currentTool + " is not a strokeable tool"); | ||
} | ||
if (!this.trace.path) { | ||
@@ -1590,3 +1621,9 @@ this.trace.path = "M" + start.x + " " + start.y; | ||
if (this.mode === 'i') { | ||
this.trace.path += "L" + end.x + " " + end.y; | ||
if (this.trace.region || (this.tools[this.currentTool].stroke['stroke-linecap'] != null)) { | ||
this.trace.path += "L" + end.x + " " + end.y; | ||
} else { | ||
width = this.tools[this.currentTool].pad[0].rect.width; | ||
height = this.tools[this.currentTool].pad[0].rect.height; | ||
this.trace.path += rectangleStrokePath(start, end, width, height); | ||
} | ||
if (this.trace.region) { | ||
@@ -1603,2 +1640,5 @@ return this.addBbox({ | ||
} else if (this.mode === 'cw' || this.mode === 'ccw') { | ||
if (this.tools[this.currentTool].stroke['stroke-linecap'] !== 'round') { | ||
throw new Error("tool " + this.currentTool + " is not circular and cannot stroke arcs"); | ||
} | ||
r = Math.sqrt(Math.pow(end.i, 2) + Math.pow(end.j, 2)); | ||
@@ -1636,15 +1676,15 @@ sweep = this.mode === 'cw' ? 0 : 1; | ||
if (thetaE < 0) { | ||
thetaE += 2 * Math.PI; | ||
thetaE += TWO_PI; | ||
} | ||
thetaS = Math.atan2(start.y - c.y, start.x - c.x); | ||
if (thetaS < 0) { | ||
thetaS += 2 * Math.PI; | ||
thetaS += TWO_PI; | ||
} | ||
if (this.mode === 'cw' && thetaS < thetaE) { | ||
thetaS += 2 * Math.PI; | ||
thetaS += TWO_PI; | ||
} else if (this.mode === 'ccw' && thetaE < thetaS) { | ||
thetaE += 2 * Math.PI; | ||
thetaE += TWO_PI; | ||
} | ||
theta = Math.abs(thetaE - thetaS); | ||
if (this.quad === 's' && Math.abs(thetaE - thetaS) > Math.PI / 2) { | ||
if (this.quad === 's' && Math.abs(thetaE - thetaS) > HALF_PI) { | ||
continue; | ||
@@ -1663,3 +1703,10 @@ } else { | ||
rTool = this.trace.region ? 0 : this.tools[this.currentTool].bbox().xMax; | ||
if ((thetaS <= (_ref6 = Math.PI) && _ref6 <= thetaE) || (thetaS >= (_ref7 = Math.PI) && _ref7 >= thetaE)) { | ||
if (this.mode === 'cw') { | ||
_ref6 = [thetaS, thetaE], thetaE = _ref6[0], thetaS = _ref6[1]; | ||
} | ||
xp = thetaS > 0 ? TWO_PI : 0; | ||
yp = HALF_PI + (thetaS > HALF_PI ? TWO_PI : 0); | ||
xn = Math.PI + (thetaS > Math.PI ? TWO_PI : 0); | ||
yn = THREEHALF_PI + (thetaS > THREEHALF_PI ? TWO_PI : 0); | ||
if ((thetaS <= xn && xn <= thetaE)) { | ||
xMin = cen.x - r - rTool; | ||
@@ -1669,3 +1716,3 @@ } else { | ||
} | ||
if ((thetaS <= (_ref8 = 2 * Math.PI) && _ref8 <= thetaE) || (thetaS >= (_ref9 = 2 * Math.PI) && _ref9 >= thetaE) || (thetaS <= 0 && 0 <= thetaE) || (thetaS >= 0 && 0 >= thetaE)) { | ||
if ((thetaS <= xp && xp <= thetaE)) { | ||
xMax = cen.x + r + rTool; | ||
@@ -1675,3 +1722,3 @@ } else { | ||
} | ||
if ((thetaS <= (_ref10 = 3 * Math.PI / 2) && _ref10 <= thetaE) || (thetaS >= (_ref11 = 3 * Math.PI / 2) && _ref11 >= thetaE)) { | ||
if ((thetaS <= yn && yn <= thetaE)) { | ||
yMin = cen.y - r - rTool; | ||
@@ -1681,3 +1728,3 @@ } else { | ||
} | ||
if ((thetaS <= (_ref12 = Math.PI / 2) && _ref12 <= thetaE) || (thetaS >= (_ref13 = Math.PI / 2) && _ref13 >= thetaE)) { | ||
if ((thetaS <= yp && yp <= thetaE)) { | ||
yMax = cen.y + r + rTool; | ||
@@ -1905,3 +1952,4 @@ } else { | ||
result.trace = { | ||
'stroke-width': 0 | ||
'stroke-width': 0, | ||
fill: 'currentColor' | ||
}; | ||
@@ -1908,0 +1956,0 @@ } |
/* copyright 2014 by mike cousins; shared under the terms of the MIT license. Source code available at github.com/mcous/gerber-to-svg */ | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.gerberToSvg=t()}}(function(){return function t(e,r,i){function o(s,h){if(!r[s]){if(!e[s]){var a="function"==typeof require&&require;if(!h&&a)return a(s,!0);if(n)return n(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var u=r[s]={exports:{}};e[s][0].call(u.exports,function(t){var r=e[s][1][t];return o(r?r:t)},u,u.exports,t,e,r,i)}return r[s].exports}for(var n="function"==typeof require&&require,s=0;s<i.length;s++)o(i[s]);return o}({1:[function(t,e){var r,i,o;i=t("./obj-to-xml"),r=t("./plotter"),o=function(t){var e,o,n,s,h,a;n=new r(t);try{a=n.plot()}catch(l){throw e=l}return n.bbox.xMin>=n.bbox.xMax?(n.bbox.xMin=0,n.bbox.xMax=0,s=0):s=parseFloat((n.bbox.xMax-n.bbox.xMin).toPrecision(10)),n.bbox.yMin>=n.bbox.yMax?(n.bbox.yMin=0,n.bbox.yMax=0,o=0):o=parseFloat((n.bbox.yMax-n.bbox.yMin).toPrecision(10)),h={svg:{xmlns:"http://www.w3.org/2000/svg",version:"1.1","xmlns:xlink":"http://www.w3.org/1999/xlink",width:""+s+n.units,height:""+o+n.units,viewBox:""+n.bbox.xMin+" "+n.bbox.yMin+" "+s+" "+o,id:n.gerberId,_:[]}},n.defs.length&&h.svg._.push({defs:{_:n.defs}}),n.group.g._.length&&(n.group.g.transform="translate(0,"+(n.bbox.yMin+n.bbox.yMax)+") scale(1,-1)",h.svg._.push(n.group)),i(h,{pretty:!0})},e.exports=o},{"./obj-to-xml":5,"./plotter":7}],2:[function(t,e){var r;r=function(){function t(t){this.file=t,this.index=0,this.line=1}return t.prototype.nextCommand=function(){var t,e,r,i,o;if(this.index>=this.file.length)return!1;for(t=[],r="",o=!1,i=!1;!i&&this.index!==this.file.length;){if(e=this.file[this.index],"%"===e){if(o?i=!0:o=!0,0!==r.length)throw new Error("% after "+r+" doesn't make sense");t.push("%")}else"*"===e?(t.push(r),r="",o||(i=!0)):e>=" "&&"~">=e?r+=e:"\n"===e&&this.line++;this.index++}return t},t}(),e.exports=r},{}],3:[function(t,e){var r,i,o,n,s,h;i=/[\+-\/x\(\)]/,r=/[\$\d\.]+/,o=new RegExp("("+i.source+")|("+r.source+")","g"),h=function(t){var e;return e=t.match(o)},n=function(t){return r.test(t)},s=function(t){var e,r,i,o,s,a,l;return l=h(t),r=0,a=function(){return l[r]},e=function(t){return t===a()?r++:void 0},s=function(){var t,r;if(r=a(),e(r),n(r))t={type:"n",val:r};else{if("("!==r)throw new SytaxError(""+r+" is unexpected in an arithmetic string");if(t=i(),")"!==a())throw new SytaxError("expected ')'");e(")")}return t},o=function(){var t,r,i;for(t=s(),i=a();"x"===i||"/"===i;)e(i),r=s(),t={type:i,left:t,right:r},i=a();return t},(i=function(){var t,r,i;for(t=o(),i=a();"+"===i||"-"===i;)e(i),r=o(),t={type:i,left:t,right:r},i=a();return t})()},e.exports={tokenize:h,isNumber:n,parse:s}},{}],4:[function(t,e){var r,i,o,n;o=t("./pad-shapes"),i=t("./macro-calc"),n=t("./unique-id"),r=function(){function t(t){this.modifiers={},this.name=t[0].slice(2),this.blocks=t.slice(1),this.shapes=[],this.masks=[],this.bbox=[null,null,null,null]}return t.prototype.run=function(t,e){var r,i,o,s,h,a,l,u,c,x,f,p,d,y,b,w,g,m,M;for(null==e&&(e=[]),o=c=0,d=e.length;d>c;o=++c)s=e[o],this.modifiers["$"+(o+1)]=s;for(g=this.blocks,x=0,y=g.length;y>x;x++)r=g[x],this.runBlock(r);for(a="tool-"+t+"-pad-"+n(),h=[],m=this.masks,f=0,b=m.length;b>f;f++)s=m[f],h.push(s);if(this.shapes.length>1){for(i={id:a,_:[]},M=this.shapes,p=0,w=M.length;w>p;p++)l=M[p],i._.push(l);h=[{g:i}]}else 1===this.shapes.length&&(u=Object.keys(this.shapes[0])[0],this.shapes[0][u].id=a,h.push(this.shapes[0]));return{pad:h,padId:a,bbox:this.bbox,trace:!1}},t.prototype.runBlock=function(t){var e,r,i,o,n,s,h,a;switch(t[0]){case"$":return o=null!=(a=t.match(/^\$\d+(?=\=)/))?a[0]:void 0,n=t.slice(1+o.length),this.modifiers[o]=this.getNumber(n);case"1":case"2":case"20":case"21":case"22":case"4":case"5":case"6":case"7":for(r=t.split(","),i=s=0,h=r.length;h>s;i=++s)e=r[i],r[i]=this.getNumber(e);return this.primitive(r);default:if("0"!==t[0])throw new SyntaxError("'"+t+"' unrecognized tool macro block")}},t.prototype.primitive=function(t){var e,r,i,s,h,a,l,u,c,x,f,p,d,y,b,w,g,m,M,v,k,E,S,q,R,I,T,_,D;switch(h=!1,c=!1,f=null,t[0]){case 1:f=o.circle({dia:t[2],cx:t[3],cy:t[4]}),0===t[1]?h=!0:this.addBbox(f.bbox);break;case 2:case 20:f=o.vector({width:t[2],x1:t[3],y1:t[4],x2:t[5],y2:t[6]}),t[7]&&(f.shape.line.transform="rotate("+t[7]+")"),0===t[1]?h=!0:this.addBbox(f.bbox,t[7]);break;case 21:f=o.rect({cx:t[4],cy:t[5],width:t[2],height:t[3]}),t[6]&&(f.shape.rect.transform="rotate("+t[6]+")"),0===t[1]?h=!0:this.addBbox(f.bbox,t[6]);break;case 22:f=o.lowerLeftRect({x:t[4],y:t[5],width:t[2],height:t[3]}),t[6]&&(f.shape.rect.transform="rotate("+t[6]+")"),0===t[1]?h=!0:this.addBbox(f.bbox,t[6]);break;case 4:for(l=[],r=p=3,S=3+2*t[2];S>=p;r=p+=2)l.push([t[r],t[r+1]]);f=o.outline({points:l}),(u=t[t.length-1])&&(f.shape.polygon.transform="rotate("+u+")"),0===t[1]?h=!0:this.addBbox(f.bbox,t[t.length-1]);break;case 5:if(0!==t[6]&&(0!==t[3]||0!==t[4]))throw new RangeError("polygon center must be 0,0 if rotated in macro");f=o.polygon({cx:t[3],cy:t[4],dia:t[5],verticies:t[2],degrees:t[6]}),0===t[1]?h=!0:this.addBbox(f.bbox);break;case 6:if(0!==t[9]&&(0!==t[1]||0!==t[2]))throw new RangeError("moiré center must be 0,0 if rotated in macro");if(f=o.moire({cx:t[1],cy:t[2],outerDia:t[3],ringThx:t[4],ringGap:t[5],maxRings:t[6],crossThx:t[7],crossLength:t[8]}),t[9])for(q=f.shape,d=0,w=q.length;w>d;d++)x=q[d],null!=x.line&&(x.line.transform="rotate("+t[9]+")");this.addBbox(f.bbox,t[9]);break;case 7:if(0!==t[9]&&(0!==t[1]||0!==t[2]))throw new RangeError("thermal center must be 0,0 if rotated in macro");if(f=o.thermal({cx:t[1],cy:t[2],outerDia:t[3],innerDia:t[4],gap:t[5]}),t[6])for(R=f.shape,y=0,g=R.length;g>y;y++)if(x=R[y],null!=x.mask)for(I=x.mask._,b=0,m=I.length;m>b;b++)s=I[b],null!=s.rect&&(s.rect.transform="rotate("+t[6]+")");this.addBbox(f.bbox,t[6]);break;default:throw new SyntaxError(""+t[0]+" is not a valid primitive code")}if(h){for(i in f.shape)f.shape[i].fill="#000";if(a="macro-"+this.name+"-mask-"+n(),s={mask:{id:a,_:[{rect:{x:this.bbox[0],y:this.bbox[1],width:this.bbox[2]-this.bbox[0],height:this.bbox[3]-this.bbox[1],fill:"#fff"}},f.shape]}},1===this.shapes.length)for(i in this.shapes[0])this.shapes[0][i].mask="url(#"+a+")";else if(this.shapes.length>1){for(e={mask:"url(#"+a+")",_:[]},T=this.shapes,k=0,M=T.length;M>k;k++)x=T[k],e._.push(x);this.shapes=[{g:e}]}return this.masks.push(s)}if(Array.isArray(f.shape)){for(_=f.shape,D=[],E=0,v=_.length;v>E;E++)x=_[E],D.push(null!=x.mask?this.masks.push(x):this.shapes.push(x));return D}return this.shapes.push(f.shape)},t.prototype.addBbox=function(t,e){var r,i,o,n,s,h,a,l,u;if(null==e&&(e=0),e){for(n=Math.sin(e*Math.PI/180),r=Math.cos(e*Math.PI/180),Math.abs(n)<1e-9&&(n=0),Math.abs(r)<1e-9&&(r=0),o=[[t[0],t[1]],[t[2],t[1]],[t[2],t[3]],[t[0],t[3]]],u=[],a=0,l=o.length;l>a;a++)i=o[a],s=i[0]*r-i[1]*n,h=i[0]*n+i[1]*r,(null===this.bbox[0]||s<this.bbox[0])&&(this.bbox[0]=s),(null===this.bbox[1]||h<this.bbox[1])&&(this.bbox[1]=h),(null===this.bbox[2]||s>this.bbox[2])&&(this.bbox[2]=s),u.push(null===this.bbox[3]||h>this.bbox[3]?this.bbox[3]=h:void 0);return u}return(null===this.bbox[0]||t[0]<this.bbox[0])&&(this.bbox[0]=t[0]),(null===this.bbox[1]||t[1]<this.bbox[1])&&(this.bbox[1]=t[1]),(null===this.bbox[2]||t[2]>this.bbox[2])&&(this.bbox[2]=t[2]),null===this.bbox[3]||t[3]>this.bbox[3]?this.bbox[3]=t[3]:void 0},t.prototype.getNumber=function(t){return t.match(/^[+-]?[\d.]+$/)?parseFloat(t):t.match(/^\$\d+$/)?parseFloat(this.modifiers[t]):this.evaluate(i.parse(t))},t.prototype.evaluate=function(t){switch(t.type){case"n":return this.getNumber(t.val);case"+":return this.evaluate(t.left)+this.evaluate(t.right);case"-":return this.evaluate(t.left)-this.evaluate(t.right);case"x":return this.evaluate(t.left)*this.evaluate(t.right);case"/":return this.evaluate(t.left)/this.evaluate(t.right)}},t}(),e.exports=r},{"./macro-calc":3,"./pad-shapes":6,"./unique-id":9}],5:[function(t,e){var r,i,o,n;n=function(t,e){var r;if(r="",0===e)return"";for(;e>1;)1&e&&(r+=t),e>>=1,t+=t;return r+t},r="_",i=" ",o=function(t,e){var s,h,a,l,u,c,x,f,p,d,y,b,w,g,m;if(null==e&&(e={}),f=e.pretty,l=null!=(g=e.indent)?g:0,c=f?"\n":"",p=c?"string"==typeof f?f:i:"",p=n(p,l),y="",Array.isArray(t))for(a=b=0,w=t.length;w>b;a=++b)x=t[a],y+=(0!==a?c:"")+o(x,e);else if(s=!1,h=Object.keys(t)[0],null!=h){y=""+p+"<"+h,m=t[h];for(u in m)d=m[u],u===r?s=d:y+=" "+u+'="'+d+'"';s&&(y+=">"+c+o(s,{pretty:f,indent:l+1})),y+=null!=t[h]._?""+c+p+"</"+h+">":"/>"}return y},e.exports=o},{}],6:[function(t,e){var r,i,o,n,s,h,a,l,u;l=t("./unique-id"),r=function(t){var e;if(null==t.dia)throw new SyntaxError("circle function requires diameter");if(null==t.cx)throw new SyntaxError("circle function requires x center");if(null==t.cy)throw new SyntaxError("circle function requires y center");return e=t.dia/2,{shape:{circle:{cx:t.cx,cy:t.cy,r:e,"stroke-width":0,fill:"currentColor"}},bbox:[t.cx-e,t.cy-e,t.cx+e,t.cy+e]}},h=function(t){var e,r,i,o;if(null==t.width)throw new SyntaxError("rectangle requires width");if(null==t.height)throw new SyntaxError("rectangle requires height");if(null==t.cx)throw new SyntaxError("rectangle function requires x center");if(null==t.cy)throw new SyntaxError("rectangle function requires y center");return i=t.cx-t.width/2,o=t.cy-t.height/2,r={shape:{rect:{x:i,y:o,width:t.width,height:t.height,"stroke-width":0,fill:"currentColor"}},bbox:[i,o,i+t.width,o+t.height]},t.obround&&(e=.5*Math.min(t.width,t.height),r.shape.rect.rx=e,r.shape.rect.ry=e),r},s=function(t){var e,r,i,o,n,s,h,a,l,u,c,x,f,p,d,y;if(null==t.dia)throw new SyntaxError("polygon requires diameter");if(null==t.verticies)throw new SyntaxError("polygon requires verticies");if(null==t.cx)throw new SyntaxError("polygon function requires x center");if(null==t.cy)throw new SyntaxError("polygon function requires y center");for(s=null!=t.degrees?t.degrees*Math.PI/180:0,h=2*Math.PI/t.verticies,i=t.dia/2,r="",c=null,p=null,u=null,f=null,e=d=0,y=t.verticies;y>=0?y>d:d>y;e=y>=0?++d:--d)a=s+e*h,o=i*Math.cos(a),n=i*Math.sin(a),Math.abs(o)<1e-9&&(o=0),Math.abs(n)<1e-9&&(n=0),l=t.cx+o,x=t.cy+n,(c>l||null===c)&&(c=l),(l>u||null===u)&&(u=l),(p>x||null===p)&&(p=x),(x>f||null===f)&&(f=x),r+=" "+l+","+x;return{shape:{polygon:{points:r.slice(1),"stroke-width":0,fill:"currentColor"}},bbox:[c,p,u,f]}},u=function(t){var e,r,i;if(null==t.x1)throw new SyntaxError("vector function requires start x");if(null==t.y1)throw new SyntaxError("vector function requires start y");if(null==t.x2)throw new SyntaxError("vector function requires end x");if(null==t.y2)throw new SyntaxError("vector function requires end y");if(null==t.width)throw new SyntaxError("vector function requires width");return e=Math.abs(Math.atan((t.y2-t.y1)/(t.x2-t.x1))),r=t.width/2*Math.sin(e),i=t.width/2*Math.cos(e),1e-7>r&&(r=0),1e-7>i&&(i=0),{shape:{line:{x1:t.x1,x2:t.x2,y1:t.y1,y2:t.y2,"stroke-width":t.width,stroke:"currentColor"}},bbox:[Math.min(t.x1,t.x2)-r,Math.min(t.y1,t.y2)-i,Math.max(t.x1,t.x2)+r,Math.max(t.y1,t.y2)+i]}},i=function(t){if(null==t.width)throw new SyntaxError("lower left rect requires width");if(null==t.height)throw new SyntaxError("lower left rect requires height");if(null==t.x)throw new SyntaxError("lower left rectangle requires x");if(null==t.y)throw new SyntaxError("lower left rectangle requires y");return{shape:{rect:{x:t.x,y:t.y,width:t.width,height:t.height,"stroke-width":0,fill:"currentColor"}},bbox:[t.x,t.y,t.x+t.width,t.y+t.height]}},n=function(t){var e,r,i,o,n,s,h,a,l,u,c,x,f;if(!(Array.isArray(t.points)&&t.points.length>1))throw new SyntaxError("outline function requires points array");for(s=null,u=null,n=null,l=null,r="",f=t.points,c=0,x=f.length;x>c;c++){if(e=f[c],!Array.isArray(e)||2!==e.length)throw new SyntaxError("outline function requires points array");i=e[0],h=e[1],(s>i||null===s)&&(s=i),(i>n||null===n)&&(n=i),(u>h||null===u)&&(u=h),(h>l||null===l)&&(l=h),r+=" "+i+","+h}if(o=t.points[t.points.length-1][0],a=t.points[t.points.length-1][1],o!==t.points[0][0]||a!==t.points[0][1])throw new RangeError("last point must match first point of outline");return{shape:{polygon:{points:r.slice(1),"stroke-width":0,fill:"currentColor"}},bbox:[s,u,n,l]}},o=function(t){var e,r,i;if(null==t.cx)throw new SyntaxError("moiré requires x center");if(null==t.cy)throw new SyntaxError("moiré requires y center");if(null==t.outerDia)throw new SyntaxError("moiré requires outer diameter");if(null==t.ringThx)throw new SyntaxError("moiré requires ring thickness");if(null==t.ringGap)throw new SyntaxError("moiré requires ring gap");if(null==t.maxRings)throw new SyntaxError("moiré requires max rings");if(null==t.crossLength)throw new SyntaxError("moiré requires crosshair length");if(null==t.crossThx)throw new SyntaxError("moiré requires crosshair thickness");for(i=[{line:{x1:t.cx-t.crossLength/2,y1:0,x2:t.cx+t.crossLength/2,y2:0,"stroke-width":t.crossThx,stroke:"currentColor"}},{line:{x1:0,y1:t.cy-t.crossLength/2,x2:0,y2:t.cy+t.crossLength/2,"stroke-width":t.crossThx,stroke:"currentColor"}}],e=(t.outerDia-t.ringThx)/2,r=0;e>=t.ringThx&&r<t.maxRings;)i.push({circle:{cx:t.cx,cy:t.cy,r:e,fill:"none","stroke-width":t.ringThx,stroke:"currentColor"}}),r++,e-=t.ringThx+t.ringGap;return e+=.5*t.ringThx,e>0&&r<t.maxRings&&i.push({circle:{cx:t.cx,cy:t.cy,r:e,"stroke-width":0,fill:"currentColor"}}),{shape:i,bbox:[Math.min(t.cx-t.crossLength/2,t.cx-t.outerDia/2),Math.min(t.cy-t.crossLength/2,t.cy-t.outerDia/2),Math.max(t.cx+t.crossLength/2,t.cx+t.outerDia/2),Math.max(t.cy+t.crossLength/2,t.cy+t.outerDia/2)]}},a=function(t){var e,r,i,o,n,s,h,a,u;if(null==t.cx)throw new SyntaxError("thermal requires x center");if(null==t.cy)throw new SyntaxError("thermal requires y center");if(null==t.outerDia)throw new SyntaxError("thermal requires outer diameter");if(null==t.innerDia)throw new SyntaxError("thermal requires inner diameter");if(null==t.gap)throw new SyntaxError("thermal requires gap");return r="thermal-mask-"+l(),n=(t.outerDia-t.innerDia)/2,i=t.outerDia/2,o=i-n/2,h=t.cx-i,s=t.cx+i,u=t.cy-i,a=t.cy+i,e=t.gap/2,{shape:[{mask:{id:r,_:[{circle:{cx:t.cx,cy:t.cy,r:i,"stroke-width":0,fill:"#fff"}},{rect:{x:h,y:-e,width:t.outerDia,height:t.gap,"stroke-width":0,fill:"#000"}},{rect:{x:-e,y:u,width:t.gap,height:t.outerDia,"stroke-width":0,fill:"#000"}}]}},{circle:{cx:t.cx,cy:t.cy,r:o,fill:"none","stroke-width":n,stroke:"currentColor",mask:"url(#"+r+")"}}],bbox:[h,u,s,a]}},e.exports={circle:r,rect:h,polygon:s,vector:u,lowerLeftRect:i,outline:n,moire:o,thermal:a}},{"./unique-id":9}],7:[function(t,e){var r,i,o,n,s,h;i=t("./gerber-parser"),h=t("./unique-id"),r=t("./macro-tool"),s=t("./standard-tool"),n=function(t){var e,r,i,o,n,h,a,l,u,c;if(i=null!=(l=t.match(/^ADD\d+/))&&null!=(u=l[0])?u.slice(2):void 0,!(null!=i&&parseInt(i.slice(1),10)>9))throw new SyntaxError(""+i+" is an invalid tool code (must be >= 10)");switch(e=null,r=!1,t.slice(2+i.length,4+i.length)){case"C,":n=t.slice(4+i.length).split("X"),a={dia:parseFloat(n[0])},n.length>2?a.hole={width:parseFloat(n[1]),height:parseFloat(n[2])}:n.length>1&&(a.hole={dia:parseFloat(n[1])}),e=s(i,a);break;case"R,":n=t.slice(4+i.length).split("X"),a={width:parseFloat(n[0]),height:parseFloat(n[1])},n.length>3?a.hole={width:parseFloat(n[2]),height:parseFloat(n[3])}:n.length>2&&(a.hole={dia:parseFloat(n[2])}),e=s(i,a);break;case"O,":n=t.slice(4+i.length).split("X"),a={width:parseFloat(n[0]),height:parseFloat(n[1])},n.length>3?a.hole={width:parseFloat(n[2]),height:parseFloat(n[3])}:n.length>2&&(a.hole={dia:parseFloat(n[2])}),a.obround=!0,e=s(i,a);break;case"P,":n=t.slice(4+i.length).split("X"),a={dia:parseFloat(n[0]),verticies:parseFloat(n[1])},null!=n[2]&&(a.degrees=parseFloat(n[2])),n.length>4?a.hole={width:parseFloat(n[3]),height:parseFloat(n[4])}:n.length>3&&(a.hole={dia:parseFloat(n[3])}),e=s(i,a);break;default:if(o=t.slice(2+i.length),h=null!=(c=o.match(/[a-zA-Z_$][a-zA-Z_$.0-9]{0,126}(?=,)?/))?c[0]:void 0,!h)throw new SyntaxError("invalid definition with macro");n=o.slice(h.length+1).split("X"),1===n.length&&""===n[0]&&(n=null),r={name:h,mods:n}}return{macro:r,tool:e,code:i}},o=function(){function t(t){null==t&&(t=""),this.parser=new i(t),this.macros={},this.tools={},this.currentTool="",this.defs=[],this.gerberId="gerber-"+h(),this.group={g:{id:""+this.gerberId+"-layer-0",_:[]}},this.layer={level:0,type:"g",current:this.group},this.stepRepeat={x:1,y:1,xStep:null,yStep:null,block:0},this.done=!1,this.units=null,this.format={set:!1,zero:null,notation:null,places:null},this.position={x:0,y:0},this.mode=null,this.trace={region:!1,path:""},this.quad=null,this.bbox={xMin:1/0,yMin:1/0,xMax:-1/0,yMax:-1/0}}return t.prototype.plot=function(){for(var t;!this.done;){if(t=this.parser.nextCommand(),t===!1)throw new Error("end of file encountered before required M02 command");"%"===t[0]?this.parameter(t):this.operate(t[0])}return this.finish()},t.prototype.finish=function(){return this.finishTrace(),this.finishStepRepeat()},t.prototype.parameter=function(t){var e,i,o,s,h,a,l,u,c,x,f,p,d,y,b,w,g,m,M,v,k,E,S,q;if(o=!1,"%"===t[0]&&"%"!==t[t.length-1])throw new SyntaxError("@parameter should only be called with paramters");for(t=t.slice(1),l=0,q=[];!o;){switch(i=t[l],i.slice(0,2)){case"FS":if(u=!1,this.format.set)throw new SyntaxError("format spec cannot be redefined");try{"L"===i[2]||"T"===i[2]?this.format.zero=i[2]:u=!0,"A"===i[3]||"I"===i[3]?this.format.notation=i[3]:u=!0,"X"===i[4]&&"Y"===i[7]&&i.slice(5,7)===i.slice(8,10)?(this.format.places=[parseInt(i[5],10),parseInt(i[6],10)],(this.format.places[0]>7||this.format.places[1]>7)&&(u=!0)):u=!0}catch(R){s=R,u=!0}if(u)throw new SyntaxError("invalid format spec");this.format.set=!0;break;case"MO":if(y=i.slice(2),null!=this.units)throw new SyntaxError("gerber file may not redifine units");if("MM"===y)this.units="mm";else{if("IN"!==y)throw new SyntaxError(""+y+" are unrecognized units");this.units="in"}break;case"AD":if(e=n(t[l]),null!=this.tools[e.code])throw new SyntaxError("duplicate tool code");e.macro&&(e.tool=this.macros[e.macro.name].run(e.code,e.macro.mods)),this.tools[e.code]={stroke:e.tool.trace,pad:function(){var t,r,i,o;for(i=e.tool.pad,o=[],t=0,r=i.length;r>t;t++)f=i[t],o.push(f);return o}(),flash:function(t,r){return{use:{x:t,y:r,"xlink:href":"#"+e.tool.padId}}},bbox:function(t,r){return null==t&&(t=0),null==r&&(r=0),{xMin:t+e.tool.bbox[0],yMin:r+e.tool.bbox[1],xMax:t+e.tool.bbox[2],yMax:r+e.tool.bbox[3]}}},this.currentTool=e.code;break;case"AM":c=new r(t.slice(0,-1)),this.macros[c.name]=c,o=!0;break;case"SR":this.finishTrace(),this.finishStepRepeat(),this.stepRepeat.x=Number(null!=(m=null!=(M=i.match(/X\d+/))?M[0].slice(1):void 0)?m:1),this.stepRepeat.y=Number(null!=(v=null!=(k=i.match(/Y\d+/))?k[0].slice(1):void 0)?v:1),this.stepRepeat.x>1&&(this.stepRepeat.xStep=Number(null!=(E=i.match(/I[\d\.]+/))?E[0].slice(1):void 0)),this.stepRepeat.y>1&&(this.stepRepeat.yStep=Number(null!=(S=i.match(/J[\d\.]+/))?S[0].slice(1):void 0)),(1!==this.stepRepeat.x||1!==this.stepRepeat.y)&&0===this.layer.level&&(d={g:{id:""+this.gerberId+"-sr-block-"+this.stepRepeat.block,_:[]}},this.layer.current[this.layer.type]._.push(d),this.layer.current=d);break;case"LP":if(this.finishTrace(),p=i[2],"D"!==p&&"C"!==p)throw new SyntaxError(""+i+" is an unrecognized level polarity");"D"===p&&"mask"===this.layer.type?(h=""+this.gerberId+"-layer-"+ ++this.layer.level,this.group={g:{id:h,_:[this.group]}},this.layer.current=this.group,this.layer.type="g"):"C"===p&&"g"===this.layer.type&&(x=""+this.gerberId+"-layer-"+ ++this.layer.level,w=this.bbox.xMin,g=this.bbox.yMin,b=this.bbox.xMax-this.bbox.xMin,a=this.bbox.yMax-this.bbox.yMin,c={mask:{id:x,color:"#000",_:[{rect:{x:w,y:g,width:b,height:a,fill:"#fff"}}]}},this.defs.push(c),this.layer.current.g.mask="url(#"+x+")",this.layer.current=this.defs[this.defs.length-1],this.layer.type="mask"),this.position.x=null,this.position.y=null}q.push("%"===t[++l]?o=!0:void 0)}return q},t.prototype.operate=function(t){var e,r,i,o,n,s,h,a,l,u,c,x,f,p,d,y,b,w,g,m,M,v,k,E,S,q,R,I,T,_,D,F,P,C,B,G,L,A,j,N,z,$,X,O,U,Y;if(m=!1,i=t.slice(0,3),"M"===t[0]){if("M02"===i)this.done=!0,t="";else if("M00"!==i&&"M01"!==i)throw new SyntaxError("invalid operation M code");m=!0}else if("G"===t[0]){if(t.match(/^G0?1/))this.mode="i";else if(t.match(/^G0?2/))this.mode="cw";else if(t.match(/^G0?3(?![67])/))this.mode="ccw";else if("G36"===i)this.finishTrace(),this.trace.region=!0;else if("G37"===i)this.finishTrace(),this.trace.region=!1;else if("G74"===i)this.quad="s";else if("G75"===i)this.quad="m";else if("G70"===i)this.backupUnits="in";else if("G71"===i)this.backupUnits="mm";else if(!i.match(/^G(0?4)|(5[45])|(7[01])|(9[01])/))throw new SyntaxError("invalid operation G code");m=!0}if(y=null!=(P=t.match(/D[1-9]\d{1,}$/))?P[0]:void 0,null!=y){if(this.finishTrace(),null==this.tools[y])throw new SyntaxError("tool "+y+" does not exist");if(this.trace.region)throw new SyntaxError("cannot change tool while region mode is on");this.currentTool=y}if(t.match(/^(G0?[123])?([XYIJ][+-]?\d+){0,4}D0?[123]$/)){if(c=t[t.length-1],o=null!=(C=null!=(j=t.match(/[XYIJ][+-]?\d+/g))?j.join(""):void 0)?C:"",p={x:this.position.x,y:this.position.y},a=this.move(o),"3"===c){if(this.finishTrace(),this.tools[this.currentTool].pad){for(N=this.tools[this.currentTool].pad,S=0,T=N.length;T>S;S++)u=N[S],this.defs.push(u);this.tools[this.currentTool].pad=!1}return this.layer.current[this.layer.type]._.push(this.tools[this.currentTool].flash(this.position.x,this.position.y)),this.addBbox(this.tools[this.currentTool].bbox(this.position.x,this.position.y))}if("1"===c){if(this.trace.path||(this.trace.path="M"+p.x+" "+p.y,"i"===this.mode&&this.addBbox(this.trace.region?{xMin:p.x,yMin:p.y,xMax:p.x,yMax:p.y}:this.tools[this.currentTool].bbox(p.x,p.y))),null==this.mode&&(this.mode="i"),"i"===this.mode)return this.trace.path+="L"+a.x+" "+a.y,this.addBbox(this.trace.region?{xMin:a.x,yMin:a.y,xMax:a.x,yMax:a.y}:this.tools[this.currentTool].bbox(a.x,a.y));if("cw"===this.mode||"ccw"===this.mode){if(x=Math.sqrt(Math.pow(a.i,2)+Math.pow(a.j,2)),d="cw"===this.mode?0:1,l=0,r=[],w=0,g=0,"s"===this.quad)for(z=[p.x-a.i,p.x+a.i],q=0,_=z.length;_>q;q++)for(n=z[q],$=[p.y-a.j,p.y+a.j],R=0,D=$.length;D>R;R++)s=$[R],h=Math.sqrt(Math.pow(n-a.x,2)+Math.pow(s-a.y,2)),Math.abs(x-h)<1e-7&&r.push({x:n,y:s});else"m"===this.quad&&r.push({x:p.x+a.i,y:p.y+a.j});for(I=0,F=r.length;F>I;I++)if(e=r[I],w=Math.atan2(a.y-e.y,a.x-e.x),0>w&&(w+=2*Math.PI),g=Math.atan2(p.y-e.y,p.x-e.x),0>g&&(g+=2*Math.PI),"cw"===this.mode&&w>g?g+=2*Math.PI:"ccw"===this.mode&&g>w&&(w+=2*Math.PI),b=Math.abs(w-g),!("s"===this.quad&&Math.abs(w-g)>Math.PI/2)){"m"===this.quad&&b>=Math.PI&&(l=1),r={x:e.x,y:e.y};break}return f=this.trace.region?0:this.tools[this.currentTool].bbox().xMax,v=g<=(X=Math.PI)&&w>=X||g>=(O=Math.PI)&&O>=w?r.x-x-f:Math.min(p.x,a.x)-f,M=g<=(U=2*Math.PI)&&w>=U||g>=(Y=2*Math.PI)&&Y>=w||0>=g&&w>=0||g>=0&&0>=w?r.x+x+f:Math.max(p.x,a.x)+f,E=g<=(B=3*Math.PI/2)&&w>=B||g>=(G=3*Math.PI/2)&&G>=w?r.y-x-f:Math.min(p.y,a.y)-f,k=g<=(L=Math.PI/2)&&w>=L||g>=(A=Math.PI/2)&&A>=w?r.y+x+f:Math.max(p.y,a.y)+f,"m"===this.quad&&Math.abs(p.x-a.x)<1e-6&&Math.abs(p.y-a.y)<1e-6&&(this.trace.path+="A"+x+" "+x+" 0 0 "+d+" "+(a.x+2*a.i)+" "+(a.y+2*a.j),v=r.x-x-f,E=r.y-x-f,M=r.x+x+f,k=r.y+x+f),this.trace.path+="A"+x+" "+x+" 0 "+l+" "+d+" "+a.x+" "+a.y,this.addBbox({xMin:v,yMin:E,xMax:M,yMax:k})}throw new SyntaxError("cannot interpolate without a G01/2/3")}if("2"===c)return this.finishTrace();throw new SyntaxError(""+c+" is an invalid operation (D) code")}},t.prototype.finishStepRepeat=function(){var t,e,r,i,o,n;if(1!==this.stepRepeat.x||1!==this.stepRepeat.y){if(0!==this.layer.level)throw new Error("step repeat with clear levels is unimplimented");for(t=this.layer.current.g.id,this.layer.current=this.group,n=[],e=i=0,o=this.stepRepeat.x;o>=0?o>i:i>o;e=o>=0?++i:--i)n.push(function(){var i,o,n;for(n=[],r=i=0,o=this.stepRepeat.y;o>=0?o>i:i>o;r=o>=0?++i:--i)n.push(0!==e||0!==r?this.layer.current[this.layer.type]._.push({use:{x:e*this.stepRepeat.xStep,y:r*this.stepRepeat.yStep,"xlink:href":t}}):void 0);return n}.call(this));return n}},t.prototype.finishTrace=function(){var t,e,r,i;if(this.trace.path){if(e={path:{d:this.trace.path}},this.trace.region)e.path["stroke-width"]=0,e.path.fill="currentColor";else{i=this.tools[this.currentTool].stroke;for(t in i)r=i[t],e.path[t]=r}return this.layer.current[this.layer.type]._.push(e),this.trace.path=""}},t.prototype.move=function(t){var e;if(null==this.units){if(null==this.backupUnits)throw new Error("units have not been set");this.units=this.backupUnits}return e=this.coordinate(t),this.position.x=e.x,this.position.y=e.y,e},t.prototype.coordinate=function(t){var e,r,i,o,n,s,h,a,l,u,c,x,f;if(!this.format.set)throw new SyntaxError("format undefined");i={x:0,y:0},i.x=null!=(n=t.match(/X[+-]?\d+/))&&null!=(s=n[0])?s.slice(1):void 0,i.y=null!=(h=t.match(/Y[+-]?\d+/))&&null!=(a=h[0])?a.slice(1):void 0,i.i=null!=(l=t.match(/I[+-]?\d+/))&&null!=(u=l[0])?u.slice(1):void 0,i.j=null!=(c=t.match(/J[+-]?\d+/))&&null!=(x=c[0])?x.slice(1):void 0;for(r in i)if(o=i[r],null!=o){if(e=1,("+"===o[0]||"-"===o[0])&&("-"===o[0]&&(e=-1),o=o.slice(1)),"L"===this.format.zero)e*=Math.pow(10,this.format.places[1]);else{if("T"!==this.format.zero)throw new SyntaxError("invalid zero suppression format");e*=Math.pow(10,o.length-this.format.places[0])}i[r]=Number(o)/e,"I"===this.format.notation&&(i[r]+=null!=(f=this.position[r])?f:0)}return null==i.x&&(i.x=this.position.x),null==i.y&&(i.y=this.position.y),null==i.i&&(i.i=0),null==i.j&&(i.j=0),i},t.prototype.addBbox=function(t){return t.xMin<this.bbox.xMin&&(this.bbox.xMin=t.xMin),t.yMin<this.bbox.yMin&&(this.bbox.yMin=t.yMin),t.xMax>this.bbox.xMax&&(this.bbox.xMax=t.xMax),t.yMax>this.bbox.yMax?this.bbox.yMax=t.yMax:void 0},t}(),e.exports=o},{"./gerber-parser":2,"./macro-tool":4,"./standard-tool":8,"./unique-id":9}],8:[function(t,e){var r,i,o;o=t("./unique-id"),r=t("./pad-shapes"),i=function(t,e){var i,n,s,h,a,l,u;if(l={pad:[],trace:!1},e.cx=0,e.cy=0,n="tool-"+t+"-pad-"+o(),u="",null!=e.dia&&null==e.verticies){if(null!=e.obround||null!=e.width||null!=e.height||null!=e.degrees)throw new Error("incompatible parameters for tool "+t);if(e.dia<0)throw new RangeError(""+t+" circle diameter out of range ("+e.dia+"<0)");u="circle",null==e.hole&&(l.trace={"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":e.dia,stroke:"currentColor",fill:"none"})}else if(null!=e.width&&null!=e.height){if(null!=e.dia||null!=e.verticies||null!=e.degrees)throw new Error("incompatible parameters for tool "+t);if(e.width<=0)throw new RangeError(""+t+" rect width out of range ("+e.width+"<=0)");if(e.height<=0)throw new RangeError(""+t+" rect height out of range ("+e.height+"<=0)");u="rect",null!=e.hole||e.obround||(l.trace={"stroke-width":0})}else{if(null==e.dia||null==e.verticies)throw new Error("unidentified standard tool shape");if(null!=e.obround||null!=e.width||null!=e.height)throw new Error("incompatible parameters for tool "+t);if(e.verticies<3||e.verticies>12)throw new RangeError(""+t+" polygon points out of range ("+e.verticies+"<3 or >12)]");u="polygon"}if(a=r[u](e),null!=e.hole){if(i=null,null!=e.hole.dia&&null==e.hole.width&&null==e.hole.height){if(!(e.hole.dia>=0))throw new RangeError(""+t+" hole diameter out of range ("+e.hole.dia+"<0)");i=r.circle({cx:e.cx,cy:e.cy,dia:e.hole.dia}),i=i.shape,i.circle.fill="#000"}else{if(null==e.hole.width||null==e.hole.height)throw new Error(""+t+" has invalid hole parameters");if(!(e.hole.width>=0))throw new RangeError(""+t+" hole width out of range ("+e.hole.width+"<0)");if(!(e.hole.height>=0))throw new RangeError(""+t+" hole height out of range");i=r.rect({cx:e.cx,cy:e.cy,width:e.hole.width,height:e.hole.height}),i=i.shape,i.rect.fill="#000"}h=n+"-mask",s={mask:{id:n+"-mask",_:[{rect:{x:a.bbox[0],y:a.bbox[1],width:a.bbox[2]-a.bbox[0],height:a.bbox[3]-a.bbox[1],fill:"#fff"}},i]}},a.shape[u].mask="url(#"+h+")",l.pad.push(s)}return n&&(a.shape[u].id=n),l.pad.push(a.shape),l.bbox=a.bbox,l.padId=n,l},e.exports=i},{"./pad-shapes":6,"./unique-id":9}],9:[function(t,e){var r,i;i=1e3,r=function(){return i++},e.exports=r},{}]},{},[1])(1)}); | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.gerberToSvg=t()}}(function(){return function t(e,r,i){function o(s,h){if(!r[s]){if(!e[s]){var a="function"==typeof require&&require;if(!h&&a)return a(s,!0);if(n)return n(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var u=r[s]={exports:{}};e[s][0].call(u.exports,function(t){var r=e[s][1][t];return o(r?r:t)},u,u.exports,t,e,r,i)}return r[s].exports}for(var n="function"==typeof require&&require,s=0;s<i.length;s++)o(i[s]);return o}({1:[function(t,e){var r,i,o;i=t("./obj-to-xml"),r=t("./plotter"),o=function(t){var e,o,n,s,h,a;n=new r(t);try{a=n.plot()}catch(l){throw e=l}return n.bbox.xMin>=n.bbox.xMax?(n.bbox.xMin=0,n.bbox.xMax=0,s=0):s=parseFloat((n.bbox.xMax-n.bbox.xMin).toPrecision(10)),n.bbox.yMin>=n.bbox.yMax?(n.bbox.yMin=0,n.bbox.yMax=0,o=0):o=parseFloat((n.bbox.yMax-n.bbox.yMin).toPrecision(10)),h={svg:{xmlns:"http://www.w3.org/2000/svg",version:"1.1","xmlns:xlink":"http://www.w3.org/1999/xlink",width:""+s+n.units,height:""+o+n.units,viewBox:""+n.bbox.xMin+" "+n.bbox.yMin+" "+s+" "+o,id:n.gerberId,_:[]}},n.defs.length&&h.svg._.push({defs:{_:n.defs}}),n.group.g._.length&&(n.group.g.transform="translate(0,"+(n.bbox.yMin+n.bbox.yMax)+") scale(1,-1)",h.svg._.push(n.group)),i(h,{pretty:!0})},e.exports=o},{"./obj-to-xml":5,"./plotter":7}],2:[function(t,e){var r;r=function(){function t(t){this.file=t,this.index=0,this.line=1}return t.prototype.nextCommand=function(){var t,e,r,i,o;if(this.index>=this.file.length)return!1;for(t=[],r="",o=!1,i=!1;!i&&this.index!==this.file.length;){if(e=this.file[this.index],"%"===e){if(o?i=!0:o=!0,0!==r.length)throw new Error("% after "+r+" doesn't make sense");t.push("%")}else"*"===e?(t.push(r),r="",o||(i=!0)):e>=" "&&"~">=e?r+=e:"\n"===e&&this.line++;this.index++}return t},t}(),e.exports=r},{}],3:[function(t,e){var r,i,o,n,s,h;i=/[\+-\/x\(\)]/,r=/[\$\d\.]+/,o=new RegExp("("+i.source+")|("+r.source+")","g"),h=function(t){var e;return e=t.match(o)},n=function(t){return r.test(t)},s=function(t){var e,r,i,o,s,a,l;return l=h(t),r=0,a=function(){return l[r]},e=function(t){return t===a()?r++:void 0},s=function(){var t,r;if(r=a(),e(r),n(r))t={type:"n",val:r};else{if("("!==r)throw new SytaxError(""+r+" is unexpected in an arithmetic string");if(t=i(),")"!==a())throw new SytaxError("expected ')'");e(")")}return t},o=function(){var t,r,i;for(t=s(),i=a();"x"===i||"/"===i;)e(i),r=s(),t={type:i,left:t,right:r},i=a();return t},(i=function(){var t,r,i;for(t=o(),i=a();"+"===i||"-"===i;)e(i),r=o(),t={type:i,left:t,right:r},i=a();return t})()},e.exports={tokenize:h,isNumber:n,parse:s}},{}],4:[function(t,e){var r,i,o,n;o=t("./pad-shapes"),i=t("./macro-calc"),n=t("./unique-id"),r=function(){function t(t){this.modifiers={},this.name=t[0].slice(2),this.blocks=t.slice(1),this.shapes=[],this.masks=[],this.bbox=[null,null,null,null]}return t.prototype.run=function(t,e){var r,i,o,s,h,a,l,u,c,x,f,p,d,y,b,w,g,m,v;for(null==e&&(e=[]),o=c=0,d=e.length;d>c;o=++c)s=e[o],this.modifiers["$"+(o+1)]=s;for(g=this.blocks,x=0,y=g.length;y>x;x++)r=g[x],this.runBlock(r);for(a="tool-"+t+"-pad-"+n(),h=[],m=this.masks,f=0,b=m.length;b>f;f++)s=m[f],h.push(s);if(this.shapes.length>1){for(i={id:a,_:[]},v=this.shapes,p=0,w=v.length;w>p;p++)l=v[p],i._.push(l);h=[{g:i}]}else 1===this.shapes.length&&(u=Object.keys(this.shapes[0])[0],this.shapes[0][u].id=a,h.push(this.shapes[0]));return{pad:h,padId:a,bbox:this.bbox,trace:!1}},t.prototype.runBlock=function(t){var e,r,i,o,n,s,h,a;switch(t[0]){case"$":return o=null!=(a=t.match(/^\$\d+(?=\=)/))?a[0]:void 0,n=t.slice(1+o.length),this.modifiers[o]=this.getNumber(n);case"1":case"2":case"20":case"21":case"22":case"4":case"5":case"6":case"7":for(r=t.split(","),i=s=0,h=r.length;h>s;i=++s)e=r[i],r[i]=this.getNumber(e);return this.primitive(r);default:if("0"!==t[0])throw new SyntaxError("'"+t+"' unrecognized tool macro block")}},t.prototype.primitive=function(t){var e,r,i,s,h,a,l,u,c,x,f,p,d,y,b,w,g,m,v,M,k,E,S,q,T,R,L,I,_;switch(h=!1,c=!1,f=null,t[0]){case 1:f=o.circle({dia:t[2],cx:t[3],cy:t[4]}),0===t[1]?h=!0:this.addBbox(f.bbox);break;case 2:case 20:f=o.vector({width:t[2],x1:t[3],y1:t[4],x2:t[5],y2:t[6]}),t[7]&&(f.shape.line.transform="rotate("+t[7]+")"),0===t[1]?h=!0:this.addBbox(f.bbox,t[7]);break;case 21:f=o.rect({cx:t[4],cy:t[5],width:t[2],height:t[3]}),t[6]&&(f.shape.rect.transform="rotate("+t[6]+")"),0===t[1]?h=!0:this.addBbox(f.bbox,t[6]);break;case 22:f=o.lowerLeftRect({x:t[4],y:t[5],width:t[2],height:t[3]}),t[6]&&(f.shape.rect.transform="rotate("+t[6]+")"),0===t[1]?h=!0:this.addBbox(f.bbox,t[6]);break;case 4:for(l=[],r=p=3,S=3+2*t[2];S>=p;r=p+=2)l.push([t[r],t[r+1]]);f=o.outline({points:l}),(u=t[t.length-1])&&(f.shape.polygon.transform="rotate("+u+")"),0===t[1]?h=!0:this.addBbox(f.bbox,t[t.length-1]);break;case 5:if(0!==t[6]&&(0!==t[3]||0!==t[4]))throw new RangeError("polygon center must be 0,0 if rotated in macro");f=o.polygon({cx:t[3],cy:t[4],dia:t[5],verticies:t[2],degrees:t[6]}),0===t[1]?h=!0:this.addBbox(f.bbox);break;case 6:if(0!==t[9]&&(0!==t[1]||0!==t[2]))throw new RangeError("moiré center must be 0,0 if rotated in macro");if(f=o.moire({cx:t[1],cy:t[2],outerDia:t[3],ringThx:t[4],ringGap:t[5],maxRings:t[6],crossThx:t[7],crossLength:t[8]}),t[9])for(q=f.shape,d=0,w=q.length;w>d;d++)x=q[d],null!=x.line&&(x.line.transform="rotate("+t[9]+")");this.addBbox(f.bbox,t[9]);break;case 7:if(0!==t[9]&&(0!==t[1]||0!==t[2]))throw new RangeError("thermal center must be 0,0 if rotated in macro");if(f=o.thermal({cx:t[1],cy:t[2],outerDia:t[3],innerDia:t[4],gap:t[5]}),t[6])for(T=f.shape,y=0,g=T.length;g>y;y++)if(x=T[y],null!=x.mask)for(R=x.mask._,b=0,m=R.length;m>b;b++)s=R[b],null!=s.rect&&(s.rect.transform="rotate("+t[6]+")");this.addBbox(f.bbox,t[6]);break;default:throw new SyntaxError(""+t[0]+" is not a valid primitive code")}if(h){for(i in f.shape)f.shape[i].fill="#000";if(a="macro-"+this.name+"-mask-"+n(),s={mask:{id:a,_:[{rect:{x:this.bbox[0],y:this.bbox[1],width:this.bbox[2]-this.bbox[0],height:this.bbox[3]-this.bbox[1],fill:"#fff"}},f.shape]}},1===this.shapes.length)for(i in this.shapes[0])this.shapes[0][i].mask="url(#"+a+")";else if(this.shapes.length>1){for(e={mask:"url(#"+a+")",_:[]},L=this.shapes,k=0,v=L.length;v>k;k++)x=L[k],e._.push(x);this.shapes=[{g:e}]}return this.masks.push(s)}if(Array.isArray(f.shape)){for(I=f.shape,_=[],E=0,M=I.length;M>E;E++)x=I[E],_.push(null!=x.mask?this.masks.push(x):this.shapes.push(x));return _}return this.shapes.push(f.shape)},t.prototype.addBbox=function(t,e){var r,i,o,n,s,h,a,l,u;if(null==e&&(e=0),e){for(n=Math.sin(e*Math.PI/180),r=Math.cos(e*Math.PI/180),Math.abs(n)<1e-9&&(n=0),Math.abs(r)<1e-9&&(r=0),o=[[t[0],t[1]],[t[2],t[1]],[t[2],t[3]],[t[0],t[3]]],u=[],a=0,l=o.length;l>a;a++)i=o[a],s=i[0]*r-i[1]*n,h=i[0]*n+i[1]*r,(null===this.bbox[0]||s<this.bbox[0])&&(this.bbox[0]=s),(null===this.bbox[1]||h<this.bbox[1])&&(this.bbox[1]=h),(null===this.bbox[2]||s>this.bbox[2])&&(this.bbox[2]=s),u.push(null===this.bbox[3]||h>this.bbox[3]?this.bbox[3]=h:void 0);return u}return(null===this.bbox[0]||t[0]<this.bbox[0])&&(this.bbox[0]=t[0]),(null===this.bbox[1]||t[1]<this.bbox[1])&&(this.bbox[1]=t[1]),(null===this.bbox[2]||t[2]>this.bbox[2])&&(this.bbox[2]=t[2]),null===this.bbox[3]||t[3]>this.bbox[3]?this.bbox[3]=t[3]:void 0},t.prototype.getNumber=function(t){return t.match(/^[+-]?[\d.]+$/)?parseFloat(t):t.match(/^\$\d+$/)?parseFloat(this.modifiers[t]):this.evaluate(i.parse(t))},t.prototype.evaluate=function(t){switch(t.type){case"n":return this.getNumber(t.val);case"+":return this.evaluate(t.left)+this.evaluate(t.right);case"-":return this.evaluate(t.left)-this.evaluate(t.right);case"x":return this.evaluate(t.left)*this.evaluate(t.right);case"/":return this.evaluate(t.left)/this.evaluate(t.right)}},t}(),e.exports=r},{"./macro-calc":3,"./pad-shapes":6,"./unique-id":9}],5:[function(t,e){var r,i,o,n;n=function(t,e){var r;if(r="",0===e)return"";for(;e>1;)1&e&&(r+=t),e>>=1,t+=t;return r+t},r="_",i=" ",o=function(t,e){var s,h,a,l,u,c,x,f,p,d,y,b,w,g,m;if(null==e&&(e={}),f=e.pretty,l=null!=(g=e.indent)?g:0,c=f?"\n":"",p=c?"string"==typeof f?f:i:"",p=n(p,l),y="",Array.isArray(t))for(a=b=0,w=t.length;w>b;a=++b)x=t[a],y+=(0!==a?c:"")+o(x,e);else if(s=!1,h=Object.keys(t)[0],null!=h){y=""+p+"<"+h,m=t[h];for(u in m)d=m[u],u===r?s=d:y+=" "+u+'="'+d+'"';s&&(y+=">"+c+o(s,{pretty:f,indent:l+1})),y+=null!=t[h]._?""+c+p+"</"+h+">":"/>"}return y},e.exports=o},{}],6:[function(t,e){var r,i,o,n,s,h,a,l,u;l=t("./unique-id"),r=function(t){var e;if(null==t.dia)throw new SyntaxError("circle function requires diameter");if(null==t.cx)throw new SyntaxError("circle function requires x center");if(null==t.cy)throw new SyntaxError("circle function requires y center");return e=t.dia/2,{shape:{circle:{cx:t.cx,cy:t.cy,r:e,"stroke-width":0,fill:"currentColor"}},bbox:[t.cx-e,t.cy-e,t.cx+e,t.cy+e]}},h=function(t){var e,r,i,o;if(null==t.width)throw new SyntaxError("rectangle requires width");if(null==t.height)throw new SyntaxError("rectangle requires height");if(null==t.cx)throw new SyntaxError("rectangle function requires x center");if(null==t.cy)throw new SyntaxError("rectangle function requires y center");return i=t.cx-t.width/2,o=t.cy-t.height/2,r={shape:{rect:{x:i,y:o,width:t.width,height:t.height,"stroke-width":0,fill:"currentColor"}},bbox:[i,o,i+t.width,o+t.height]},t.obround&&(e=.5*Math.min(t.width,t.height),r.shape.rect.rx=e,r.shape.rect.ry=e),r},s=function(t){var e,r,i,o,n,s,h,a,l,u,c,x,f,p,d,y;if(null==t.dia)throw new SyntaxError("polygon requires diameter");if(null==t.verticies)throw new SyntaxError("polygon requires verticies");if(null==t.cx)throw new SyntaxError("polygon function requires x center");if(null==t.cy)throw new SyntaxError("polygon function requires y center");for(s=null!=t.degrees?t.degrees*Math.PI/180:0,h=2*Math.PI/t.verticies,i=t.dia/2,r="",c=null,p=null,u=null,f=null,e=d=0,y=t.verticies;y>=0?y>d:d>y;e=y>=0?++d:--d)a=s+e*h,o=i*Math.cos(a),n=i*Math.sin(a),Math.abs(o)<1e-9&&(o=0),Math.abs(n)<1e-9&&(n=0),l=t.cx+o,x=t.cy+n,(c>l||null===c)&&(c=l),(l>u||null===u)&&(u=l),(p>x||null===p)&&(p=x),(x>f||null===f)&&(f=x),r+=" "+l+","+x;return{shape:{polygon:{points:r.slice(1),"stroke-width":0,fill:"currentColor"}},bbox:[c,p,u,f]}},u=function(t){var e,r,i;if(null==t.x1)throw new SyntaxError("vector function requires start x");if(null==t.y1)throw new SyntaxError("vector function requires start y");if(null==t.x2)throw new SyntaxError("vector function requires end x");if(null==t.y2)throw new SyntaxError("vector function requires end y");if(null==t.width)throw new SyntaxError("vector function requires width");return e=Math.abs(Math.atan((t.y2-t.y1)/(t.x2-t.x1))),r=t.width/2*Math.sin(e),i=t.width/2*Math.cos(e),1e-7>r&&(r=0),1e-7>i&&(i=0),{shape:{line:{x1:t.x1,x2:t.x2,y1:t.y1,y2:t.y2,"stroke-width":t.width,stroke:"currentColor"}},bbox:[Math.min(t.x1,t.x2)-r,Math.min(t.y1,t.y2)-i,Math.max(t.x1,t.x2)+r,Math.max(t.y1,t.y2)+i]}},i=function(t){if(null==t.width)throw new SyntaxError("lower left rect requires width");if(null==t.height)throw new SyntaxError("lower left rect requires height");if(null==t.x)throw new SyntaxError("lower left rectangle requires x");if(null==t.y)throw new SyntaxError("lower left rectangle requires y");return{shape:{rect:{x:t.x,y:t.y,width:t.width,height:t.height,"stroke-width":0,fill:"currentColor"}},bbox:[t.x,t.y,t.x+t.width,t.y+t.height]}},n=function(t){var e,r,i,o,n,s,h,a,l,u,c,x,f;if(!(Array.isArray(t.points)&&t.points.length>1))throw new SyntaxError("outline function requires points array");for(s=null,u=null,n=null,l=null,r="",f=t.points,c=0,x=f.length;x>c;c++){if(e=f[c],!Array.isArray(e)||2!==e.length)throw new SyntaxError("outline function requires points array");i=e[0],h=e[1],(s>i||null===s)&&(s=i),(i>n||null===n)&&(n=i),(u>h||null===u)&&(u=h),(h>l||null===l)&&(l=h),r+=" "+i+","+h}if(o=t.points[t.points.length-1][0],a=t.points[t.points.length-1][1],o!==t.points[0][0]||a!==t.points[0][1])throw new RangeError("last point must match first point of outline");return{shape:{polygon:{points:r.slice(1),"stroke-width":0,fill:"currentColor"}},bbox:[s,u,n,l]}},o=function(t){var e,r,i;if(null==t.cx)throw new SyntaxError("moiré requires x center");if(null==t.cy)throw new SyntaxError("moiré requires y center");if(null==t.outerDia)throw new SyntaxError("moiré requires outer diameter");if(null==t.ringThx)throw new SyntaxError("moiré requires ring thickness");if(null==t.ringGap)throw new SyntaxError("moiré requires ring gap");if(null==t.maxRings)throw new SyntaxError("moiré requires max rings");if(null==t.crossLength)throw new SyntaxError("moiré requires crosshair length");if(null==t.crossThx)throw new SyntaxError("moiré requires crosshair thickness");for(i=[{line:{x1:t.cx-t.crossLength/2,y1:0,x2:t.cx+t.crossLength/2,y2:0,"stroke-width":t.crossThx,stroke:"currentColor"}},{line:{x1:0,y1:t.cy-t.crossLength/2,x2:0,y2:t.cy+t.crossLength/2,"stroke-width":t.crossThx,stroke:"currentColor"}}],e=(t.outerDia-t.ringThx)/2,r=0;e>=t.ringThx&&r<t.maxRings;)i.push({circle:{cx:t.cx,cy:t.cy,r:e,fill:"none","stroke-width":t.ringThx,stroke:"currentColor"}}),r++,e-=t.ringThx+t.ringGap;return e+=.5*t.ringThx,e>0&&r<t.maxRings&&i.push({circle:{cx:t.cx,cy:t.cy,r:e,"stroke-width":0,fill:"currentColor"}}),{shape:i,bbox:[Math.min(t.cx-t.crossLength/2,t.cx-t.outerDia/2),Math.min(t.cy-t.crossLength/2,t.cy-t.outerDia/2),Math.max(t.cx+t.crossLength/2,t.cx+t.outerDia/2),Math.max(t.cy+t.crossLength/2,t.cy+t.outerDia/2)]}},a=function(t){var e,r,i,o,n,s,h,a,u;if(null==t.cx)throw new SyntaxError("thermal requires x center");if(null==t.cy)throw new SyntaxError("thermal requires y center");if(null==t.outerDia)throw new SyntaxError("thermal requires outer diameter");if(null==t.innerDia)throw new SyntaxError("thermal requires inner diameter");if(null==t.gap)throw new SyntaxError("thermal requires gap");return r="thermal-mask-"+l(),n=(t.outerDia-t.innerDia)/2,i=t.outerDia/2,o=i-n/2,h=t.cx-i,s=t.cx+i,u=t.cy-i,a=t.cy+i,e=t.gap/2,{shape:[{mask:{id:r,_:[{circle:{cx:t.cx,cy:t.cy,r:i,"stroke-width":0,fill:"#fff"}},{rect:{x:h,y:-e,width:t.outerDia,height:t.gap,"stroke-width":0,fill:"#000"}},{rect:{x:-e,y:u,width:t.gap,height:t.outerDia,"stroke-width":0,fill:"#000"}}]}},{circle:{cx:t.cx,cy:t.cy,r:o,fill:"none","stroke-width":n,stroke:"currentColor",mask:"url(#"+r+")"}}],bbox:[h,u,s,a]}},e.exports={circle:r,rect:h,polygon:s,vector:u,lowerLeftRect:i,outline:n,moire:o,thermal:a}},{"./unique-id":9}],7:[function(t,e){var r,i,o,n,s,h,a,l,u,c;o=t("./gerber-parser"),c=t("./unique-id"),i=t("./macro-tool"),u=t("./standard-tool"),r=Math.PI/2,s=3*r,h=2*Math.PI,a=function(t){var e,r,i,o,n,s,h,a,l,c;if(i=null!=(a=t.match(/^ADD\d+/))&&null!=(l=a[0])?l.slice(2):void 0,!(null!=i&&parseInt(i.slice(1),10)>9))throw new SyntaxError(""+i+" is an invalid tool code (must be >= 10)");switch(e=null,r=!1,t.slice(2+i.length,4+i.length)){case"C,":n=t.slice(4+i.length).split("X"),h={dia:parseFloat(n[0])},n.length>2?h.hole={width:parseFloat(n[1]),height:parseFloat(n[2])}:n.length>1&&(h.hole={dia:parseFloat(n[1])}),e=u(i,h);break;case"R,":n=t.slice(4+i.length).split("X"),h={width:parseFloat(n[0]),height:parseFloat(n[1])},n.length>3?h.hole={width:parseFloat(n[2]),height:parseFloat(n[3])}:n.length>2&&(h.hole={dia:parseFloat(n[2])}),e=u(i,h);break;case"O,":n=t.slice(4+i.length).split("X"),h={width:parseFloat(n[0]),height:parseFloat(n[1])},n.length>3?h.hole={width:parseFloat(n[2]),height:parseFloat(n[3])}:n.length>2&&(h.hole={dia:parseFloat(n[2])}),h.obround=!0,e=u(i,h);break;case"P,":n=t.slice(4+i.length).split("X"),h={dia:parseFloat(n[0]),verticies:parseFloat(n[1])},null!=n[2]&&(h.degrees=parseFloat(n[2])),n.length>4?h.hole={width:parseFloat(n[3]),height:parseFloat(n[4])}:n.length>3&&(h.hole={dia:parseFloat(n[3])}),e=u(i,h);break;default:if(o=t.slice(2+i.length),s=null!=(c=o.match(/[a-zA-Z_$][a-zA-Z_$.0-9]{0,126}(?=,)?/))?c[0]:void 0,!s)throw new SyntaxError("invalid definition with macro");n=o.slice(s.length+1).split("X"),1===n.length&&""===n[0]&&(n=null),r={name:s,mods:n}}return{macro:r,tool:e,code:i}},l=function(t,e,i,o){var n,s,h,a,l,u,c,x,f;return l=t.x-i/2,u=t.x+i/2,c=t.y-o/2,x=t.y+o/2,n=e.x-i/2,s=e.x+i/2,h=e.y-o/2,a=e.y+o/2,f=Math.atan2(e.y-t.y,e.x-t.x),f>=0&&r>f?"M"+l+" "+c+"L"+u+" "+c+"L"+s+" "+h+"L"+s+" "+a+"L"+n+" "+a+" L"+l+" "+x+"Z":f>=r&&f<Math.PI?"M"+l+" "+c+"L"+u+" "+c+"L"+u+" "+x+"L"+s+" "+a+"L"+n+" "+a+" L"+n+" "+h+"Z":-Math.PI<=f&&-r>f?"M"+u+" "+c+"L"+u+" "+x+"L"+l+" "+x+"L"+n+" "+a+"L"+n+" "+h+" L"+s+" "+h+"Z":f>=-r&&0>f?"M"+l+" "+c+"L"+n+" "+h+"L"+s+" "+h+"L"+s+" "+a+"L"+u+" "+x+" L"+l+" "+x+"Z":void 0},n=function(){function t(t){null==t&&(t=""),this.parser=new o(t),this.macros={},this.tools={},this.currentTool="",this.defs=[],this.gerberId="gerber-"+c(),this.group={g:{id:""+this.gerberId+"-layer-0",_:[]}},this.layer={level:0,type:"g",current:this.group},this.stepRepeat={x:1,y:1,xStep:null,yStep:null,block:0},this.done=!1,this.units=null,this.format={set:!1,zero:null,notation:null,places:null},this.position={x:0,y:0},this.mode=null,this.trace={region:!1,path:""},this.quad=null,this.bbox={xMin:1/0,yMin:1/0,xMax:-1/0,yMax:-1/0}}return t.prototype.plot=function(){for(var t;!this.done;){if(t=this.parser.nextCommand(),t===!1)throw new Error("end of file encountered before required M02 command");"%"===t[0]?this.parameter(t):this.operate(t[0])}return this.finish()},t.prototype.finish=function(){return this.finishTrace(),this.finishStepRepeat()},t.prototype.parameter=function(t){var e,r,o,n,s,h,l,u,c,x,f,p,d,y,b,w,g,m,v,M,k,E,S,q;if(o=!1,"%"===t[0]&&"%"!==t[t.length-1])throw new SyntaxError("@parameter should only be called with paramters");for(t=t.slice(1),l=0,q=[];!o;){switch(r=t[l],r.slice(0,2)){case"FS":if(u=!1,this.format.set)throw new SyntaxError("format spec cannot be redefined");try{"L"===r[2]||"T"===r[2]?this.format.zero=r[2]:u=!0,"A"===r[3]||"I"===r[3]?this.format.notation=r[3]:u=!0,"X"===r[4]&&"Y"===r[7]&&r.slice(5,7)===r.slice(8,10)?(this.format.places=[parseInt(r[5],10),parseInt(r[6],10)],(this.format.places[0]>7||this.format.places[1]>7)&&(u=!0)):u=!0}catch(T){n=T,u=!0}if(u)throw new SyntaxError("invalid format spec");this.format.set=!0;break;case"MO":if(y=r.slice(2),null!=this.units)throw new SyntaxError("gerber file may not redifine units");if("MM"===y)this.units="mm";else{if("IN"!==y)throw new SyntaxError(""+y+" are unrecognized units");this.units="in"}break;case"AD":if(e=a(t[l]),null!=this.tools[e.code])throw new SyntaxError("duplicate tool code");e.macro&&(e.tool=this.macros[e.macro.name].run(e.code,e.macro.mods)),this.tools[e.code]={stroke:e.tool.trace,pad:function(){var t,r,i,o;for(i=e.tool.pad,o=[],t=0,r=i.length;r>t;t++)f=i[t],o.push(f);return o}(),flash:function(t,r){return{use:{x:t,y:r,"xlink:href":"#"+e.tool.padId}}},bbox:function(t,r){return null==t&&(t=0),null==r&&(r=0),{xMin:t+e.tool.bbox[0],yMin:r+e.tool.bbox[1],xMax:t+e.tool.bbox[2],yMax:r+e.tool.bbox[3]}}},this.currentTool=e.code;break;case"AM":c=new i(t.slice(0,-1)),this.macros[c.name]=c,o=!0;break;case"SR":this.finishTrace(),this.finishStepRepeat(),this.stepRepeat.x=Number(null!=(m=null!=(v=r.match(/X\d+/))?v[0].slice(1):void 0)?m:1),this.stepRepeat.y=Number(null!=(M=null!=(k=r.match(/Y\d+/))?k[0].slice(1):void 0)?M:1),this.stepRepeat.x>1&&(this.stepRepeat.xStep=Number(null!=(E=r.match(/I[\d\.]+/))?E[0].slice(1):void 0)),this.stepRepeat.y>1&&(this.stepRepeat.yStep=Number(null!=(S=r.match(/J[\d\.]+/))?S[0].slice(1):void 0)),(1!==this.stepRepeat.x||1!==this.stepRepeat.y)&&0===this.layer.level&&(d={g:{id:""+this.gerberId+"-sr-block-"+this.stepRepeat.block,_:[]}},this.layer.current[this.layer.type]._.push(d),this.layer.current=d);break;case"LP":if(this.finishTrace(),p=r[2],"D"!==p&&"C"!==p)throw new SyntaxError(""+r+" is an unrecognized level polarity");"D"===p&&"mask"===this.layer.type?(s=""+this.gerberId+"-layer-"+ ++this.layer.level,this.group={g:{id:s,_:[this.group]}},this.layer.current=this.group,this.layer.type="g"):"C"===p&&"g"===this.layer.type&&(x=""+this.gerberId+"-layer-"+ ++this.layer.level,w=this.bbox.xMin,g=this.bbox.yMin,b=this.bbox.xMax-this.bbox.xMin,h=this.bbox.yMax-this.bbox.yMin,c={mask:{id:x,color:"#000",_:[{rect:{x:w,y:g,width:b,height:h,fill:"#fff"}}]}},this.defs.push(c),this.layer.current.g.mask="url(#"+x+")",this.layer.current=this.defs[this.defs.length-1],this.layer.type="mask"),this.position.x=null,this.position.y=null}q.push("%"===t[++l]?o=!0:void 0)}return q},t.prototype.operate=function(t){var e,i,o,n,a,u,c,x,f,p,d,y,b,w,g,m,v,M,k,E,S,q,T,R,L,I,_,D,F,C,B,G,A,j,P,N,z,$,X,O,U,Z,Y,J,H;if(S=!1,o=t.slice(0,3),"M"===t[0]){if("M02"===o)this.done=!0,t="";else if("M00"!==o&&"M01"!==o)throw new SyntaxError("invalid operation M code");S=!0}else if("G"===t[0]){if(t.match(/^G0?1/))this.mode="i";else if(t.match(/^G0?2/))this.mode="cw";else if(t.match(/^G0?3(?![67])/))this.mode="ccw";else if("G36"===o)this.finishTrace(),this.trace.region=!0;else if("G37"===o)this.finishTrace(),this.trace.region=!1;else if("G74"===o)this.quad="s";else if("G75"===o)this.quad="m";else if("G70"===o)this.backupUnits="in";else if("G71"===o)this.backupUnits="mm";else if(!o.match(/^G(0?4)|(5[45])|(7[01])|(9[01])/))throw new SyntaxError("invalid operation G code");S=!0}if(v=null!=(X=t.match(/D[1-9]\d{1,}$/))?X[0]:void 0,null!=v){if(this.finishTrace(),null==this.tools[v])throw new SyntaxError("tool "+v+" does not exist");if(this.trace.region)throw new SyntaxError("cannot change tool while region mode is on");this.currentTool=v}if(t.match(/^(G0?[123])?([XYIJ][+-]?\d+){0,4}D0?[123]$/)){if(y=t[t.length-1],n=null!=(O=null!=(U=t.match(/[XYIJ][+-]?\d+/g))?U.join(""):void 0)?O:"",g={x:this.position.x,y:this.position.y},x=this.move(n),"3"===y){if(this.finishTrace(),this.tools[this.currentTool].pad){for(Z=this.tools[this.currentTool].pad,B=0,P=Z.length;P>B;B++)d=Z[B],this.defs.push(d);this.tools[this.currentTool].pad=!1}return this.layer.current[this.layer.type]._.push(this.tools[this.currentTool].flash(this.position.x,this.position.y)),this.addBbox(this.tools[this.currentTool].bbox(this.position.x,this.position.y))}if("1"===y){if(!this.trace.region&&!this.tools[this.currentTool].stroke)throw new Error("tool "+this.currentTool+" is not a strokeable tool");if(this.trace.path||(this.trace.path="M"+g.x+" "+g.y,"i"===this.mode&&this.addBbox(this.trace.region?{xMin:g.x,yMin:g.y,xMax:g.x,yMax:g.y}:this.tools[this.currentTool].bbox(g.x,g.y))),null==this.mode&&(this.mode="i"),"i"===this.mode)return this.trace.region||null!=this.tools[this.currentTool].stroke["stroke-linecap"]?this.trace.path+="L"+x.x+" "+x.y:(q=this.tools[this.currentTool].pad[0].rect.width,f=this.tools[this.currentTool].pad[0].rect.height,this.trace.path+=l(g,x,q,f)),this.addBbox(this.trace.region?{xMin:x.x,yMin:x.y,xMax:x.x,yMax:x.y}:this.tools[this.currentTool].bbox(x.x,x.y));if("cw"===this.mode||"ccw"===this.mode){if("round"!==this.tools[this.currentTool].stroke["stroke-linecap"])throw new Error("tool "+this.currentTool+" is not circular and cannot stroke arcs");if(b=Math.sqrt(Math.pow(x.i,2)+Math.pow(x.j,2)),m="cw"===this.mode?0:1,p=0,i=[],k=0,E=0,"s"===this.quad)for(Y=[g.x-x.i,g.x+x.i],G=0,N=Y.length;N>G;G++)for(a=Y[G],J=[g.y-x.j,g.y+x.j],A=0,z=J.length;z>A;A++)u=J[A],c=Math.sqrt(Math.pow(a-x.x,2)+Math.pow(u-x.y,2)),Math.abs(b-c)<1e-7&&i.push({x:a,y:u});else"m"===this.quad&&i.push({x:g.x+x.i,y:g.y+x.j});for(j=0,$=i.length;$>j;j++)if(e=i[j],k=Math.atan2(x.y-e.y,x.x-e.x),0>k&&(k+=h),E=Math.atan2(g.y-e.y,g.x-e.x),0>E&&(E+=h),"cw"===this.mode&&k>E?E+=h:"ccw"===this.mode&&E>k&&(k+=h),M=Math.abs(k-E),!("s"===this.quad&&Math.abs(k-E)>r)){"m"===this.quad&&M>=Math.PI&&(p=1),i={x:e.x,y:e.y};break}return w=this.trace.region?0:this.tools[this.currentTool].bbox().xMax,"cw"===this.mode&&(H=[E,k],k=H[0],E=H[1]),I=E>0?h:0,C=r+(E>r?h:0),L=Math.PI+(E>Math.PI?h:0),F=s+(E>s?h:0),R=L>=E&&k>=L?i.x-b-w:Math.min(g.x,x.x)-w,T=I>=E&&k>=I?i.x+b+w:Math.max(g.x,x.x)+w,D=F>=E&&k>=F?i.y-b-w:Math.min(g.y,x.y)-w,_=C>=E&&k>=C?i.y+b+w:Math.max(g.y,x.y)+w,"m"===this.quad&&Math.abs(g.x-x.x)<1e-6&&Math.abs(g.y-x.y)<1e-6&&(this.trace.path+="A"+b+" "+b+" 0 0 "+m+" "+(x.x+2*x.i)+" "+(x.y+2*x.j),R=i.x-b-w,D=i.y-b-w,T=i.x+b+w,_=i.y+b+w),this.trace.path+="A"+b+" "+b+" 0 "+p+" "+m+" "+x.x+" "+x.y,this.addBbox({xMin:R,yMin:D,xMax:T,yMax:_})}throw new SyntaxError("cannot interpolate without a G01/2/3")}if("2"===y)return this.finishTrace();throw new SyntaxError(""+y+" is an invalid operation (D) code")}},t.prototype.finishStepRepeat=function(){var t,e,r,i,o,n;if(1!==this.stepRepeat.x||1!==this.stepRepeat.y){if(0!==this.layer.level)throw new Error("step repeat with clear levels is unimplimented");for(t=this.layer.current.g.id,this.layer.current=this.group,n=[],e=i=0,o=this.stepRepeat.x;o>=0?o>i:i>o;e=o>=0?++i:--i)n.push(function(){var i,o,n;for(n=[],r=i=0,o=this.stepRepeat.y;o>=0?o>i:i>o;r=o>=0?++i:--i)n.push(0!==e||0!==r?this.layer.current[this.layer.type]._.push({use:{x:e*this.stepRepeat.xStep,y:r*this.stepRepeat.yStep,"xlink:href":t}}):void 0);return n}.call(this));return n}},t.prototype.finishTrace=function(){var t,e,r,i;if(this.trace.path){if(e={path:{d:this.trace.path}},this.trace.region)e.path["stroke-width"]=0,e.path.fill="currentColor";else{i=this.tools[this.currentTool].stroke;for(t in i)r=i[t],e.path[t]=r}return this.layer.current[this.layer.type]._.push(e),this.trace.path=""}},t.prototype.move=function(t){var e;if(null==this.units){if(null==this.backupUnits)throw new Error("units have not been set");this.units=this.backupUnits}return e=this.coordinate(t),this.position.x=e.x,this.position.y=e.y,e},t.prototype.coordinate=function(t){var e,r,i,o,n,s,h,a,l,u,c,x,f;if(!this.format.set)throw new SyntaxError("format undefined");i={x:0,y:0},i.x=null!=(n=t.match(/X[+-]?\d+/))&&null!=(s=n[0])?s.slice(1):void 0,i.y=null!=(h=t.match(/Y[+-]?\d+/))&&null!=(a=h[0])?a.slice(1):void 0,i.i=null!=(l=t.match(/I[+-]?\d+/))&&null!=(u=l[0])?u.slice(1):void 0,i.j=null!=(c=t.match(/J[+-]?\d+/))&&null!=(x=c[0])?x.slice(1):void 0;for(r in i)if(o=i[r],null!=o){if(e=1,("+"===o[0]||"-"===o[0])&&("-"===o[0]&&(e=-1),o=o.slice(1)),"L"===this.format.zero)e*=Math.pow(10,this.format.places[1]);else{if("T"!==this.format.zero)throw new SyntaxError("invalid zero suppression format");e*=Math.pow(10,o.length-this.format.places[0])}i[r]=Number(o)/e,"I"===this.format.notation&&(i[r]+=null!=(f=this.position[r])?f:0)}return null==i.x&&(i.x=this.position.x),null==i.y&&(i.y=this.position.y),null==i.i&&(i.i=0),null==i.j&&(i.j=0),i},t.prototype.addBbox=function(t){return t.xMin<this.bbox.xMin&&(this.bbox.xMin=t.xMin),t.yMin<this.bbox.yMin&&(this.bbox.yMin=t.yMin),t.xMax>this.bbox.xMax&&(this.bbox.xMax=t.xMax),t.yMax>this.bbox.yMax?this.bbox.yMax=t.yMax:void 0},t}(),e.exports=n},{"./gerber-parser":2,"./macro-tool":4,"./standard-tool":8,"./unique-id":9}],8:[function(t,e){var r,i,o;o=t("./unique-id"),r=t("./pad-shapes"),i=function(t,e){var i,n,s,h,a,l,u;if(l={pad:[],trace:!1},e.cx=0,e.cy=0,n="tool-"+t+"-pad-"+o(),u="",null!=e.dia&&null==e.verticies){if(null!=e.obround||null!=e.width||null!=e.height||null!=e.degrees)throw new Error("incompatible parameters for tool "+t);if(e.dia<0)throw new RangeError(""+t+" circle diameter out of range ("+e.dia+"<0)");u="circle",null==e.hole&&(l.trace={"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":e.dia,stroke:"currentColor",fill:"none"})}else if(null!=e.width&&null!=e.height){if(null!=e.dia||null!=e.verticies||null!=e.degrees)throw new Error("incompatible parameters for tool "+t);if(e.width<=0)throw new RangeError(""+t+" rect width out of range ("+e.width+"<=0)");if(e.height<=0)throw new RangeError(""+t+" rect height out of range ("+e.height+"<=0)");u="rect",null!=e.hole||e.obround||(l.trace={"stroke-width":0,fill:"currentColor"})}else{if(null==e.dia||null==e.verticies)throw new Error("unidentified standard tool shape");if(null!=e.obround||null!=e.width||null!=e.height)throw new Error("incompatible parameters for tool "+t);if(e.verticies<3||e.verticies>12)throw new RangeError(""+t+" polygon points out of range ("+e.verticies+"<3 or >12)]");u="polygon"}if(a=r[u](e),null!=e.hole){if(i=null,null!=e.hole.dia&&null==e.hole.width&&null==e.hole.height){if(!(e.hole.dia>=0))throw new RangeError(""+t+" hole diameter out of range ("+e.hole.dia+"<0)");i=r.circle({cx:e.cx,cy:e.cy,dia:e.hole.dia}),i=i.shape,i.circle.fill="#000"}else{if(null==e.hole.width||null==e.hole.height)throw new Error(""+t+" has invalid hole parameters");if(!(e.hole.width>=0))throw new RangeError(""+t+" hole width out of range ("+e.hole.width+"<0)");if(!(e.hole.height>=0))throw new RangeError(""+t+" hole height out of range");i=r.rect({cx:e.cx,cy:e.cy,width:e.hole.width,height:e.hole.height}),i=i.shape,i.rect.fill="#000"}h=n+"-mask",s={mask:{id:n+"-mask",_:[{rect:{x:a.bbox[0],y:a.bbox[1],width:a.bbox[2]-a.bbox[0],height:a.bbox[3]-a.bbox[1],fill:"#fff"}},i]}},a.shape[u].mask="url(#"+h+")",l.pad.push(s)}return n&&(a.shape[u].id=n),l.pad.push(a.shape),l.bbox=a.bbox,l.padId=n,l},e.exports=i},{"./pad-shapes":6,"./unique-id":9}],9:[function(t,e){var r,i;i=1e3,r=function(){return i++},e.exports=r},{}]},{},[1])(1)}); |
(function() { | ||
var Macro, Parser, Plotter, parseAD, tool, unique; | ||
var HALF_PI, Macro, Parser, Plotter, THREEHALF_PI, TWO_PI, parseAD, rectangleStrokePath, tool, unique; | ||
@@ -12,2 +12,8 @@ Parser = require('./gerber-parser'); | ||
HALF_PI = Math.PI / 2; | ||
THREEHALF_PI = 3 * HALF_PI; | ||
TWO_PI = 2 * Math.PI; | ||
parseAD = function(block) { | ||
@@ -119,2 +125,24 @@ var ad, am, code, def, mods, name, params, _ref, _ref1, _ref2; | ||
rectangleStrokePath = function(start, end, width, height) { | ||
var exm, exp, eym, eyp, sxm, sxp, sym, syp, theta; | ||
sxm = start.x - width / 2; | ||
sxp = start.x + width / 2; | ||
sym = start.y - height / 2; | ||
syp = start.y + height / 2; | ||
exm = end.x - width / 2; | ||
exp = end.x + width / 2; | ||
eym = end.y - height / 2; | ||
eyp = end.y + height / 2; | ||
theta = Math.atan2(end.y - start.y, end.x - start.x); | ||
if ((0 <= theta && theta < HALF_PI)) { | ||
return "M" + sxm + " " + sym + "L" + sxp + " " + sym + "L" + exp + " " + eym + "L" + exp + " " + eyp + "L" + exm + " " + eyp + " L" + sxm + " " + syp + "Z"; | ||
} else if ((HALF_PI <= theta && theta < Math.PI)) { | ||
return "M" + sxm + " " + sym + "L" + sxp + " " + sym + "L" + sxp + " " + syp + "L" + exp + " " + eyp + "L" + exm + " " + eyp + " L" + exm + " " + eym + "Z"; | ||
} else if ((-Math.PI <= theta && theta < -HALF_PI)) { | ||
return "M" + sxp + " " + sym + "L" + sxp + " " + syp + "L" + sxm + " " + syp + "L" + exm + " " + eyp + "L" + exm + " " + eym + " L" + exp + " " + eym + "Z"; | ||
} else if ((-HALF_PI <= theta && theta < 0)) { | ||
return "M" + sxm + " " + sym + "L" + exm + " " + eym + "L" + exp + " " + eym + "L" + exp + " " + eyp + "L" + sxp + " " + syp + " L" + sxm + " " + syp + "Z"; | ||
} | ||
}; | ||
Plotter = (function() { | ||
@@ -388,3 +416,3 @@ function Plotter(file) { | ||
Plotter.prototype.operate = function(block) { | ||
var c, cen, code, coord, cx, cy, dist, end, large, obj, op, r, rTool, start, sweep, t, theta, thetaE, thetaS, valid, xMax, xMin, yMax, yMin, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref10, _ref11, _ref12, _ref13, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9; | ||
var c, cen, code, coord, cx, cy, dist, end, height, large, obj, op, r, rTool, start, sweep, t, theta, thetaE, thetaS, valid, width, xMax, xMin, xn, xp, yMax, yMin, yn, yp, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6; | ||
valid = false; | ||
@@ -458,2 +486,5 @@ code = block.slice(0, 3); | ||
} else if (op === '1') { | ||
if (!this.trace.region && !this.tools[this.currentTool].stroke) { | ||
throw new Error("tool " + this.currentTool + " is not a strokeable tool"); | ||
} | ||
if (!this.trace.path) { | ||
@@ -479,3 +510,9 @@ this.trace.path = "M" + start.x + " " + start.y; | ||
if (this.mode === 'i') { | ||
this.trace.path += "L" + end.x + " " + end.y; | ||
if (this.trace.region || (this.tools[this.currentTool].stroke['stroke-linecap'] != null)) { | ||
this.trace.path += "L" + end.x + " " + end.y; | ||
} else { | ||
width = this.tools[this.currentTool].pad[0].rect.width; | ||
height = this.tools[this.currentTool].pad[0].rect.height; | ||
this.trace.path += rectangleStrokePath(start, end, width, height); | ||
} | ||
if (this.trace.region) { | ||
@@ -492,2 +529,5 @@ return this.addBbox({ | ||
} else if (this.mode === 'cw' || this.mode === 'ccw') { | ||
if (this.tools[this.currentTool].stroke['stroke-linecap'] !== 'round') { | ||
throw new Error("tool " + this.currentTool + " is not circular and cannot stroke arcs"); | ||
} | ||
r = Math.sqrt(Math.pow(end.i, 2) + Math.pow(end.j, 2)); | ||
@@ -525,15 +565,15 @@ sweep = this.mode === 'cw' ? 0 : 1; | ||
if (thetaE < 0) { | ||
thetaE += 2 * Math.PI; | ||
thetaE += TWO_PI; | ||
} | ||
thetaS = Math.atan2(start.y - c.y, start.x - c.x); | ||
if (thetaS < 0) { | ||
thetaS += 2 * Math.PI; | ||
thetaS += TWO_PI; | ||
} | ||
if (this.mode === 'cw' && thetaS < thetaE) { | ||
thetaS += 2 * Math.PI; | ||
thetaS += TWO_PI; | ||
} else if (this.mode === 'ccw' && thetaE < thetaS) { | ||
thetaE += 2 * Math.PI; | ||
thetaE += TWO_PI; | ||
} | ||
theta = Math.abs(thetaE - thetaS); | ||
if (this.quad === 's' && Math.abs(thetaE - thetaS) > Math.PI / 2) { | ||
if (this.quad === 's' && Math.abs(thetaE - thetaS) > HALF_PI) { | ||
continue; | ||
@@ -552,3 +592,10 @@ } else { | ||
rTool = this.trace.region ? 0 : this.tools[this.currentTool].bbox().xMax; | ||
if ((thetaS <= (_ref6 = Math.PI) && _ref6 <= thetaE) || (thetaS >= (_ref7 = Math.PI) && _ref7 >= thetaE)) { | ||
if (this.mode === 'cw') { | ||
_ref6 = [thetaS, thetaE], thetaE = _ref6[0], thetaS = _ref6[1]; | ||
} | ||
xp = thetaS > 0 ? TWO_PI : 0; | ||
yp = HALF_PI + (thetaS > HALF_PI ? TWO_PI : 0); | ||
xn = Math.PI + (thetaS > Math.PI ? TWO_PI : 0); | ||
yn = THREEHALF_PI + (thetaS > THREEHALF_PI ? TWO_PI : 0); | ||
if ((thetaS <= xn && xn <= thetaE)) { | ||
xMin = cen.x - r - rTool; | ||
@@ -558,3 +605,3 @@ } else { | ||
} | ||
if ((thetaS <= (_ref8 = 2 * Math.PI) && _ref8 <= thetaE) || (thetaS >= (_ref9 = 2 * Math.PI) && _ref9 >= thetaE) || (thetaS <= 0 && 0 <= thetaE) || (thetaS >= 0 && 0 >= thetaE)) { | ||
if ((thetaS <= xp && xp <= thetaE)) { | ||
xMax = cen.x + r + rTool; | ||
@@ -564,3 +611,3 @@ } else { | ||
} | ||
if ((thetaS <= (_ref10 = 3 * Math.PI / 2) && _ref10 <= thetaE) || (thetaS >= (_ref11 = 3 * Math.PI / 2) && _ref11 >= thetaE)) { | ||
if ((thetaS <= yn && yn <= thetaE)) { | ||
yMin = cen.y - r - rTool; | ||
@@ -570,3 +617,3 @@ } else { | ||
} | ||
if ((thetaS <= (_ref12 = Math.PI / 2) && _ref12 <= thetaE) || (thetaS >= (_ref13 = Math.PI / 2) && _ref13 >= thetaE)) { | ||
if ((thetaS <= yp && yp <= thetaE)) { | ||
yMax = cen.y + r + rTool; | ||
@@ -573,0 +620,0 @@ } else { |
@@ -48,3 +48,4 @@ (function() { | ||
result.trace = { | ||
'stroke-width': 0 | ||
'stroke-width': 0, | ||
fill: 'currentColor' | ||
}; | ||
@@ -51,0 +52,0 @@ } |
{ | ||
"name": "gerber-to-svg", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"description": "Gerber file to SVG converter", | ||
@@ -5,0 +5,0 @@ "main": "lib/gerber-to-svg.js", |
@@ -28,9 +28,2 @@ # gerber-to-svg [![Build Status](http://img.shields.io/travis/mcous/gerber-to-svg.svg?style=flat)](https://travis-ci.org/mcous/gerber-to-svg) [![Version](http://img.shields.io/npm/v/gerber-to-svg.svg?style=flat)](https://www.npmjs.org/package/gerber-to-svg) | ||
### build from source | ||
1. `$ git clone https://github.com/mcous/gerber-to-svg.git` | ||
2. `$ npm install && gulp` | ||
Library files for Node and Browserify live in lib/, standalone library files live in dist/, and the command line utility lives in bin/. | ||
## what you get | ||
@@ -46,3 +39,14 @@ Not a whole lot, for now. This converter uses RS-274X and strives to be true to the [latest format specification](http://www.ucamco.com/files/downloads/file/81/the_gerber_file_format_specification.pdf?d69271f6602e26ab2474ad625fe40c97). Most all of the Gerber file features are there. | ||
## if it messes up | ||
Open up an issue and attach your Gerber, if you can. I appreciate files to test on. | ||
If it messes up, open up an issue and attach your Gerber, if you can. I appreciate files to test on. | ||
## building from source | ||
1. `$ git clone https://github.com/mcous/gerber-to-svg.git` | ||
2. `$ npm install && gulp` | ||
Library files for Node and Browserify live in lib/, standalone library files live in dist/, and the command line utility lives in bin/. | ||
### unit testing | ||
This module uses mocha and shouldjs for unit testing. To run the tests once, run `$ gulp test`. To run the tests in watch mode, run `$ gulp testwatch`. | ||
There's also a visual test suite. Run `$ gulp testvisual` and point your browser to http://localhost.com:4242 to take a look. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
152536
3895
51