paper 0.12.15 → 0.12.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +2 -2
  3. package/dist/docs/assets/js/paper.js +35 -22
  4. package/dist/docs/classes/Color.html +2 -2
  5. package/dist/docs/classes/CompoundPath.html +2 -2
  6. package/dist/docs/classes/Curve.html +2 -2
  7. package/dist/docs/classes/CurveLocation.html +2 -2
  8. package/dist/docs/classes/Event.html +2 -2
  9. package/dist/docs/classes/Gradient.html +2 -2
  10. package/dist/docs/classes/GradientStop.html +2 -2
  11. package/dist/docs/classes/Group.html +2 -2
  12. package/dist/docs/classes/HitResult.html +2 -2
  13. package/dist/docs/classes/Item.html +2 -2
  14. package/dist/docs/classes/Key.html +2 -2
  15. package/dist/docs/classes/KeyEvent.html +2 -2
  16. package/dist/docs/classes/Layer.html +2 -2
  17. package/dist/docs/classes/Matrix.html +2 -2
  18. package/dist/docs/classes/MouseEvent.html +2 -2
  19. package/dist/docs/classes/PaperScope.html +2 -2
  20. package/dist/docs/classes/PaperScript.html +2 -2
  21. package/dist/docs/classes/Path.html +2 -2
  22. package/dist/docs/classes/PathItem.html +2 -2
  23. package/dist/docs/classes/Point.html +2 -2
  24. package/dist/docs/classes/PointText.html +2 -2
  25. package/dist/docs/classes/Project.html +2 -2
  26. package/dist/docs/classes/Raster.html +35 -4
  27. package/dist/docs/classes/Rectangle.html +2 -2
  28. package/dist/docs/classes/Segment.html +3 -3
  29. package/dist/docs/classes/Shape.html +3 -3
  30. package/dist/docs/classes/Size.html +2 -2
  31. package/dist/docs/classes/Style.html +2 -2
  32. package/dist/docs/classes/SymbolDefinition.html +2 -2
  33. package/dist/docs/classes/SymbolItem.html +2 -2
  34. package/dist/docs/classes/TextItem.html +2 -2
  35. package/dist/docs/classes/Tool.html +2 -2
  36. package/dist/docs/classes/ToolEvent.html +2 -2
  37. package/dist/docs/classes/Tween.html +2 -2
  38. package/dist/docs/classes/View.html +2 -2
  39. package/dist/docs/classes/global.html +2 -2
  40. package/dist/docs/classes/index.html +2 -2
  41. package/dist/docs/index.html +1 -1
  42. package/dist/paper-core.js +35 -22
  43. package/dist/paper-core.min.js +3 -3
  44. package/dist/paper-full.js +35 -22
  45. package/dist/paper-full.min.js +3 -3
  46. package/dist/paper.d.ts +171 -146
  47. package/package.json +9 -9
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Paper.js v0.12.15 - The Swiss Army Knife of Vector Graphics Scripting.
2
+ * Paper.js v0.12.17 - The Swiss Army Knife of Vector Graphics Scripting.
3
3
  * http://paperjs.org/
4
4
  *
5
5
  * Copyright (c) 2011 - 2020, Jürg Lehni & Jonathan Puckey
@@ -9,7 +9,7 @@
9
9
  *
10
10
  * All rights reserved.
11
11
  *
12
- * Date: Wed Mar 17 10:49:48 2021 +0100
12
+ * Date: Thu Nov 3 21:15:36 2022 +0100
13
13
  *
14
14
  ***
15
15
  *
@@ -575,7 +575,7 @@ statics: {
575
575
  if (Base.isPlainObject(arg)) {
576
576
  arg.insert = false;
577
577
  if (useTarget) {
578
- args = args.concat([{ insert: true }]);
578
+ args = args.concat([Item.INSERT]);
579
579
  }
580
580
  }
581
581
  }
@@ -821,7 +821,7 @@ var PaperScope = Base.extend({
821
821
  }
822
822
  },
823
823
 
824
- version: "0.12.15",
824
+ version: "0.12.17",
825
825
 
