Skip to content

Commit

Permalink
added switch to paint all polylines black
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Pilz committed May 3, 2018
1 parent d99e68b commit f965251
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
9 changes: 7 additions & 2 deletions dist/dxf.js
Original file line number Diff line number Diff line change
Expand Up @@ -1676,6 +1676,8 @@ var _logger2 = _interopRequireDefault(_logger);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var ALL_BLACK = 1; // Paint all lines black

var polylineToPath = function polylineToPath(rgb, polyline) {
var color24bit = rgb[2] | rgb[1] << 8 | rgb[0] << 16;
var prepad = color24bit.toString(16);
Expand All @@ -1684,10 +1686,13 @@ var polylineToPath = function polylineToPath(rgb, polyline) {
}
var hex = '#' + prepad;

// SVG is white by default, so make white lines black
if (hex === '#ffffff') {
if (ALL_BLACK) {
hex = '#000000';
}
// SVG is white by default, so make white lines black
else if (hex === '#ffffff') {
hex = '#000000';
}

var d = polyline.reduce(function (acc, point, i) {
acc += i === 0 ? 'M' : 'L';
Expand Down
9 changes: 7 additions & 2 deletions lib/toSVG.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ var _logger2 = _interopRequireDefault(_logger);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var ALL_BLACK = 1; // Paint all lines black

var polylineToPath = function polylineToPath(rgb, polyline) {
var color24bit = rgb[2] | rgb[1] << 8 | rgb[0] << 16;
var prepad = color24bit.toString(16);
Expand All @@ -36,10 +38,13 @@ var polylineToPath = function polylineToPath(rgb, polyline) {
}
var hex = '#' + prepad;

// SVG is white by default, so make white lines black
if (hex === '#ffffff') {
if (ALL_BLACK) {
hex = '#000000';
}
// SVG is white by default, so make white lines black
else if (hex === '#ffffff') {
hex = '#000000';
}

var d = polyline.reduce(function (acc, point, i) {
acc += i === 0 ? 'M' : 'L';
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/toSVG.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import entityToPolyline from './entityToPolyline'
import colors from './util/colors'
import logger from './util/logger'

const ALL_BLACK = 1; // Paint all lines black

const polylineToPath = (rgb, polyline) => {
const color24bit = rgb[2] | (rgb[1] << 8) | (rgb[0] << 16)
let prepad = color24bit.toString(16)
Expand All @@ -14,8 +16,11 @@ const polylineToPath = (rgb, polyline) => {
}
let hex = '#' + prepad

if(ALL_BLACK) {
hex = '#000000'
}
// SVG is white by default, so make white lines black
if (hex === '#ffffff') {
else if (hex === '#ffffff') {
hex = '#000000'
}

Expand Down

0 comments on commit f965251

Please sign in to comment.