paper 0.12.17 → 0.12.19

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 (46) hide show
  1. package/CHANGELOG.md +44 -1
  2. package/dist/docs/assets/js/paper.js +107 -61
  3. package/dist/docs/classes/Color.html +2 -2
  4. package/dist/docs/classes/CompoundPath.html +3 -4
  5. package/dist/docs/classes/Curve.html +2 -2
  6. package/dist/docs/classes/CurveLocation.html +2 -2
  7. package/dist/docs/classes/Event.html +2 -2
  8. package/dist/docs/classes/Gradient.html +2 -2
  9. package/dist/docs/classes/GradientStop.html +2 -2
  10. package/dist/docs/classes/Group.html +3 -4
  11. package/dist/docs/classes/HitResult.html +2 -2
  12. package/dist/docs/classes/Item.html +3 -4
  13. package/dist/docs/classes/Key.html +2 -2
  14. package/dist/docs/classes/KeyEvent.html +2 -2
  15. package/dist/docs/classes/Layer.html +3 -4
  16. package/dist/docs/classes/Matrix.html +2 -2
  17. package/dist/docs/classes/MouseEvent.html +2 -2
  18. package/dist/docs/classes/PaperScope.html +2 -2
  19. package/dist/docs/classes/PaperScript.html +2 -2
  20. package/dist/docs/classes/Path.html +3 -4
  21. package/dist/docs/classes/PathItem.html +3 -4
  22. package/dist/docs/classes/Point.html +2 -2
  23. package/dist/docs/classes/PointText.html +3 -4
  24. package/dist/docs/classes/Project.html +3 -2
  25. package/dist/docs/classes/Raster.html +3 -4
  26. package/dist/docs/classes/Rectangle.html +2 -2
  27. package/dist/docs/classes/Segment.html +2 -2
  28. package/dist/docs/classes/Shape.html +3 -4
  29. package/dist/docs/classes/Size.html +2 -2
  30. package/dist/docs/classes/Style.html +2 -2
  31. package/dist/docs/classes/SymbolDefinition.html +2 -2
  32. package/dist/docs/classes/SymbolItem.html +3 -4
  33. package/dist/docs/classes/TextItem.html +3 -4
  34. package/dist/docs/classes/Tool.html +2 -2
  35. package/dist/docs/classes/ToolEvent.html +2 -2
  36. package/dist/docs/classes/Tween.html +2 -2
  37. package/dist/docs/classes/View.html +3 -3
  38. package/dist/docs/classes/global.html +2 -2
  39. package/dist/docs/classes/index.html +2 -2
  40. package/dist/docs/index.html +1 -1
  41. package/dist/paper-core.js +106 -60
  42. package/dist/paper-core.min.js +3 -3
  43. package/dist/paper-full.js +107 -61
  44. package/dist/paper-full.min.js +3 -3
  45. package/dist/paper.d.ts +10 -4
  46. package/package.json +8 -5
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Paper.js v0.12.17 - The Swiss Army Knife of Vector Graphics Scripting.
2
+ * Paper.js v0.12.19 - 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: Thu Nov 3 21:15:36 2022 +0100
12
+ * Date: Sun Oct 18 13:05:31 2026 +0200
13
13
  *
14
14
  ***
15
15
  *
@@ -821,7 +821,7 @@ var PaperScope = Base.extend({
821
821
  }
822
822
  },
823
823
 
824
- version: "0.12.17",
824
+ version: "0.12.19",
825
825
 
