Skip to content
This repository has been archived by the owner on Jul 23, 2018. It is now read-only.

Commit

Permalink
Switch outline gap fill to always be in mm
Browse files Browse the repository at this point in the history
  • Loading branch information
kasbah committed Apr 7, 2018
1 parent 3c49c4e commit f841a7e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
7 changes: 1 addition & 6 deletions lib/path-graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

var fill = require('lodash.fill')

var MAX_GAP = 0.00011

var find = function (collection, condition) {
var element
var i
Expand Down Expand Up @@ -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
}

Expand Down
13 changes: 11 additions & 2 deletions lib/plotter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' ||
Expand Down Expand Up @@ -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
Expand Down
13 changes: 6 additions & 7 deletions test/gerber-plotter_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
})

Expand Down Expand Up @@ -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)
})
})
Expand Down

0 comments on commit f841a7e

Please sign in to comment.