826
826
  getView: function() {
827
827
  var project = this.project;
@@ -1221,6 +1221,7 @@ var Numerical = new function() {
1221
1221
  CURVETIME_EPSILON: 1e-8,
1222
1222
  GEOMETRIC_EPSILON: 1e-7,
1223
1223
  TRIGONOMETRIC_EPSILON: 1e-8,
1224
+ ANGULAR_EPSILON: 1e-5,
1224
1225
  KAPPA: 4 * (sqrt(2) - 1) / 3,
1225
1226
 
1226
1227
  isZero: function(val) {
@@ -3138,6 +3139,7 @@ var Item = Base.extend(Emitter, {
3138
3139
  return extend.base.apply(this, arguments);
3139
3140
  },
3140
3141
 
3142
+ INSERT: { insert: true },
3141
3143
  NO_INSERT: { insert: false }
3142
3144
  },
3143
3145
 
@@ -3224,13 +3226,13 @@ new function() {
3224
3226
  matrix._owner = this;
3225
3227
  this._style = new Style(project._currentStyle, this, project);
3226
3228
  if (internal || hasProps && props.insert == false
3227
- || !settings.insertItems && !(hasProps && props.insert === true)) {
3229
+ || !settings.insertItems && !(hasProps && props.insert == true)) {
3228
3230
  this._setProject(project);
3229
3231
  } else {
3230
3232
  (hasProps && props.parent || project)
3231
3233
  ._insertItem(undefined, this, true);
3232
3234
  }
3233
- if (hasProps && props !== Item.NO_INSERT) {
3235
+ if (hasProps && props !== Item.NO_INSERT && props !== Item.INSERT) {
3234
3236
  this.set(props, {
3235
3237
  internal: true, insert: true, project: true, parent: true
3236
3238
  });
@@ -3903,9 +3905,7 @@ new function() {
3903
3905
  resolution = arg0;
3904
3906
  insert = arg1;
3905
3907
  }
3906
- if (raster) {
3907
- raster.matrix.reset(true);
3908
- } else {
3908
+ if (!raster) {
3909
3909
  raster = new Raster(Item.NO_INSERT);
3910
3910
  }
3911
3911
  var bounds = this.getStrokeBounds(),
@@ -3924,7 +3924,7 @@ new function() {
3924
3924
  this.draw(ctx, new Base({ matrices: [matrix] }));
3925
3925
  ctx.restore();
3926
3926
  }
3927
- raster.transform(
3927
+ raster._matrix.set(
3928
3928
  new Matrix()
3929
3929
  .translate(topLeft.add(boundsSize.divide(2)))
3930
3930
  .scale(1 / scale)
@@ -5733,11 +5733,16 @@ var Raster = Item.extend({
5733
5733
  rect.width, rect.height);
5734
5734
  },
5735
5735
 
5736
- setImageData: function(data ) {
5736
+ putImageData: function(data ) {
5737
5737
  var point = Point.read(arguments, 1);
5738
5738
  this.getContext(true).putImageData(data, point.x, point.y);
5739
5739
  },
5740
5740
 
5741
+ setImageData: function(data) {
5742
+ this.setSize(data);
5743
+ this.getContext(true).putImageData(data, 0, 0);
5744
+ },
5745
+
5741
5746
  _getBounds: function(matrix, options) {
5742
5747
  var rect = new Rectangle(this._size).setCenter(0, 0);
5743
5748
  return matrix ? matrix._transformBounds(rect) : rect;
@@ -9669,9 +9674,11 @@ new function() {
9669
9674
  }
9670
9675
  }
9671
9676
  if (extent) {
9672
- var epsilon = 1e-7,
9677
+ var epsilon = 1e-5,
9673
9678
  ext = abs(extent),
9674
- count = ext >= 360 ? 4 : Math.ceil((ext - epsilon) / 90),
9679
+ count = ext >= 360
9680
+ ? 4
9681
+ : Math.ceil((ext - epsilon) / 90),
9675
9682
  inc = extent / count,
9676
9683
  half = inc * Math.PI / 360,
9677
9684
  z = 4 / 3 * Math.sin(half) / (1 + Math.cos(half)),
@@ -9979,10 +9986,14 @@ Path.inject({ statics: new function() {
9979
9986
 
9980
9987
  function createPath(segments, closed, args) {
9981
9988
  var props = Base.getNamed(args),
9982
- path = new Path(props && props.insert == false && Item.NO_INSERT);
9989
+ path = new Path(props && (
9990
+ props.insert == true ? Item.INSERT
9991
+ : props.insert == false ? Item.NO_INSERT
9992
+ : null
9993
+ ));
9983
9994
  path._add(segments);
9984
9995
  path._closed = closed;
9985
- return path.set(props, { insert: true });
9996
+ return path.set(props, Item.INSERT);
9986
9997
  }
9987
9998
 
9988
9999
  function createEllipse(center, radius, args) {
@@ -11700,7 +11711,9 @@ var Color = Base.extend(new function() {
11700
11711
  if (!color) {
11701
11712
  if (window) {
11702
11713
  if (!colorCtx) {
11703
- colorCtx = CanvasProvider.getContext(1, 1);
11714
+ colorCtx = CanvasProvider.getContext(1, 1, {
11715
+ willReadFrequently: true
11716
+ });
11704
11717
  colorCtx.globalCompositeOperation = 'copy';
11705
11718
  }
11706
11719
  colorCtx.fillStyle = 'rgba(0,0,0,0)';
@@ -14328,7 +14341,7 @@ var Http = {
14328
14341
  var CanvasProvider = Base.exports.CanvasProvider = {
14329
14342
  canvases: [],
14330
14343
 
14331
- getCanvas: function(width, height) {
14344
+ getCanvas: function(width, height, options) {
14332
14345
  if (!window)
14333
14346
  return null;
14334
14347
  var canvas,
@@ -14343,7 +14356,7 @@ var CanvasProvider = Base.exports.CanvasProvider = {
14343
14356
  canvas = document.createElement('canvas');
14344
14357
  clear = false;
14345
14358
  }
14346
- var ctx = canvas.getContext('2d');
14359
+ var ctx = canvas.getContext('2d', options || {});
14347
14360
  if (!ctx) {
14348
14361
  throw new Error('Canvas ' + canvas +
14349
14362
  ' is unable to provide a 2D context.');
@@ -14359,9 +14372,9 @@ var CanvasProvider = Base.exports.CanvasProvider = {
14359
14372
  return canvas;
14360
14373
  },
14361
14374
 
14362
- getContext: function(width, height) {
14363
- var canvas = this.getCanvas(width, height);
14364
- return canvas ? canvas.getContext('2d') : null;
14375
+ getContext: function(width, height, options) {
14376
+ var canvas = this.getCanvas(width, height, options);
14377
+ return canvas ? canvas.getContext('2d', options || {}) : null;
14365
14378
  },
14366
14379
 
14367
14380
  release: function(obj) {
@@ -14559,7 +14572,7 @@ var BlendMode = new function() {
14559
14572
  this[mode] = true;
14560
14573
  }, {});
14561
14574
 
14562
- var ctx = CanvasProvider.getContext(1, 1);
14575
+ var ctx = CanvasProvider.getContext(1, 1, { willReadFrequently: true });
14563
14576
  if (ctx) {
14564
14577
  Base.each(modes, function(func, mode) {
14565
14578
  var darken = mode === 'darken',