paper 0.12.20 → 0.13.0
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.
- package/CHANGELOG.md +233 -0
- package/README.md +29 -13
- package/dist/docs/assets/js/paper.js +788 -365
- package/dist/docs/classes/Color.html +63 -47
- package/dist/docs/classes/CompoundPath.html +162 -59
- package/dist/docs/classes/Curve.html +9 -7
- package/dist/docs/classes/CurveLocation.html +1 -1
- package/dist/docs/classes/Event.html +1 -1
- package/dist/docs/classes/Gradient.html +1 -1
- package/dist/docs/classes/GradientStop.html +1 -1
- package/dist/docs/classes/Group.html +63 -24
- package/dist/docs/classes/HitResult.html +1 -1
- package/dist/docs/classes/Item.html +63 -24
- package/dist/docs/classes/Key.html +1 -1
- package/dist/docs/classes/KeyEvent.html +1 -1
- package/dist/docs/classes/Layer.html +63 -24
- package/dist/docs/classes/Matrix.html +1 -1
- package/dist/docs/classes/MouseEvent.html +1 -1
- package/dist/docs/classes/PaperScope.html +87 -1
- package/dist/docs/classes/PaperScript.html +1 -1
- package/dist/docs/classes/Path.html +174 -68
- package/dist/docs/classes/PathItem.html +280 -177
- package/dist/docs/classes/Point.html +143 -21
- package/dist/docs/classes/PointText.html +94 -24
- package/dist/docs/classes/Project.html +14 -8
- package/dist/docs/classes/Raster.html +93 -35
- package/dist/docs/classes/Rectangle.html +12 -11
- package/dist/docs/classes/Segment.html +1 -1
- package/dist/docs/classes/Shape.html +63 -24
- package/dist/docs/classes/Size.html +81 -21
- package/dist/docs/classes/Style.html +34 -2
- package/dist/docs/classes/SymbolDefinition.html +1 -1
- package/dist/docs/classes/SymbolItem.html +64 -25
- package/dist/docs/classes/TextItem.html +94 -24
- package/dist/docs/classes/Tool.html +2 -1
- package/dist/docs/classes/ToolEvent.html +27 -1
- package/dist/docs/classes/Tween.html +1 -1
- package/dist/docs/classes/View.html +203 -10
- package/dist/docs/classes/global.html +1 -1
- package/dist/docs/classes/index.html +2 -2
- package/dist/docs/index.html +1 -1
- package/dist/node/canvas.js +1 -1
- package/dist/node/self.js +4 -3
- package/dist/paper-core.js +769 -354
- package/dist/paper-core.min.js +3 -3
- package/dist/paper-full.js +788 -365
- package/dist/paper-full.min.js +3 -3
- package/dist/paper.d.ts +324 -73
- package/examples/Rasters/Smoothing.html +1 -1
- package/package.json +1 -8
- package/dist/node/xml.js +0 -40
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
<h1>View</h1>
|
|
17
17
|
|
|
18
18
|
<p>The View object wraps an HTML element and handles drawing and user interaction through mouse and keyboard for it. It offer means to scroll the view, find the currently visible bounds in project coordinates, or the center, both useful for constructing artwork that should appear centered on screen.</p>
|
|
19
|
+
<p>If the canvas element has a <code>resize</code> or <code>data-paper-resize</code> attribute, the view adjusts its size to the size of the element whenever the window is resized. The element itself needs to be sized through CSS, e.g. with <code>html, body { height: 100%; }</code> and <code>canvas[resize] { width: 100%; height:
|
|
20
|
+
100%; }</code> for a canvas that fills the window. Without such CSS, the view does not follow the window, and on HiDPI screens it grows with each resize.</p>
|
|
19
21
|
|
|
20
22
|
</div>
|
|
21
23
|
|
|
@@ -76,6 +78,34 @@
|
|
|
76
78
|
|
|
77
79
|
|
|
78
80
|
|
|
81
|
+
</div>
|
|
82
|
+
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
<div id="project" class="member">
|
|
88
|
+
<div class="member-link">
|
|
89
|
+
<a name="project" href="#project"><tt><b>project</b></tt></a>
|
|
90
|
+
</div>
|
|
91
|
+
<div class="member-description hidden">
|
|
92
|
+
|
|
93
|
+
<div class="member-text">
|
|
94
|
+
<p>The project that this view displays.</p>
|
|
95
|
+
|
|
96
|
+
<p>Read only.</p>
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
<ul class="member-list">
|
|
101
|
+
<h4>Type:</h4>
|
|
102
|
+
<li>
|
|
103
|
+
<a href="../classes/Project.html"><tt>Project</tt></a>
|
|
104
|
+
</li>
|
|
105
|
+
</ul>
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
79
109
|
</div>
|
|
80
110
|
|
|
81
111
|
</div>
|
|
@@ -253,7 +283,7 @@
|
|
|
253
283
|
<div class="member-description hidden">
|
|
254
284
|
|
|
255
285
|
<div class="member-text">
|
|
256
|
-
<p>The view’s zoom factor by which the project coordinates are magnified.</p>
|
|
286
|
+
<p>The view’s zoom factor by which the project coordinates are magnified. Setting it to a value that isn’t a positive number has no effect.</p>
|
|
257
287
|
|
|
258
288
|
|
|
259
289
|
|
|
@@ -721,6 +751,97 @@ view.onResize = function(event) {
|
|
|
721
751
|
</ul>
|
|
722
752
|
|
|
723
753
|
|
|
754
|
+
</div>
|
|
755
|
+
|
|
756
|
+
</div>
|
|
757
|
+
</div>
|
|
758
|
+
|
|
759
|
+
|
|
760
|
+
<div id="onkeydown" class="member">
|
|
761
|
+
<div class="member-link">
|
|
762
|
+
<a name="onkeydown" href="#onkeydown"><tt><b>onKeyDown</b></tt></a>
|
|
763
|
+
</div>
|
|
764
|
+
<div class="member-description hidden">
|
|
765
|
+
|
|
766
|
+
<div class="member-text">
|
|
767
|
+
<p>The function to be called when the user presses a key on the keyboard. The function receives a <a href="../classes/KeyEvent.html"><tt>KeyEvent</tt></a> object which contains information about the keyboard event.</p>
|
|
768
|
+
<p>If the function returns <code>false</code>, the keyboard event will be prevented from bubbling up. This can be used for example to stop the window from scrolling, when you need the user to interact with arrow keys.</p>
|
|
769
|
+
|
|
770
|
+
|
|
771
|
+
|
|
772
|
+
<ul class="member-list">
|
|
773
|
+
<h4>Type:</h4>
|
|
774
|
+
<li>
|
|
775
|
+
<tt>Function</tt>⟋<tt>null</tt>
|
|
776
|
+
</li>
|
|
777
|
+
</ul>
|
|
778
|
+
|
|
779
|
+
|
|
780
|
+
<h4>Example:<span class="description">Scaling a path whenever the user presses the space bar:</span></h4>
|
|
781
|
+
|
|
782
|
+
<div class="paperscript split">
|
|
783
|
+
|
|
784
|
+
<div class="buttons">
|
|
785
|
+
<div class="button run">Run</div>
|
|
786
|
+
</div>
|
|
787
|
+
|
|
788
|
+
<script type="text/paperscript" canvas="canvas-1">
|
|
789
|
+
// Create a circle shaped path:
|
|
790
|
+
var path = new Path.Circle({
|
|
791
|
+
center: new Point(50, 50),
|
|
792
|
+
radius: 30,
|
|
793
|
+
fillColor: 'red'
|
|
794
|
+
});
|
|
795
|
+
|
|
796
|
+
view.onKeyDown = function(event) {
|
|
797
|
+
if (event.key == 'space') {
|
|
798
|
+
// Scale the path by 110%:
|
|
799
|
+
path.scale(1.1);
|
|
800
|
+
|
|
801
|
+
// Prevent the key event from bubbling
|
|
802
|
+
return false;
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
</script>
|
|
806
|
+
<div class="canvas"><canvas width="516" height="100" id="canvas-1"></canvas></div>
|
|
807
|
+
</div>
|
|
808
|
+
|
|
809
|
+
|
|
810
|
+
</div>
|
|
811
|
+
|
|
812
|
+
</div>
|
|
813
|
+
</div>
|
|
814
|
+
|
|
815
|
+
|
|
816
|
+
<div id="onkeyup" class="member">
|
|
817
|
+
<div class="member-link">
|
|
818
|
+
<a name="onkeyup" href="#onkeyup"><tt><b>onKeyUp</b></tt></a>
|
|
819
|
+
</div>
|
|
820
|
+
<div class="member-description hidden">
|
|
821
|
+
|
|
822
|
+
<div class="member-text">
|
|
823
|
+
<p>The function to be called when the user releases a key on the keyboard. The function receives a <a href="../classes/KeyEvent.html"><tt>KeyEvent</tt></a> object which contains information about the keyboard event.</p>
|
|
824
|
+
<p>If the function returns <code>false</code>, the keyboard event will be prevented from bubbling up. This can be used for example to stop the window from scrolling, when you need the user to interact with arrow keys.</p>
|
|
825
|
+
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
<ul class="member-list">
|
|
829
|
+
<h4>Type:</h4>
|
|
830
|
+
<li>
|
|
831
|
+
<tt>Function</tt>⟋<tt>null</tt>
|
|
832
|
+
</li>
|
|
833
|
+
</ul>
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
<h4>Example:</h4>
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
<pre><code>view.onKeyUp = function(event) {
|
|
840
|
+
if (event.key == 'space') {
|
|
841
|
+
console.log('The spacebar was released!');
|
|
842
|
+
}
|
|
843
|
+
}</code></pre>
|
|
844
|
+
|
|
724
845
|
</div>
|
|
725
846
|
|
|
726
847
|
</div>
|
|
@@ -758,13 +879,25 @@ view.onResize = function(event) {
|
|
|
758
879
|
|
|
759
880
|
<div id="update" class="member">
|
|
760
881
|
<div class="member-link">
|
|
761
|
-
<a name="update" href="#update"><tt><b>update</b>()</tt></a>
|
|
882
|
+
<a name="update" href="#update"><tt><b>update</b>([force])</tt></a>
|
|
762
883
|
</div>
|
|
763
884
|
<div class="member-description hidden">
|
|
764
885
|
<div class="member-text">
|
|
765
|
-
<p>Updates the view if there are changes. Note that when using built-in event
|
|
886
|
+
<p>Updates the view if there are changes. Note that when using built-in event handlers for interaction, animation and load events, this method is invoked for you automatically at the end.</p>
|
|
766
887
|
|
|
767
888
|
|
|
889
|
+
<ul class="member-list">
|
|
890
|
+
<h4>Parameters:</h4>
|
|
891
|
+
|
|
892
|
+
<li>
|
|
893
|
+
<tt>force:</tt>
|
|
894
|
+
<tt>Boolean</tt>
|
|
895
|
+
— whether to redraw the view even if nothing has changed, e.g. after a web font used by text items has finished loading
|
|
896
|
+
— optional, default: <tt>false</tt>
|
|
897
|
+
</li>
|
|
898
|
+
|
|
899
|
+
</ul>
|
|
900
|
+
|
|
768
901
|
|
|
769
902
|
<ul class="member-list">
|
|
770
903
|
<h4>Returns:</h4>
|
|
@@ -1282,6 +1415,66 @@ view.onResize = function(event) {
|
|
|
1282
1415
|
|
|
1283
1416
|
|
|
1284
1417
|
|
|
1418
|
+
</div>
|
|
1419
|
+
</div>
|
|
1420
|
+
</div>
|
|
1421
|
+
|
|
1422
|
+
|
|
1423
|
+
<div id="fitbounds-rectangle" class="member">
|
|
1424
|
+
<div class="member-link">
|
|
1425
|
+
<a name="fitbounds-rectangle" href="#fitbounds-rectangle"><tt><b>fitBounds</b>(rectangle[, fit])</tt></a>
|
|
1426
|
+
</div>
|
|
1427
|
+
<div class="member-description hidden">
|
|
1428
|
+
<div class="member-text">
|
|
1429
|
+
<p>Transform the view so that the specified rectangle is centered in it and fitted to it as described by <code>fit</code>, keeping the view’s rotation and mirroring.</p>
|
|
1430
|
+
|
|
1431
|
+
|
|
1432
|
+
<ul class="member-list">
|
|
1433
|
+
<h4>Parameters:</h4>
|
|
1434
|
+
|
|
1435
|
+
<li>
|
|
1436
|
+
<tt>rectangle:</tt>
|
|
1437
|
+
<a href="../classes/Rectangle.html"><tt>Rectangle</tt></a>
|
|
1438
|
+
— the rectangle to fit, in project coordinates
|
|
1439
|
+
|
|
1440
|
+
</li>
|
|
1441
|
+
|
|
1442
|
+
<li>
|
|
1443
|
+
<tt>fit:</tt>
|
|
1444
|
+
<tt>String</tt>
|
|
1445
|
+
— how to fit the rectangle, as in CSS’s <code>object-fit</code>: <code>'contain'</code> shows all of it, and <code>'cover'</code> fills the whole view with it, cropping the parts that don’t fit
|
|
1446
|
+
— optional, default: <tt>‘contain’</tt>
|
|
1447
|
+
</li>
|
|
1448
|
+
|
|
1449
|
+
</ul>
|
|
1450
|
+
|
|
1451
|
+
|
|
1452
|
+
|
|
1453
|
+
|
|
1454
|
+
|
|
1455
|
+
<h4>Example:<span class="description">Fitting the view to the bounds of an item:</span></h4>
|
|
1456
|
+
|
|
1457
|
+
<div class="paperscript split">
|
|
1458
|
+
|
|
1459
|
+
<div class="buttons">
|
|
1460
|
+
<div class="button run">Run</div>
|
|
1461
|
+
</div>
|
|
1462
|
+
|
|
1463
|
+
<script type="text/paperscript" canvas="canvas-2">
|
|
1464
|
+
// Create a circle shaped path around the top left corner of the view:
|
|
1465
|
+
var path = new Path.Circle({
|
|
1466
|
+
center: [0, 0],
|
|
1467
|
+
radius: 50,
|
|
1468
|
+
fillColor: 'orange'
|
|
1469
|
+
});
|
|
1470
|
+
|
|
1471
|
+
// Make the view show the whole circle:
|
|
1472
|
+
view.fitBounds(path.bounds);
|
|
1473
|
+
</script>
|
|
1474
|
+
<div class="canvas"><canvas width="516" height="100" id="canvas-2"></canvas></div>
|
|
1475
|
+
</div>
|
|
1476
|
+
|
|
1477
|
+
|
|
1285
1478
|
</div>
|
|
1286
1479
|
</div>
|
|
1287
1480
|
</div>
|
|
@@ -1462,7 +1655,7 @@ view.onResize = function(event) {
|
|
|
1462
1655
|
<div class="button run">Run</div>
|
|
1463
1656
|
</div>
|
|
1464
1657
|
|
|
1465
|
-
<script type="text/paperscript" canvas="canvas-
|
|
1658
|
+
<script type="text/paperscript" canvas="canvas-3">
|
|
1466
1659
|
var path = new Path.Rectangle(new Point(50, 25), new Size(50, 50));
|
|
1467
1660
|
path.fillColor = 'black';
|
|
1468
1661
|
|
|
@@ -1473,7 +1666,7 @@ var frameHandler = function(event) {
|
|
|
1473
1666
|
|
|
1474
1667
|
view.on('frame', frameHandler);
|
|
1475
1668
|
</script>
|
|
1476
|
-
<div class="canvas"><canvas width="516" height="100" id="canvas-
|
|
1669
|
+
<div class="canvas"><canvas width="516" height="100" id="canvas-3"></canvas></div>
|
|
1477
1670
|
</div>
|
|
1478
1671
|
|
|
1479
1672
|
|
|
@@ -1525,7 +1718,7 @@ view.on('frame', frameHandler);
|
|
|
1525
1718
|
<div class="button run">Run</div>
|
|
1526
1719
|
</div>
|
|
1527
1720
|
|
|
1528
|
-
<script type="text/paperscript" canvas="canvas-
|
|
1721
|
+
<script type="text/paperscript" canvas="canvas-4">
|
|
1529
1722
|
var path = new Path.Rectangle(new Point(50, 25), new Size(50, 50));
|
|
1530
1723
|
path.fillColor = 'black';
|
|
1531
1724
|
|
|
@@ -1538,7 +1731,7 @@ view.on({
|
|
|
1538
1731
|
frame: frameHandler
|
|
1539
1732
|
});
|
|
1540
1733
|
</script>
|
|
1541
|
-
<div class="canvas"><canvas width="516" height="100" id="canvas-
|
|
1734
|
+
<div class="canvas"><canvas width="516" height="100" id="canvas-4"></canvas></div>
|
|
1542
1735
|
</div>
|
|
1543
1736
|
|
|
1544
1737
|
|
|
@@ -1597,7 +1790,7 @@ view.on({
|
|
|
1597
1790
|
<div class="button run">Run</div>
|
|
1598
1791
|
</div>
|
|
1599
1792
|
|
|
1600
|
-
<script type="text/paperscript" canvas="canvas-
|
|
1793
|
+
<script type="text/paperscript" canvas="canvas-5">
|
|
1601
1794
|
var path = new Path.Rectangle(new Point(50, 25), new Size(50, 50));
|
|
1602
1795
|
path.fillColor = 'black';
|
|
1603
1796
|
|
|
@@ -1616,7 +1809,7 @@ function onMouseDown(event) {
|
|
|
1616
1809
|
view.off('frame');
|
|
1617
1810
|
}
|
|
1618
1811
|
</script>
|
|
1619
|
-
<div class="canvas"><canvas width="516" height="100" id="canvas-
|
|
1812
|
+
<div class="canvas"><canvas width="516" height="100" id="canvas-5"></canvas></div>
|
|
1620
1813
|
</div>
|
|
1621
1814
|
|
|
1622
1815
|
|
|
@@ -1763,7 +1956,7 @@ function onMouseDown(event) {
|
|
|
1763
1956
|
|
|
1764
1957
|
<!-- =========================== copyright notice ========================== -->
|
|
1765
1958
|
<p class="footer">
|
|
1766
|
-
Paper.js v0.
|
|
1959
|
+
Paper.js v0.13.0<br>
|
|
1767
1960
|
Copyright © 2011—2026 <a href="http://www.lehni.org" target="_blank">Jürg Lehni</a> & <a href="http://www.jonathanpuckey.com" target="_blank">Jonathan Puckey</a>. All Rights Reserved.</p>
|
|
1768
1961
|
<div class="content-end"></div>
|
|
1769
1962
|
|
|
@@ -416,7 +416,7 @@
|
|
|
416
416
|
|
|
417
417
|
<!-- =========================== copyright notice ========================== -->
|
|
418
418
|
<p class="footer">
|
|
419
|
-
Paper.js v0.
|
|
419
|
+
Paper.js v0.13.0<br>
|
|
420
420
|
Copyright © 2011—2026 <a href="http://www.lehni.org" target="_blank">Jürg Lehni</a> & <a href="http://www.jonathanpuckey.com" target="_blank">Jonathan Puckey</a>. All Rights Reserved.</p>
|
|
421
421
|
<div class="content-end"></div>
|
|
422
422
|
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
<html>
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8">
|
|
5
|
-
<title>Paper.js v0.
|
|
5
|
+
<title>Paper.js v0.13.0</title>
|
|
6
6
|
<base target="class-frame">
|
|
7
7
|
<link href="../assets/css/docs.css" rel="stylesheet" type="text/css">
|
|
8
8
|
</head>
|
|
9
9
|
<body class="reference">
|
|
10
10
|
<div class="reference-index">
|
|
11
|
-
<h1>Paper.js<span class="version">0.
|
|
11
|
+
<h1>Paper.js<span class="version">0.13.0</span></h1>
|
|
12
12
|
<ul class="reference-classes"><li><a href="../classes/global.html">Global Scope</a></li>
|
|
13
13
|
<li>
|
|
14
14
|
<h2>Basic Types</h2>
|
package/dist/docs/index.html
CHANGED
package/dist/node/canvas.js
CHANGED
|
@@ -24,7 +24,7 @@ module.exports = function(self, requireName) {
|
|
|
24
24
|
// Check the required module's name to see if it contains canvas, and
|
|
25
25
|
// only complain about its lack if the module requires it.
|
|
26
26
|
if (/\bcanvas\b/.test(requireName)) {
|
|
27
|
-
throw new Error('Unable to load canvas module.');
|
|
27
|
+
throw new Error('Unable to load canvas module.', { cause: error });
|
|
28
28
|
}
|
|
29
29
|
return false;
|
|
30
30
|
}
|
package/dist/node/self.js
CHANGED
|
@@ -18,7 +18,9 @@ var path = require('path');
|
|
|
18
18
|
// 'paper-jsdom' or 'paper-jsdom-canvas'), and use this to determine if error
|
|
19
19
|
// exceptions should be thrown or if loading should fail silently.
|
|
20
20
|
var parent = module.parent && module.parent.parent,
|
|
21
|
-
|
|
21
|
+
// The REPL's module has no filename:
|
|
22
|
+
requireName = parent && parent.filename &&
|
|
23
|
+
path.basename(path.dirname(parent.filename));
|
|
22
24
|
requireName = /^paper/.test(requireName) ? requireName : 'paper';
|
|
23
25
|
|
|
24
26
|
var jsdom,
|
|
@@ -30,7 +32,7 @@ try {
|
|
|
30
32
|
// Check the required module's name to see if it contains jsdom, and only
|
|
31
33
|
// complain about its lack if the module requires it.
|
|
32
34
|
if (/\bjsdom\b/.test(requireName)) {
|
|
33
|
-
throw new Error('Unable to load jsdom module.');
|
|
35
|
+
throw new Error('Unable to load jsdom module.', { cause: e });
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
|
|
@@ -53,7 +55,6 @@ if (jsdom) {
|
|
|
53
55
|
// jsdom's window can't be removed from itself, so inherit from it:
|
|
54
56
|
self = Object.create(self, { window: { value: null } });
|
|
55
57
|
}
|
|
56
|
-
require('./xml.js')(self);
|
|
57
58
|
} else {
|
|
58
59
|
self = {
|
|
59
60
|
navigator: {
|