@doodle3d/clipper-js
Advanced tools
Comparing version 1.0.10 to 1.0.11
@@ -10,5 +10,5 @@ 'use strict'; | ||
var _clipperLib = require('clipper-lib'); | ||
var _clipper = require('@doodle3d/clipper-lib/clipper'); | ||
var _clipperLib2 = _interopRequireDefault(_clipperLib); | ||
var _clipper2 = _interopRequireDefault(_clipper); | ||
@@ -25,8 +25,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
}; | ||
_clipperLib2.default.Error = function (message) { | ||
_clipper2.default.Error = function (message) { | ||
if (errorCallback) errorCallback(message); | ||
}; | ||
var CLIPPER = new _clipperLib2.default.Clipper(); | ||
var CLIPPER_OFFSET = new _clipperLib2.default.ClipperOffset(); | ||
var CLIPPER = new _clipper2.default.Clipper(); | ||
var CLIPPER_OFFSET = new _clipper2.default.ClipperOffset(); | ||
@@ -53,6 +53,6 @@ var Shape = function () { | ||
value: function _clip(type) { | ||
var solution = new _clipperLib2.default.PolyTree(); | ||
var solution = new _clipper2.default.PolyTree(); | ||
CLIPPER.Clear(); | ||
CLIPPER.AddPaths(this.paths, _clipperLib2.default.PolyType.ptSubject, this.closed); | ||
CLIPPER.AddPaths(this.paths, _clipper2.default.PolyType.ptSubject, this.closed); | ||
@@ -65,7 +65,7 @@ for (var _len = arguments.length, clipShapes = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
var clipShape = clipShapes[i]; | ||
CLIPPER.AddPaths(clipShape.paths, _clipperLib2.default.PolyType.ptClip, clipShape.closed); | ||
CLIPPER.AddPaths(clipShape.paths, _clipper2.default.PolyType.ptClip, clipShape.closed); | ||
} | ||
CLIPPER.Execute(type, solution); | ||
var newShape = _clipperLib2.default.Clipper.PolyTreeToPaths(solution); | ||
var newShape = _clipper2.default.Clipper.PolyTreeToPaths(solution); | ||
return new Shape(newShape, this.closed); | ||
@@ -80,3 +80,3 @@ } | ||
return this._clip.apply(this, [_clipperLib2.default.ClipType.ctUnion].concat(clipShapes)); | ||
return this._clip.apply(this, [_clipper2.default.ClipType.ctUnion].concat(clipShapes)); | ||
} | ||
@@ -90,3 +90,3 @@ }, { | ||
return this._clip.apply(this, [_clipperLib2.default.ClipType.ctDifference].concat(clipShapes)); | ||
return this._clip.apply(this, [_clipper2.default.ClipType.ctDifference].concat(clipShapes)); | ||
} | ||
@@ -100,3 +100,3 @@ }, { | ||
return this._clip.apply(this, [_clipperLib2.default.ClipType.ctIntersection].concat(clipShapes)); | ||
return this._clip.apply(this, [_clipper2.default.ClipType.ctIntersection].concat(clipShapes)); | ||
} | ||
@@ -110,3 +110,3 @@ }, { | ||
return this._clip.apply(this, [_clipperLib2.default.ClipType.ctXor].concat(clipShapes)); | ||
return this._clip.apply(this, [_clipper2.default.ClipType.ctXor].concat(clipShapes)); | ||
} | ||
@@ -131,4 +131,4 @@ }, { | ||
var offsetPaths = new _clipperLib2.default.Paths(); | ||
CLIPPER_OFFSET.AddPaths(this.paths, _clipperLib2.default.JoinType[jointType], _clipperLib2.default.EndType[endType]); | ||
var offsetPaths = new _clipper2.default.Paths(); | ||
CLIPPER_OFFSET.AddPaths(this.paths, _clipper2.default.JoinType[jointType], _clipper2.default.EndType[endType]); | ||
CLIPPER_OFFSET.Execute(offsetPaths, _offset); | ||
@@ -141,3 +141,3 @@ | ||
value: function scaleUp(factor) { | ||
_clipperLib2.default.JS.ScaleUpPaths(this.paths, factor); | ||
_clipper2.default.JS.ScaleUpPaths(this.paths, factor); | ||
@@ -149,3 +149,3 @@ return this; | ||
value: function scaleDown(factor) { | ||
_clipperLib2.default.JS.ScaleDownPaths(this.paths, factor); | ||
_clipper2.default.JS.ScaleDownPaths(this.paths, factor); | ||
@@ -202,3 +202,3 @@ return this; | ||
var path = this.paths[index]; | ||
var area = _clipperLib2.default.Clipper.Area(path); | ||
var area = _clipper2.default.Clipper.Area(path); | ||
return area; | ||
@@ -217,3 +217,3 @@ } | ||
var path = this.paths[index]; | ||
var perimeter = _clipperLib2.default.JS.PerimeterOfPath(path, this.closed, 1); | ||
var perimeter = _clipper2.default.JS.PerimeterOfPath(path, this.closed, 1); | ||
return perimeter; | ||
@@ -227,3 +227,3 @@ } | ||
return this.paths.map(function (path) { | ||
return _clipperLib2.default.JS.PerimeterOfPath(path, _this2.closed, 1); | ||
return _clipper2.default.JS.PerimeterOfPath(path, _this2.closed, 1); | ||
}); | ||
@@ -234,3 +234,3 @@ } | ||
value: function totalPerimeter() { | ||
var perimeter = _clipperLib2.default.JS.PerimeterOfPaths(this.paths, this.closed); | ||
var perimeter = _clipper2.default.JS.PerimeterOfPaths(this.paths, this.closed); | ||
return perimeter; | ||
@@ -241,3 +241,3 @@ } | ||
value: function reverse() { | ||
_clipperLib2.default.Clipper.ReversePaths(this.paths); | ||
_clipper2.default.Clipper.ReversePaths(this.paths); | ||
@@ -253,3 +253,3 @@ return this; | ||
var path = _arr[_i]; | ||
var area = Math.abs(_clipperLib2.default.Clipper.Area(path)); | ||
var area = Math.abs(_clipper2.default.Clipper.Area(path)); | ||
@@ -275,3 +275,3 @@ if (area < minArea) { | ||
value: function clone() { | ||
return new Shape(_clipperLib2.default.JS.Clone(this.paths), this.closed); | ||
return new Shape(_clipper2.default.JS.Clone(this.paths), this.closed); | ||
} | ||
@@ -281,3 +281,3 @@ }, { | ||
value: function shapeBounds() { | ||
return _clipperLib2.default.JS.BoundsOfPaths(this.paths); | ||
return _clipper2.default.JS.BoundsOfPaths(this.paths); | ||
} | ||
@@ -289,3 +289,3 @@ }, { | ||
return _clipperLib2.default.JS.BoundsOfPath(path); | ||
return _clipper2.default.JS.BoundsOfPath(path); | ||
} | ||
@@ -295,3 +295,3 @@ }, { | ||
value: function clean(cleanDelta) { | ||
return new Shape(_clipperLib2.default.Clipper.CleanPolygons(this.paths, cleanDelta), this.closed); | ||
return new Shape(_clipper2.default.Clipper.CleanPolygons(this.paths, cleanDelta), this.closed); | ||
} | ||
@@ -302,3 +302,3 @@ }, { | ||
var path = this.paths[index]; | ||
return _clipperLib2.default.Clipper.Orientation(path); | ||
return _clipper2.default.Clipper.Orientation(path); | ||
} | ||
@@ -335,3 +335,3 @@ }, { | ||
return _clipperLib2.default.Clipper.PointInPolygon(intPoint, path) > 0; | ||
return _clipper2.default.Clipper.PointInPolygon(intPoint, path) > 0; | ||
} | ||
@@ -355,3 +355,3 @@ }, { | ||
if (this.closed) { | ||
var shape = _clipperLib2.default.Clipper.SimplifyPolygons(this.paths, _clipperLib2.default.PolyFillType[fillType]); | ||
var shape = _clipper2.default.Clipper.SimplifyPolygons(this.paths, _clipper2.default.PolyFillType[fillType]); | ||
return new Shape(shape, true); | ||
@@ -363,4 +363,4 @@ } else { | ||
}, { | ||
key: 'seperateShapes', | ||
value: function seperateShapes() { | ||
key: 'separateShapes', | ||
value: function separateShapes() { | ||
var shapes = []; | ||
@@ -367,0 +367,0 @@ |
@@ -10,5 +10,5 @@ 'use strict'; | ||
var _clipperLib = require('clipper-lib'); | ||
var _clipper = require('@doodle3d/clipper-lib/clipper'); | ||
var _clipperLib2 = _interopRequireDefault(_clipperLib); | ||
var _clipper2 = _interopRequireDefault(_clipper); | ||
@@ -25,8 +25,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
}; | ||
_clipperLib2.default.Error = function (message) { | ||
_clipper2.default.Error = function (message) { | ||
if (errorCallback) errorCallback(message); | ||
}; | ||
var CLIPPER = new _clipperLib2.default.Clipper(); | ||
var CLIPPER_OFFSET = new _clipperLib2.default.ClipperOffset(); | ||
var CLIPPER = new _clipper2.default.Clipper(); | ||
var CLIPPER_OFFSET = new _clipper2.default.ClipperOffset(); | ||
@@ -53,6 +53,6 @@ var Shape = function () { | ||
value: function _clip(type) { | ||
var solution = new _clipperLib2.default.PolyTree(); | ||
var solution = new _clipper2.default.PolyTree(); | ||
CLIPPER.Clear(); | ||
CLIPPER.AddPaths(this.paths, _clipperLib2.default.PolyType.ptSubject, this.closed); | ||
CLIPPER.AddPaths(this.paths, _clipper2.default.PolyType.ptSubject, this.closed); | ||
@@ -65,7 +65,7 @@ for (var _len = arguments.length, clipShapes = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
var clipShape = clipShapes[i]; | ||
CLIPPER.AddPaths(clipShape.paths, _clipperLib2.default.PolyType.ptClip, clipShape.closed); | ||
CLIPPER.AddPaths(clipShape.paths, _clipper2.default.PolyType.ptClip, clipShape.closed); | ||
} | ||
CLIPPER.Execute(type, solution); | ||
var newShape = _clipperLib2.default.Clipper.PolyTreeToPaths(solution); | ||
var newShape = _clipper2.default.Clipper.PolyTreeToPaths(solution); | ||
return new Shape(newShape, this.closed); | ||
@@ -80,3 +80,3 @@ } | ||
return this._clip.apply(this, [_clipperLib2.default.ClipType.ctUnion].concat(clipShapes)); | ||
return this._clip.apply(this, [_clipper2.default.ClipType.ctUnion].concat(clipShapes)); | ||
} | ||
@@ -90,3 +90,3 @@ }, { | ||
return this._clip.apply(this, [_clipperLib2.default.ClipType.ctDifference].concat(clipShapes)); | ||
return this._clip.apply(this, [_clipper2.default.ClipType.ctDifference].concat(clipShapes)); | ||
} | ||
@@ -100,3 +100,3 @@ }, { | ||
return this._clip.apply(this, [_clipperLib2.default.ClipType.ctIntersection].concat(clipShapes)); | ||
return this._clip.apply(this, [_clipper2.default.ClipType.ctIntersection].concat(clipShapes)); | ||
} | ||
@@ -110,3 +110,3 @@ }, { | ||
return this._clip.apply(this, [_clipperLib2.default.ClipType.ctXor].concat(clipShapes)); | ||
return this._clip.apply(this, [_clipper2.default.ClipType.ctXor].concat(clipShapes)); | ||
} | ||
@@ -131,4 +131,4 @@ }, { | ||
var offsetPaths = new _clipperLib2.default.Paths(); | ||
CLIPPER_OFFSET.AddPaths(this.paths, _clipperLib2.default.JoinType[jointType], _clipperLib2.default.EndType[endType]); | ||
var offsetPaths = new _clipper2.default.Paths(); | ||
CLIPPER_OFFSET.AddPaths(this.paths, _clipper2.default.JoinType[jointType], _clipper2.default.EndType[endType]); | ||
CLIPPER_OFFSET.Execute(offsetPaths, _offset); | ||
@@ -141,3 +141,3 @@ | ||
value: function scaleUp(factor) { | ||
_clipperLib2.default.JS.ScaleUpPaths(this.paths, factor); | ||
_clipper2.default.JS.ScaleUpPaths(this.paths, factor); | ||
@@ -149,3 +149,3 @@ return this; | ||
value: function scaleDown(factor) { | ||
_clipperLib2.default.JS.ScaleDownPaths(this.paths, factor); | ||
_clipper2.default.JS.ScaleDownPaths(this.paths, factor); | ||
@@ -202,3 +202,3 @@ return this; | ||
var path = this.paths[index]; | ||
var area = _clipperLib2.default.Clipper.Area(path); | ||
var area = _clipper2.default.Clipper.Area(path); | ||
return area; | ||
@@ -217,3 +217,3 @@ } | ||
var path = this.paths[index]; | ||
var perimeter = _clipperLib2.default.JS.PerimeterOfPath(path, this.closed, 1); | ||
var perimeter = _clipper2.default.JS.PerimeterOfPath(path, this.closed, 1); | ||
return perimeter; | ||
@@ -227,3 +227,3 @@ } | ||
return this.paths.map(function (path) { | ||
return _clipperLib2.default.JS.PerimeterOfPath(path, _this2.closed, 1); | ||
return _clipper2.default.JS.PerimeterOfPath(path, _this2.closed, 1); | ||
}); | ||
@@ -234,3 +234,3 @@ } | ||
value: function totalPerimeter() { | ||
var perimeter = _clipperLib2.default.JS.PerimeterOfPaths(this.paths, this.closed); | ||
var perimeter = _clipper2.default.JS.PerimeterOfPaths(this.paths, this.closed); | ||
return perimeter; | ||
@@ -241,3 +241,3 @@ } | ||
value: function reverse() { | ||
_clipperLib2.default.Clipper.ReversePaths(this.paths); | ||
_clipper2.default.Clipper.ReversePaths(this.paths); | ||
@@ -253,3 +253,3 @@ return this; | ||
var path = _arr[_i]; | ||
var area = Math.abs(_clipperLib2.default.Clipper.Area(path)); | ||
var area = Math.abs(_clipper2.default.Clipper.Area(path)); | ||
@@ -275,3 +275,3 @@ if (area < minArea) { | ||
value: function clone() { | ||
return new Shape(_clipperLib2.default.JS.Clone(this.paths), this.closed); | ||
return new Shape(_clipper2.default.JS.Clone(this.paths), this.closed); | ||
} | ||
@@ -281,3 +281,3 @@ }, { | ||
value: function shapeBounds() { | ||
return _clipperLib2.default.JS.BoundsOfPaths(this.paths); | ||
return _clipper2.default.JS.BoundsOfPaths(this.paths); | ||
} | ||
@@ -289,3 +289,3 @@ }, { | ||
return _clipperLib2.default.JS.BoundsOfPath(path); | ||
return _clipper2.default.JS.BoundsOfPath(path); | ||
} | ||
@@ -295,3 +295,3 @@ }, { | ||
value: function clean(cleanDelta) { | ||
return new Shape(_clipperLib2.default.Clipper.CleanPolygons(this.paths, cleanDelta), this.closed); | ||
return new Shape(_clipper2.default.Clipper.CleanPolygons(this.paths, cleanDelta), this.closed); | ||
} | ||
@@ -302,3 +302,3 @@ }, { | ||
var path = this.paths[index]; | ||
return _clipperLib2.default.Clipper.Orientation(path); | ||
return _clipper2.default.Clipper.Orientation(path); | ||
} | ||
@@ -335,3 +335,3 @@ }, { | ||
return _clipperLib2.default.Clipper.PointInPolygon(intPoint, path) > 0; | ||
return _clipper2.default.Clipper.PointInPolygon(intPoint, path) > 0; | ||
} | ||
@@ -355,3 +355,3 @@ }, { | ||
if (this.closed) { | ||
var shape = _clipperLib2.default.Clipper.SimplifyPolygons(this.paths, _clipperLib2.default.PolyFillType[fillType]); | ||
var shape = _clipper2.default.Clipper.SimplifyPolygons(this.paths, _clipper2.default.PolyFillType[fillType]); | ||
return new Shape(shape, true); | ||
@@ -363,4 +363,4 @@ } else { | ||
}, { | ||
key: 'seperateShapes', | ||
value: function seperateShapes() { | ||
key: 'separateShapes', | ||
value: function separateShapes() { | ||
var shapes = []; | ||
@@ -367,0 +367,0 @@ |
{ | ||
"name": "@doodle3d/clipper-js", | ||
"version": "1.0.10", | ||
"version": "1.0.11", | ||
"description": "Clipper-lib abstraction layer (simplified API)", | ||
@@ -34,3 +34,5 @@ "main": "lib/index.js", | ||
"babel-preset-latest": "^6.5.0", | ||
"browser-sync": "^2.11.1" | ||
"browser-sync": "^2.26.7", | ||
"server": "^1.0.27", | ||
"tape": "^4.13.2" | ||
}, | ||
@@ -37,0 +39,0 @@ "dependencies": { |
@@ -57,3 +57,3 @@ # ClipperJS | ||
``` | ||
npm install clipper-js --save | ||
npm install @doodle3d/clipper-js --save | ||
``` | ||
@@ -60,0 +60,0 @@ |
@@ -1,2 +0,2 @@ | ||
import ClipperLib from 'clipper-lib'; | ||
import ClipperLib from '@doodle3d/clipper-lib/clipper'; | ||
@@ -235,3 +235,3 @@ let errorCallback; | ||
seperateShapes() { | ||
separateShapes() { | ||
const shapes = []; | ||
@@ -238,0 +238,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
98878
7