826
826
  getView: function() {
827
827
  var project = this.project;
@@ -1916,7 +1916,9 @@ var Rectangle = Base.extend({
1916
1916
  } else if (type === 'undefined' || arg0 === null) {
1917
1917
  this._set(0, 0, 0, 0);
1918
1918
  read = arg0 === null ? 1 : 0;
1919
- } else if (args.length === 1) {
1919
+ } else if (args.length === 1
1920
+ || Array.isArray(arg0) && arg0.length === 4
1921
+ || arg0.x !== undefined && arg0.width !== undefined) {
1920
1922
  if (Array.isArray(arg0)) {
1921
1923
  this._set.apply(this, arg0);
1922
1924
  read = 1;
@@ -3816,6 +3818,15 @@ new function() {
3816
3818
  return this._index;
3817
3819
  },
3818
3820
 
3821
+ setIndex: function(index) {
3822
+ var parent = this._parent,
3823
+ children = parent && parent._children;
3824
+ if (children) {
3825
+ parent.insertChildren(index in children ? index : undefined,
3826
+ [this]);
3827
+ }
3828
+ },
3829
+
3819
3830
  equals: function(item) {
3820
3831
  return item === this || item && this._class === item._class
3821
3832
  && this._style.equals(item._style)
@@ -4635,6 +4646,7 @@ new function() {
4635
4646
 
4636
4647
  fitBounds: function(rectangle, fill) {
4637
4648
  rectangle = Rectangle.read(arguments);
4649
+ fill = Base.read(arguments);
4638
4650
  var bounds = this.getBounds(),
4639
4651
  itemRatio = bounds.height / bounds.width,
4640
4652
  rectRatio = rectangle.height / rectangle.width,
@@ -5090,7 +5102,11 @@ var Shape = Item.extend({
5090
5102
  return;
5091
5103
  var size = radius * 2;
5092
5104
  this._radius = radius;
5093
- this._size._set(size, size);
5105
+ if (this._size) {
5106
+ this._size._set(size, size);
5107
+ } else {
5108
+ this._size = new Size(size, size);
5109
+ }
5094
5110
  } else {
5095
5111
  radius = Size.read(arguments);
5096
5112
  if (!this._radius) {
@@ -5367,7 +5383,7 @@ var Raster = Item.extend({
5367
5383
 
5368
5384
  initialize: function Raster(source, position) {
5369
5385
  if (!this._initialize(source,
5370
- position !== undefined && Point.read(arguments))) {
5386
+ position !== undefined && Point.read([position]))) {
5371
5387
  var image,
5372
5388
  type = typeof source,
5373
5389
  object = type === 'string'
@@ -10074,12 +10090,10 @@ Path.inject({ statics: new function() {
10074
10090
  from = Point.readNamed(args, 'from'),
10075
10091
  through = Point.readNamed(args, 'through'),
10076
10092
  to = Point.readNamed(args, 'to'),
10077
- props = Base.getNamed(args),
10078
- path = new Path(props && props.insert == false
10079
- && Item.NO_INSERT);
10080
- path.moveTo(from);
10081
- path.arcTo(through, to);
10082
- return path.set(props);
10093
+ arc = new Path(Item.NO_INSERT);
10094
+ arc.moveTo(from);
10095
+ arc.arcTo(through, to);
10096
+ return createPath(arc._segments, false, args);
10083
10097
  },
10084
10098
 
10085
10099
  RegularPolygon: function() {
@@ -13099,7 +13113,7 @@ var View = Base.extend(Emitter, {
13099
13113
  pixels = parseFloat(DomElement.getStyles(temp).fontSize);
13100
13114
  parent.removeChild(temp);
13101
13115
  } else {
13102
- pixels = parseFloat(pixels);
13116
+ pixels = parseFloat(size);
13103
13117
  }
13104
13118
  return pixels;
13105
13119
  },
@@ -13923,8 +13937,8 @@ var ToolEvent = Event.extend({
13923
13937
  },
13924
13938
 
13925
13939
  setCount: function(count) {
13926
- this.tool[/^mouse(down|up)$/.test(this.type) ? 'downCount' : 'count']
13927
- = count;
13940
+ this.tool[/^mouse(down|up)$/.test(this.type)
13941
+ ? '_downCount' : '_moveCount'] = count;
13928
13942
  },
13929
13943
 
13930
13944
  getItem: function() {
@@ -14010,8 +14024,6 @@ var Tool = PaperScopeItem.extend({
14010
14024
  type = 'mousemove';
14011
14025
  var move = mouse.move || mouse.drag,
14012
14026
  responds = this.responds(type),
14013
- minDistance = this.minDistance,
14014
- maxDistance = this.maxDistance,
14015
14027
  called = false,
14016
14028
  tool = this;
14017
14029
  function update(minDistance, maxDistance) {
@@ -14054,10 +14066,10 @@ var Tool = PaperScopeItem.extend({
14054
14066
  update();
14055
14067
  emit();
14056
14068
  } else if (mouse.up) {
14057
- update(null, maxDistance);
14069
+ update(null, this._maxDistance);
14058
14070
  emit();
14059
14071
  } else if (responds) {
14060
- while (update(minDistance, maxDistance))
14072
+ while (update(this._minDistance, this._maxDistance))
14061
14073
  emit();
14062
14074
  }
14063
14075
  return called;
@@ -14191,8 +14203,8 @@ var Tween = Base.extend(Emitter, {
14191
14203
  var key = keys[i],
14192
14204
  from = getValue(this._from[key]),
14193
14205
  to = getValue(this._to[key]),
14194
- value = (from && to && from.__add && to.__add)
14195
- ? to.__subtract(from).__multiply(factor).__add(from)
14206
+ value = (from && to && from.multiply && to.multiply)
14207
+ ? to.subtract(from).multiply(factor).add(from)
14196
14208
  : ((to - from) * factor) + from;
14197
14209
  this._setProperty(this._parsedKeys[key], value);
14198
14210
  }
@@ -14273,7 +14285,16 @@ var Tween = Base.extend(Emitter, {
14273
14285
  },
14274
14286
 
14275
14287
  _calculate: function(left, operator, right) {
14276
- return paper.PaperScript.calculateBinary(left, operator, right);
14288
+ var name = { '+': 'add', '-': 'subtract', '*': 'multiply',
14289
+ '/': 'divide' }[operator];
14290
+ if (left && left[name])
14291
+ return left[name](right);
14292
+ switch (operator) {
14293
+ case '+': return left + right;
14294
+ case '-': return left - right;
14295
+ case '*': return left * right;
14296
+ case '/': return left / right;
14297
+ }
14277
14298
  },
14278
14299
 
14279
14300
  _parseKeys: function(keys) {
@@ -14972,7 +14993,7 @@ new function() {
14972
14993
  PointText: exportText
14973
14994
  };
14974
14995
 
14975
- function applyStyle(item, node, isRoot) {
14996
+ function applyStyle(item, node, options, isRoot) {
14976
14997
  var attrs = {},
14977
14998
  parent = !isRoot && item.getParent(),
14978
14999
  style = [];
@@ -14986,7 +15007,8 @@ new function() {
14986
15007
  value = item[get]();
14987
15008
  if (entry.exportFilter
14988
15009
  ? entry.exportFilter(item, value)
14989
- : !parent || !Base.equals(parent[get](), value)) {
15010
+ : options.reduceAttributes == false
15011
+ || !parent || !Base.equals(parent[get](), value)) {
14990
15012
  if (type === 'color' && value != null) {
14991
15013
  var alpha = value.getAlpha();
14992
15014
  if (alpha < 1)
@@ -15068,7 +15090,7 @@ new function() {
15068
15090
  if (data && data !== '{}' && data !== 'null')
15069
15091
  node.setAttribute('data-paper-data', data);
15070
15092
  }
15071
- return node && applyStyle(item, node, isRoot);
15093
+ return node && applyStyle(item, node, options, isRoot);
15072
15094
  }
15073
15095
 
15074
15096
  function setOptions(options) {
@@ -15358,7 +15380,7 @@ new function() {
15358
15380
  if (!transform)
15359
15381
  break;
15360
15382
  var parts = transform.split(/\(\s*/),
15361
- command = parts[0],
15383
+ command = parts[0].trim(),
15362
15384
  v = parts[1].split(/[\s,]+/g);
15363
15385
  for (var j = 0, m = v.length; j < m; j++)
15364
15386
  v[j] = parseFloat(v[j]);
@@ -15534,10 +15556,27 @@ new function() {
15534
15556
  return res;
15535
15557
  }
15536
15558
 
15559
+ var sandbox;
15560
+
15561
+ function getSandbox() {
15562
+ if (!(sandbox && sandbox.contentDocument)) {
15563
+ sandbox = document.createElement('iframe');
15564
+ sandbox.setAttribute('sandbox', 'allow-same-origin');
15565
+ sandbox.style.cssText = 'position: absolute; visibility: hidden;'
15566
+ + ' width: 0; height: 0; border: 0';
15567
+ document.body.appendChild(sandbox);
15568
+ var doc = sandbox.contentDocument,
15569
+ meta = doc.createElement('meta');
15570
+ meta.httpEquiv = 'Content-Security-Policy';
15571
+ meta.content = "default-src 'none'; style-src 'unsafe-inline'";
15572
+ doc.head.appendChild(meta);
15573
+ }
15574
+ return sandbox.contentDocument.body;
15575
+ }
15576
+
15537
15577
  function importNode(node, options, isRoot) {
15538
15578
  var type = node.nodeName.toLowerCase(),
15539
15579
  isElement = type !== '#document',
15540
- body = document.body,
15541
15580
  container,
15542
15581
  parent,
15543
15582
  next;
@@ -15550,46 +15589,53 @@ new function() {
15550
15589
  parent = node.parentNode;
15551
15590
  next = node.nextSibling;
15552
15591
  container.appendChild(node);
15553
- body.appendChild(container);
15592
+ getSandbox().appendChild(container);
15554
15593
  }
15555
15594
  var settings = paper.settings,
15556
15595
  applyMatrix = settings.applyMatrix,
15557
- insertItems = settings.insertItems;
15558
- settings.applyMatrix = false;
15559
- settings.insertItems = false;
15560
- var importer = importers[type],
15561
- item = importer && importer(node, type, options, isRoot) || null;
15562
- settings.insertItems = insertItems;
15563
- settings.applyMatrix = applyMatrix;
15564
- if (item) {
15565
- if (isElement && !(item instanceof Group))
15566
- item = applyAttributes(item, node, isRoot);
15567
- var onImport = options.onImport,
15568
- data = isElement && node.getAttribute('data-paper-data');
15569
- if (onImport)
15570
- item = onImport(node, item, options) || item;
15571
- if (options.expandShapes && item instanceof Shape) {
15572
- item.remove();
15573
- item = item.toPath();
15596
+ insertItems = settings.insertItems,
15597
+ item;
15598
+ try {
15599
+ settings.applyMatrix = false;
15600
+ settings.insertItems = false;
15601
+ try {
15602
+ var importer = importers[type];
15603
+ item = importer && importer(node, type, options, isRoot)
15604
+ || null;
15605
+ } finally {
15606
+ settings.insertItems = insertItems;
15607
+ settings.applyMatrix = applyMatrix;
15608
+ }
15609
+ if (item) {
15610
+ if (isElement && !(item instanceof Group))
15611
+ item = applyAttributes(item, node, isRoot);
15612
+ var onImport = options.onImport,
15613
+ data = isElement && node.getAttribute('data-paper-data');
15614
+ if (onImport)
15615
+ item = onImport(node, item, options) || item;
15616
+ if (options.expandShapes && item instanceof Shape) {
15617
+ item.remove();
15618
+ item = item.toPath();
15619
+ }
15620
+ if (data)
15621
+ item._data = JSON.parse(data);
15574
15622
  }
15575
- if (data)
15576
- item._data = JSON.parse(data);
15577
- }
15578
- if (container) {
15579
- body.removeChild(container);
15580
- if (parent) {
15581
- if (next) {
15582
- parent.insertBefore(node, next);
15583
- } else {
15584
- parent.appendChild(node);
15623
+ } finally {
15624
+ if (container) {
15625
+ container.parentNode.removeChild(container);
15626
+ if (parent) {
15627
+ if (next) {
15628
+ parent.insertBefore(node, next);
15629
+ } else {
15630
+ parent.appendChild(node);
15631
+ }
15585
15632
  }
15586
15633
  }
15634
+ if (isRoot)
15635
+ definitions = {};
15587
15636
  }
15588
- if (isRoot) {
15589
- definitions = {};
15590
- if (item && Base.pick(options.applyMatrix, applyMatrix))
15591
- item.matrix.apply(true, true);
15592
- }
15637
+ if (isRoot && item && Base.pick(options.applyMatrix, applyMatrix))
15638
+ item.matrix.apply(true, true);
15593
15639
  return item;
15594
15640
  }
15595
15641