diff --git a/lib/path-graph.js b/lib/path-graph.js index dac581c..9b5c8dd 100644 --- a/lib/path-graph.js +++ b/lib/path-graph.js @@ -3,8 +3,6 @@ var fill = require('lodash.fill') -var MAX_GAP = 0.00011 - var find = function (collection, condition) { var element var i @@ -55,10 +53,7 @@ var PathGraph = function (optimize, fillGaps) { this._points = [] this._edges = [] this._optimize = optimize - this._fillGaps = (fillGaps === true) - ? MAX_GAP - : fillGaps - + this._fillGaps = fillGaps this.length = 0 } diff --git a/lib/plotter.js b/lib/plotter.js index 024cf24..a0712cc 100644 --- a/lib/plotter.js +++ b/lib/plotter.js @@ -10,6 +10,8 @@ var padShape = require('./_pad-shape') var operate = require('./_operate') var boundingBox = require('./_box') +var MAX_GAP = 0.00011 + var isFormatKey = function (key) { return ( key === 'units' || @@ -44,8 +46,15 @@ var Plotter = function ( backupNota: (backupNota != null) } - // plotting options - this._plotAsOutline = plotAsOutline + this._plotAsOutline = (plotAsOutline === true) + ? MAX_GAP + : plotAsOutline + + // plotAsOutline parameter is always in mm + if ((units || this.format.backupUnits) === 'in') { + this._plotAsOutline = this._plotAsOutline / 2.54 + } + this._optimizePaths = optimizePaths || plotAsOutline this._line = 0 diff --git a/test/gerber-plotter_test.js b/test/gerber-plotter_test.js index d1980d2..3e7bde8 100644 --- a/test/gerber-plotter_test.js +++ b/test/gerber-plotter_test.js @@ -92,14 +92,14 @@ describe('gerber plotter', function () { it('should have an outline mode option that defaults to falsey', function () { expect(!p._plotAsOutline).to.equal(true) - p = plotter({plotAsOutline: true}) - expect(p._plotAsOutline).to.equal(true) + p = plotter({plotAsOutline: true, units: 'mm'}) + expect(p._plotAsOutline).to.equal(0.00011) }) it('should force optimize paths to true if plot as outline is true', function () { - p = plotter({plotAsOutline: true, optimizePaths: false}) - expect(p._plotAsOutline).to.equal(true) - expect(p._optimizePaths).to.equal(true) + p = plotter({plotAsOutline: true, optimizePaths: false, units: 'mm'}) + expect(p._plotAsOutline).to.equal(0.00011) + expect(p._optimizePaths).to.be.true }) }) @@ -1870,8 +1870,7 @@ describe('gerber plotter', function () { }) it('should be able to set a custom max gap size', function () { - outPlotter = plotter({plotAsOutline: 0.0011}) - + outPlotter = plotter({plotAsOutline: 0.0011, units: 'mm'}) expect(outPlotter._path._fillGaps).to.equal(0.0011) }) })