New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gerber-to-svg

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gerber-to-svg - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

lib/obj-to-xml.js

4

lib/gerber-to-svg.js
(function() {
var Plotter, builder, gerberToSvg;
builder = require('xml');
builder = require('./obj-to-xml');

@@ -19,3 +19,3 @@ Plotter = require('./plotter');

return builder(xmlObject, {
indent: ' '
pretty: true
});

@@ -22,0 +22,0 @@ };

@@ -21,3 +21,3 @@ (function() {

MacroTool.prototype.run = function(tool, modifiers) {
var b, group, i, key, m, pad, padId, s, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2;
var b, group, i, m, pad, padId, s, shape, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2;
if (modifiers == null) {

@@ -43,13 +43,10 @@ modifiers = [];

if (this.shapes.length > 1) {
group = [
{
_attr: {
id: padId
}
}
];
group = {
id: padId,
_: []
};
_ref2 = this.shapes;
for (_l = 0, _len3 = _ref2.length; _l < _len3; _l++) {
s = _ref2[_l];
group.push(s);
group._.push(s);
}

@@ -62,5 +59,4 @@ pad = [

} else if (this.shapes.length === 1) {
for (key in this.shapes[0]) {
this.shapes[0][key]._attr.id = padId;
}
shape = Object.keys(this.shapes[0])[0];
this.shapes[0][shape].id = padId;
pad.push(this.shapes[0]);

@@ -133,3 +129,3 @@ }

if (args[7]) {
shape.shape.line._attr.transform = "rotate(" + args[7] + ")";
shape.shape.line.transform = "rotate(" + args[7] + ")";
}

@@ -150,3 +146,3 @@ if (args[1] === 0) {

if (args[6]) {
shape.shape.rect._attr.transform = "rotate(" + args[6] + ")";
shape.shape.rect.transform = "rotate(" + args[6] + ")";
}

@@ -167,3 +163,3 @@ if (args[1] === 0) {

if (args[6]) {
shape.shape.rect._attr.transform = "rotate(" + args[6] + ")";
shape.shape.rect.transform = "rotate(" + args[6] + ")";
}

@@ -185,3 +181,3 @@ if (args[1] === 0) {

if (rot = args[args.length - 1]) {
shape.shape.polygon._attr.transform = "rotate(" + rot + ")";
shape.shape.polygon.transform = "rotate(" + rot + ")";
}

@@ -230,3 +226,3 @@ if (args[1] === 0) {

if (s.line != null) {
s.line._attr.transform = "rotate(" + args[9] + ")";
s.line.transform = "rotate(" + args[9] + ")";
}

@@ -253,7 +249,7 @@ }

if (s.mask != null) {
_ref3 = s.mask;
_ref3 = s.mask._;
for (_l = 0, _len2 = _ref3.length; _l < _len2; _l++) {
m = _ref3[_l];
if (m.rect != null) {
m.rect._attr.transform = "rotate(" + args[6] + ")";
m.rect.transform = "rotate(" + args[6] + ")";
}

@@ -271,40 +267,34 @@ }

for (key in shape.shape) {
shape.shape[key]._attr.fill = '#000';
shape.shape[key].fill = '#000';
}
maskId = "macro-" + this.name + "-mask-" + (unique());
m = {
mask: [
{
_attr: {
id: maskId
}
}, {
rect: {
_attr: {
x: "" + this.bbox[0],
y: "" + this.bbox[1],
width: "" + (this.bbox[2] - this.bbox[0]),
height: "" + (this.bbox[3] - this.bbox[1]),
mask: {
id: maskId,
_: [
{
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'
}
}
}, shape.shape
]
}, shape.shape
]
}
};
if (this.shapes.length === 1) {
for (key in this.shapes[0]) {
this.shapes[0][key]._attr.mask = "url(#" + maskId + ")";
this.shapes[0][key].mask = "url(#" + maskId + ")";
}
} else if (this.shapes.length > 1) {
group = [
{
_attr: {
mask: "url(#" + maskId + ")"
}
}
];
group = {
mask: "url(#" + maskId + ")",
_: []
};
_ref4 = this.shapes;
for (_m = 0, _len3 = _ref4.length; _m < _len3; _m++) {
s = _ref4[_m];
group.push(s);
group._.push(s);
}

@@ -311,0 +301,0 @@ this.shapes = [

@@ -21,9 +21,7 @@ (function() {

circle: {
_attr: {
cx: "" + p.cx,
cy: "" + p.cy,
r: "" + r,
'stroke-width': '0',
fill: 'currentColor'
}
cx: p.cx,
cy: p.cy,
r: r,
'stroke-width': 0,
fill: 'currentColor'
}

@@ -54,10 +52,8 @@ },

rect: {
_attr: {
x: "" + x,
y: "" + y,
width: "" + p.width,
height: "" + p.height,
'stroke-width': '0',
fill: 'currentColor'
}
x: x,
y: y,
width: p.width,
height: p.height,
'stroke-width': 0,
fill: 'currentColor'
}

@@ -69,4 +65,4 @@ },

radius = 0.5 * Math.min(p.width, p.height);
rectangle.shape.rect._attr.rx = "" + radius;
rectangle.shape.rect._attr.ry = "" + radius;
rectangle.shape.rect.rx = radius;
rectangle.shape.rect.ry = radius;
}

@@ -127,7 +123,5 @@ return rectangle;

polygon: {
_attr: {
points: points.slice(1),
'stroke-width': '0',
fill: 'currentColor'
}
points: points.slice(1),
'stroke-width': 0,
fill: 'currentColor'
}

@@ -168,10 +162,8 @@ },

line: {
_attr: {
x1: "" + p.x1,
x2: "" + p.x2,
y1: "" + p.y1,
y2: "" + p.y2,
'stroke-width': "" + p.width,
stroke: 'currentColor'
}
x1: p.x1,
x2: p.x2,
y1: p.y1,
y2: p.y2,
'stroke-width': p.width,
stroke: 'currentColor'
}

@@ -199,10 +191,8 @@ },

rect: {
_attr: {
x: "" + p.x,
y: "" + p.y,
width: "" + p.width,
height: "" + p.height,
'stroke-width': '0',
fill: 'currentColor'
}
x: p.x,
y: p.y,
width: p.width,
height: p.height,
'stroke-width': 0,
fill: 'currentColor'
}

@@ -254,7 +244,5 @@ },

polygon: {
_attr: {
points: pointString.slice(1),
'stroke-width': '0',
fill: 'currentColor'
}
points: pointString.slice(1),
'stroke-width': 0,
fill: 'currentColor'
}

@@ -295,21 +283,17 @@ },

line: {
_attr: {
x1: "" + (p.cx - p.crossLength / 2),
y1: '0',
x2: "" + (p.cx + p.crossLength / 2),
y2: '0',
'stroke-width': "" + p.crossThx,
stroke: 'currentColor'
}
x1: p.cx - p.crossLength / 2,
y1: 0,
x2: p.cx + p.crossLength / 2,
y2: 0,
'stroke-width': p.crossThx,
stroke: 'currentColor'
}
}, {
line: {
_attr: {
x1: '0',
y1: "" + (p.cy - p.crossLength / 2),
x2: '0',
y2: "" + (p.cy + p.crossLength / 2),
'stroke-width': "" + p.crossThx,
stroke: 'currentColor'
}
x1: 0,
y1: p.cy - p.crossLength / 2,
x2: 0,
y2: p.cy + p.crossLength / 2,
'stroke-width': p.crossThx,
stroke: 'currentColor'
}

@@ -323,10 +307,8 @@ }

circle: {
_attr: {
cx: "" + p.cx,
cy: "" + p.cy,
r: "" + r,
fill: 'none',
'stroke-width': "" + p.ringThx,
stroke: 'currentColor'
}
cx: p.cx,
cy: p.cy,
r: r,
fill: 'none',
'stroke-width': p.ringThx,
stroke: 'currentColor'
}

@@ -340,9 +322,7 @@ });

circle: {
_attr: {
cx: "" + p.cx,
cy: "" + p.cy,
r: "" + r,
'stroke-width': 0,
fill: 'currentColor'
}
cx: p.cx,
cy: p.cy,
r: r,
'stroke-width': 0,
fill: 'currentColor'
}

@@ -386,52 +366,43 @@ });

{
mask: [
{
_attr: {
id: maskId
}
}, {
circle: {
_attr: {
cx: "" + p.cx,
cy: "" + p.cy,
r: "" + outerR,
'stroke-width': '0',
mask: {
id: maskId,
_: [
{
circle: {
cx: p.cx,
cy: p.cy,
r: outerR,
'stroke-width': 0,
fill: '#fff'
}
}
}, {
rect: {
_attr: {
x: "" + xMin,
y: "" + (-halfGap),
width: "" + p.outerDia,
height: "" + p.gap,
}, {
rect: {
x: xMin,
y: -halfGap,
width: p.outerDia,
height: p.gap,
'stroke-width': 0,
fill: "#000"
fill: '#000'
}
}
}, {
rect: {
_attr: {
x: "" + (-halfGap),
y: "" + yMin,
width: "" + p.gap,
height: "" + p.outerDia,
}, {
rect: {
x: -halfGap,
y: yMin,
width: p.gap,
height: p.outerDia,
'stroke-width': 0,
fill: "#000"
fill: '#000'
}
}
}
]
]
}
}, {
circle: {
_attr: {
cx: "" + p.cx,
cy: "" + p.cy,
r: "" + r,
fill: 'none',
'stroke-width': "" + thx,
stroke: 'currentColor',
mask: "url(#" + maskId + ")"
}
cx: p.cx,
cy: p.cy,
r: r,
fill: 'none',
'stroke-width': thx,
stroke: 'currentColor',
mask: "url(#" + maskId + ")"
}

@@ -438,0 +409,0 @@ }

@@ -130,9 +130,6 @@ (function() {

this.group = {
g: [
{
_attr: {
id: "" + this.gerberId + "-layer-0"
}
}
]
g: {
id: "" + this.gerberId + "-layer-0",
_: []
}
};

@@ -197,23 +194,22 @@ this.layer = {

xml = {
svg: [
{
_attr: {
xmlns: 'http://www.w3.org/2000/svg',
version: '1.1',
'xmlns:xlink': 'http://www.w3.org/1999/xlink',
width: "" + width + this.units,
height: "" + height + this.units,
viewBox: "" + this.bbox.xMin + " " + this.bbox.yMin + " " + width + " " + height,
id: this.gerberId
}
}
]
svg: {
xmlns: 'http://www.w3.org/2000/svg',
version: '1.1',
'xmlns:xlink': 'http://www.w3.org/1999/xlink',
width: "" + width + this.units,
height: "" + height + this.units,
viewBox: "" + this.bbox.xMin + " " + this.bbox.yMin + " " + width + " " + height,
id: this.gerberId,
_: []
}
};
if (this.defs.length) {
xml.svg.push({
defs: this.defs
xml.svg._.push({
defs: {
_: this.defs
}
});
}
this.group.g[0]._attr.transform = "translate(0," + (this.bbox.yMin + this.bbox.yMax) + ") scale(1,-1)";
xml.svg.push(this.group);
this.group.g.transform = "translate(0," + (this.bbox.yMin + this.bbox.yMax) + ") scale(1,-1)";
xml.svg._.push(this.group);
return xml;

@@ -223,3 +219,3 @@ };

Plotter.prototype.parameter = function(blocks) {
var ad, block, done, error, groupId, height, index, invalid, m, maskId, obj, p, srBlock, u, width, x, y, _i, _len, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6, _results;
var ad, block, done, error, groupId, hgt, index, invalid, m, maskId, obj, p, srBlock, u, wid, x, y, _i, _len, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6, _results;
done = false;

@@ -296,7 +292,5 @@ if (blocks[0] === '%' && blocks[blocks.length - 1] !== '%') {

use: {
_attr: {
x: "" + x,
y: "" + y,
'xlink:href': '#' + ad.tool.padId
}
x: x,
y: y,
'xlink:href': '#' + ad.tool.padId
}

@@ -345,11 +339,8 @@ };

srBlock = {
g: [
{
_attr: {
id: "" + this.gerberId + "-sr-block-" + this.stepRepeat.block
}
}
]
g: {
id: "" + this.gerberId + "-sr-block-" + this.stepRepeat.block,
_: []
}
};
this.layer.current[this.layer.type].push(srBlock);
this.layer.current[this.layer.type]._.push(srBlock);
this.layer.current = srBlock;

@@ -368,9 +359,6 @@ }

this.group = {
g: [
{
_attr: {
id: groupId
}
}, this.group
]
g: {
id: groupId,
_: [this.group]
}
};

@@ -381,28 +369,25 @@ this.layer.current = this.group;

maskId = "" + this.gerberId + "-layer-" + (++this.layer.level);
x = "" + this.bbox.xMin;
y = "" + this.bbox.yMin;
width = "" + (this.bbox.xMax - this.bbox.xMin);
height = "" + (this.bbox.yMax - this.bbox.yMin);
x = this.bbox.xMin;
y = this.bbox.yMin;
wid = this.bbox.xMax - this.bbox.xMin;
hgt = this.bbox.yMax - this.bbox.yMin;
m = {
mask: [
{
_attr: {
id: maskId,
color: '#000'
}
}, {
rect: {
_attr: {
mask: {
id: maskId,
color: '#000',
_: [
{
rect: {
x: x,
y: y,
width: width,
height: height,
width: wid,
height: hgt,
fill: '#fff'
}
}
}
]
]
}
};
this.defs.push(m);
this.layer.current.g[0]._attr.mask = "url(#" + maskId + ")";
this.layer.current.g.mask = "url(#" + maskId + ")";
this.layer.current = this.defs[this.defs.length - 1];

@@ -482,3 +467,3 @@ this.layer.type = 'mask';

this.finishTrace();
this.layer.current[this.layer.type].push(this.tools[this.currentTool].flash(this.position.x, this.position.y));
this.layer.current[this.layer.type]._.push(this.tools[this.currentTool].flash(this.position.x, this.position.y));
return this.addBbox(this.tools[this.currentTool].bbox(this.position.x, this.position.y));

@@ -501,2 +486,6 @@ } else if (op === '1') {

}
if (this.mode == null) {
console.warn("Warning: no interpolation mode was set by G01/2/3. Assuming linear interpolation (G01)");
this.mode = 'i';
}
if (this.mode === 'i') {

@@ -624,3 +613,3 @@ this.trace.path += "L" + end.x + " " + end.y;

}
srId = this.layer.current.g[0]._attr.id;
srId = this.layer.current.g.id;
this.layer.current = this.group;

@@ -634,9 +623,7 @@ _results = [];

if (!(x === 0 && y === 0)) {
_results1.push(this.layer.current[this.layer.type].push({
_results1.push(this.layer.current[this.layer.type]._.push({
use: {
_attr: {
x: "" + (x * this.stepRepeat.xStep),
y: "" + (y * this.stepRepeat.yStep),
'xlink:href': srId
}
x: x * this.stepRepeat.xStep,
y: y * this.stepRepeat.yStep,
'xlink:href': srId
}

@@ -660,10 +647,8 @@ }));

path: {
_attr: {
d: this.trace.path
}
d: this.trace.path
}
};
if (this.trace.region) {
p.path._attr['stroke-width'] = '0';
p.path._attr.fill = 'currentColor';
p.path['stroke-width'] = 0;
p.path.fill = 'currentColor';
} else {

@@ -673,6 +658,6 @@ _ref = this.tools[this.currentTool].stroke;

val = _ref[key];
p.path._attr[key] = val;
p.path[key] = val;
}
}
this.layer.current[this.layer.type].push(p);
this.layer.current[this.layer.type]._.push(p);
return this.trace.path = '';

@@ -687,2 +672,3 @@ }

this.units = this.backupUnits;
console.warn("Warning: units set to '" + this.units + "' according to deprecated command G7" + (this.units === 'in' ? 0 : 1));
} else {

@@ -689,0 +675,0 @@ throw new Error('units have not been set');

@@ -30,3 +30,3 @@ (function() {

'stroke-linejoin': 'round',
'stroke-width': "" + p.dia,
'stroke-width': p.dia,
stroke: 'currentColor',

@@ -49,3 +49,3 @@ fill: 'none'

result.trace = {
'stroke-width': '0'
'stroke-width': 0
};

@@ -77,3 +77,3 @@ }

hole = hole.shape;
hole.circle._attr.fill = '#000';
hole.circle.fill = '#000';
} else if ((p.hole.width != null) && (p.hole.height != null)) {

@@ -93,3 +93,3 @@ if (!(p.hole.width >= 0)) {

hole = hole.shape;
hole.rect._attr.fill = '#000';
hole.rect.fill = '#000';
} else {

@@ -100,25 +100,22 @@ throw new Error("" + tool + " has invalid hole parameters");

mask = {
mask: [
{
_attr: {
id: id + "-mask"
}
}, {
rect: {
_attr: {
x: "" + pad.bbox[0],
y: "" + pad.bbox[1],
width: "" + (pad.bbox[2] - pad.bbox[0]),
height: "" + (pad.bbox[3] - pad.bbox[1]),
mask: {
id: id + "-mask",
_: [
{
rect: {
x: pad.bbox[0],
y: pad.bbox[1],
width: pad.bbox[2] - pad.bbox[0],
height: pad.bbox[3] - pad.bbox[1],
fill: '#fff'
}
}
}, hole
]
}, hole
]
}
};
pad.shape[shape]._attr.mask = "url(#" + maskId + ")";
pad.shape[shape].mask = "url(#" + maskId + ")";
result.pad.push(mask);
}
if (id) {
pad.shape[shape]._attr.id = id;
pad.shape[shape].id = id;
}

@@ -125,0 +122,0 @@ result.pad.push(pad.shape);

{
"name": "gerber-to-svg",
"version": "0.0.4",
"version": "0.0.5",
"description": "Gerber file to SVG converter",

@@ -38,4 +38,3 @@ "main": "lib/gerber-to-svg.js",

"dependencies": {
"xml": "0.0.12"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc