gerber-plotter
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -137,6 +137,6 @@ # gerber plotter api | ||
A modifier that changes the subsequent shape polarities to `clear` or `dark`. By default, all shapes are `dark`. A dark shape creates an image, while a clear shape erases any shape that lies below it (in that pad). Used for macro-defined tools and standard tools with holes: | ||
A modifier that changes the subsequent shape polarities to `clear` or `dark`. By default, all shapes are `dark`. A dark shape creates an image, while a clear shape erases any shape that lies below it. Used for macro-defined tools and standard tools with holes. The polarity object also includes the current size of the image: | ||
``` javascript | ||
{type: 'layer', polarity: 'clear' OR 'dark'} | ||
{type: 'layer', polarity: POLARITY, box: [X_MIN, Y_MIN, X_MAX, Y_MAX]} | ||
``` | ||
@@ -143,0 +143,0 @@ |
@@ -8,2 +8,3 @@ // returns a pad shape array given a tool definition | ||
var isFunction = require('lodash.isfunction') | ||
var clone = require('lodash.clone') | ||
@@ -244,3 +245,4 @@ var boundingBox = require('./_box') | ||
type: 'layer', | ||
polarity: (block.exp === 1) ? 'dark' : 'clear' | ||
polarity: (block.exp === 1) ? 'dark' : 'clear', | ||
box: clone(result.box) | ||
}) | ||
@@ -307,4 +309,7 @@ exposure = block.exp | ||
result.shape = result.shape.concat(shapeAndBox.shape), | ||
result.box = boundingBox.add(result.box, shapeAndBox.box) | ||
result.shape = result.shape.concat(shapeAndBox.shape) | ||
// only change the box if the exposure is creating an image | ||
if (exposure === 1) { | ||
result.box = boundingBox.add(result.box, shapeAndBox.box) | ||
} | ||
}, emptyMacro) | ||
@@ -355,3 +360,3 @@ } | ||
shape.push({type: 'layer', polarity: 'clear'}, holeShape) | ||
shape.push({type: 'layer', polarity: 'clear', box: box}, holeShape) | ||
} | ||
@@ -358,0 +363,0 @@ |
{ | ||
"name": "gerber-plotter", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Transform stream that takes objects from gerber-parser and emits PCB image objects", | ||
@@ -5,0 +5,0 @@ "main": "lib/gerber-plotter.js", |
@@ -263,3 +263,3 @@ // test suite for plotter | ||
{type: 'circle', cx: 0, cy: 0, r: 1}, | ||
{type: 'layer', polarity: 'clear'}, | ||
{type: 'layer', polarity: 'clear', box: [-1, -1, 1, 1]}, | ||
{type: 'circle', cx: 0, cy: 0, r: 0.5} | ||
@@ -271,3 +271,3 @@ ]) | ||
{type: 'circle', cx: 0, cy: 0, r: 1.5}, | ||
{type: 'layer', polarity: 'clear'}, | ||
{type: 'layer', polarity: 'clear', box: [-1.5, -1.5, 1.5, 1.5]}, | ||
{type: 'rect', cx: 0, cy: 0, r: 0, width: 1, height: 1} | ||
@@ -290,3 +290,3 @@ ]) | ||
{type: 'rect', cx: 0, cy: 0, r: 0, width: 3, height: 4}, | ||
{type: 'layer', polarity: 'clear'}, | ||
{type: 'layer', polarity: 'clear', box: [-1.5, -2, 1.5, 2]}, | ||
{type: 'circle', cx: 0, cy: 0, r: 0.5} | ||
@@ -298,3 +298,3 @@ ]) | ||
{type: 'rect', cx: 0, cy: 0, r: 0, width: 5, height: 6}, | ||
{type: 'layer', polarity: 'clear'}, | ||
{type: 'layer', polarity: 'clear', box: [-2.5, -3, 2.5, 3]}, | ||
{type: 'rect', cx: 0, cy: 0, r: 0, width: 1, height: 1} | ||
@@ -317,3 +317,3 @@ ]) | ||
{type: 'rect', cx: 0, cy: 0, r: 1.5, width: 4, height: 3}, | ||
{type: 'layer', polarity: 'clear'}, | ||
{type: 'layer', polarity: 'clear', box: [-2, -1.5, 2, 1.5]}, | ||
{type: 'circle', cx: 0, cy: 0, r: 0.5} | ||
@@ -325,3 +325,3 @@ ]) | ||
{type: 'rect', cx: 0, cy: 0, r: 2.5, width: 5, height: 6}, | ||
{type: 'layer', polarity: 'clear'}, | ||
{type: 'layer', polarity: 'clear', box: [-2.5, -3, 2.5, 3]}, | ||
{type: 'rect', cx: 0, cy: 0, r: 0, width: 1, height: 1} | ||
@@ -347,2 +347,4 @@ ]) | ||
var poly = p._tool.pad[0] | ||
var box = [-0.96592583, -0.96592583, 0.96592583, 0.96592583] | ||
expect(p._tool.pad).to.have.length(3) | ||
@@ -358,5 +360,5 @@ expect(poly).to.have.all.keys(['type', 'points']) | ||
[0.96592583, -0.25881905] | ||
], 10) | ||
]) | ||
expect(p._tool.pad.slice(1)).to.eql([ | ||
{type: 'layer', polarity: 'clear'}, | ||
{type: 'layer', polarity: 'clear', box: box}, | ||
{type: 'circle', cx: 0, cy: 0, r: 0.5} | ||
@@ -367,2 +369,4 @@ ]) | ||
poly = p._tool.pad[0] | ||
box = [-0.98480775, -0.98480775, 0.98480775, 0.98480775] | ||
expect(p._tool.pad).to.have.length(3) | ||
@@ -386,3 +390,3 @@ expect(poly).to.have.all.keys(['type', 'points']) | ||
expect(p._tool.pad.slice(1)).to.eql([ | ||
{type: 'layer', polarity: 'clear'}, | ||
{type: 'layer', polarity: 'clear', box: box}, | ||
{type: 'rect', cx: 0, cy: 0, r: 0, width: 1, height: 1} | ||
@@ -894,6 +898,6 @@ ]) | ||
{type: 'circle', cx: -2, cy: 0, r: 2}, | ||
{type: 'layer', polarity: 'clear'}, | ||
{type: 'layer', polarity: 'clear', box: [-4, -2, 0, 2]}, | ||
{type: 'rect', width: 1, height: 1, cx: -1, cy: 0, r: 0}, | ||
{type: 'rect', width: 1, height: 1, cx: 1, cy: 0, r: 0}, | ||
{type: 'layer', polarity: 'dark'}, | ||
{type: 'layer', polarity: 'dark', box: [-4, -2, 0, 2]}, | ||
{type: 'circle', cx: 2, cy: 0, r: 2} | ||
@@ -900,0 +904,0 @@ ]) |
110641
2550