paper 0.12.18 → 0.12.20

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 (231) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/README.md +5 -14
  3. package/dist/docs/assets/js/paper.js +94 -54
  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 +2 -2
  27. package/dist/docs/classes/Rectangle.html +2 -2
  28. package/dist/docs/classes/Segment.html +2 -2
  29. package/dist/docs/classes/Shape.html +2 -2
  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/node/canvas.js +9 -7
  43. package/dist/node/self.js +9 -1
  44. package/dist/paper-core.js +93 -53
  45. package/dist/paper-core.min.js +3 -3
  46. package/dist/paper-full.js +94 -54
  47. package/dist/paper-full.min.js +3 -3
  48. package/dist/paper.d.ts +2 -2
  49. package/package.json +11 -7
  50. package/dist/paperjs/LICENSE.txt +0 -23
  51. package/dist/paperjs/dist/node/canvas.js +0 -66
  52. package/dist/paperjs/dist/node/extend.js +0 -156
  53. package/dist/paperjs/dist/node/self.js +0 -58
  54. package/dist/paperjs/dist/node/xml.js +0 -40
  55. package/dist/paperjs/dist/paper-core.d.ts +0 -1
  56. package/dist/paperjs/dist/paper-core.js +0 -15703
  57. package/dist/paperjs/dist/paper-core.min.js +0 -32
  58. package/dist/paperjs/dist/paper-full.js +0 -17472
  59. package/dist/paperjs/dist/paper-full.min.js +0 -32
  60. package/dist/paperjs/dist/paper.d.ts +0 -7394
  61. package/dist/paperjs/docs/assets/css/docs.css +0 -414
  62. package/dist/paperjs/docs/assets/js/codemirror.js +0 -4
  63. package/dist/paperjs/docs/assets/js/docs.js +0 -493
  64. package/dist/paperjs/docs/assets/js/jquery.js +0 -6
  65. package/dist/paperjs/docs/assets/js/paper.js +0 -17472
  66. package/dist/paperjs/docs/classes/Color.html +0 -2188
  67. package/dist/paperjs/docs/classes/CompoundPath.html +0 -8877
  68. package/dist/paperjs/docs/classes/Curve.html +0 -2323
  69. package/dist/paperjs/docs/classes/CurveLocation.html +0 -672
  70. package/dist/paperjs/docs/classes/Event.html +0 -176
  71. package/dist/paperjs/docs/classes/Gradient.html +0 -240
  72. package/dist/paperjs/docs/classes/GradientStop.html +0 -273
  73. package/dist/paperjs/docs/classes/Group.html +0 -6864
  74. package/dist/paperjs/docs/classes/HitResult.html +0 -239
  75. package/dist/paperjs/docs/classes/Item.html +0 -6628
  76. package/dist/paperjs/docs/classes/Key.html +0 -139
  77. package/dist/paperjs/docs/classes/KeyEvent.html +0 -308
  78. package/dist/paperjs/docs/classes/Layer.html +0 -6850
  79. package/dist/paperjs/docs/classes/Matrix.html +0 -1744
  80. package/dist/paperjs/docs/classes/MouseEvent.html +0 -355
  81. package/dist/paperjs/docs/classes/PaperScope.html +0 -459
  82. package/dist/paperjs/docs/classes/PaperScript.html +0 -198
  83. package/dist/paperjs/docs/classes/Path.html +0 -11775
  84. package/dist/paperjs/docs/classes/PathItem.html +0 -8639
  85. package/dist/paperjs/docs/classes/Point.html +0 -2699
  86. package/dist/paperjs/docs/classes/PointText.html +0 -7029
  87. package/dist/paperjs/docs/classes/Project.html +0 -1305
  88. package/dist/paperjs/docs/classes/Raster.html +0 -7843
  89. package/dist/paperjs/docs/classes/Rectangle.html +0 -1654
  90. package/dist/paperjs/docs/classes/Segment.html +0 -939
  91. package/dist/paperjs/docs/classes/Shape.html +0 -7363
  92. package/dist/paperjs/docs/classes/Size.html +0 -1825
  93. package/dist/paperjs/docs/classes/Style.html +0 -919
  94. package/dist/paperjs/docs/classes/SymbolDefinition.html +0 -311
  95. package/dist/paperjs/docs/classes/SymbolItem.html +0 -6755
  96. package/dist/paperjs/docs/classes/TextItem.html +0 -6869
  97. package/dist/paperjs/docs/classes/Tool.html +0 -761
  98. package/dist/paperjs/docs/classes/ToolEvent.html +0 -446
  99. package/dist/paperjs/docs/classes/Tween.html +0 -374
  100. package/dist/paperjs/docs/classes/View.html +0 -1772
  101. package/dist/paperjs/docs/classes/global.html +0 -425
  102. package/dist/paperjs/docs/classes/index.html +0 -88
  103. package/dist/paperjs/docs/index.html +0 -11
  104. package/dist/paperjs/examples/Animated/AnimatedStar.html +0 -53
  105. package/dist/paperjs/examples/Animated/BooleanOperations.html +0 -115
  106. package/dist/paperjs/examples/Animated/CandyCrash.html +0 -151
  107. package/dist/paperjs/examples/Animated/Extruded.html +0 -50
  108. package/dist/paperjs/examples/Animated/Lines.html +0 -53
  109. package/dist/paperjs/examples/Animated/Smoothing.html +0 -70
  110. package/dist/paperjs/examples/Animated/Space.html +0 -86
  111. package/dist/paperjs/examples/Animated/SpaceUsingShapes.html +0 -79
  112. package/dist/paperjs/examples/Games/Paperoids.html +0 -569
  113. package/dist/paperjs/examples/JSON/Circle Testing.html +0 -34
  114. package/dist/paperjs/examples/JSON/Compound Path.html +0 -25
  115. package/dist/paperjs/examples/JSON/Empty Path Testing.html +0 -31
  116. package/dist/paperjs/examples/JSON/Gradients.html +0 -34
  117. package/dist/paperjs/examples/JSON/Group Transform.html +0 -28
  118. package/dist/paperjs/examples/JSON/Line Testing.html +0 -44
  119. package/dist/paperjs/examples/JSON/Random Path Testing.html +0 -42
  120. package/dist/paperjs/examples/JSON/Raster.html +0 -29
  121. package/dist/paperjs/examples/JSON/Rect and Attribute Testing.html +0 -56
  122. package/dist/paperjs/examples/JSON/Rotated Primitives.html +0 -55
  123. package/dist/paperjs/examples/JSON/Selection.html +0 -43
  124. package/dist/paperjs/examples/JSON/Shapes.html +0 -54
  125. package/dist/paperjs/examples/JSON/Symbols.html +0 -30
  126. package/dist/paperjs/examples/JSON/Text Testing.html +0 -38
  127. package/dist/paperjs/examples/JSON/Tiger.html +0 -19
  128. package/dist/paperjs/examples/JSON/Transform Test 1.html +0 -32
  129. package/dist/paperjs/examples/JSON/Transform Test 2.html +0 -30
  130. package/dist/paperjs/examples/Node.js/AnimatedStar.js +0 -52
  131. package/dist/paperjs/examples/Node.js/BooleanOperations.js +0 -36
  132. package/dist/paperjs/examples/Node.js/JSONtoPDF.js +0 -20
  133. package/dist/paperjs/examples/Node.js/Raster.js +0 -32
  134. package/dist/paperjs/examples/Node.js/RasterRemote.js +0 -33
  135. package/dist/paperjs/examples/Node.js/SvgExport.js +0 -52
  136. package/dist/paperjs/examples/Node.js/SvgImport.js +0 -23
  137. package/dist/paperjs/examples/Node.js/Tadpoles.js +0 -16
  138. package/dist/paperjs/examples/Node.js/Tadpoles.pjs +0 -278
  139. package/dist/paperjs/examples/Node.js/in.json +0 -1
  140. package/dist/paperjs/examples/Node.js/in.svg +0 -16
  141. package/dist/paperjs/examples/Paperjs.org/BooleanOperattions.html +0 -115
  142. package/dist/paperjs/examples/Paperjs.org/BouncingBalls.html +0 -103
  143. package/dist/paperjs/examples/Paperjs.org/Chain.html +0 -54
  144. package/dist/paperjs/examples/Paperjs.org/DivisionRaster.html +0 -72
  145. package/dist/paperjs/examples/Paperjs.org/FutureSplash.html +0 -122
  146. package/dist/paperjs/examples/Paperjs.org/HitTesting.html +0 -103
  147. package/dist/paperjs/examples/Paperjs.org/InteractiveTiger.html +0 -777
  148. package/dist/paperjs/examples/Paperjs.org/MetaBalls.html +0 -132
  149. package/dist/paperjs/examples/Paperjs.org/NyanRainbow.html +0 -202
  150. package/dist/paperjs/examples/Paperjs.org/PathIntersections.html +0 -76
  151. package/dist/paperjs/examples/Paperjs.org/Qbertify.html +0 -146
  152. package/dist/paperjs/examples/Paperjs.org/RadialRainbows.html +0 -80
  153. package/dist/paperjs/examples/Paperjs.org/RoundedRectangles.html +0 -41
  154. package/dist/paperjs/examples/Paperjs.org/SatieLikedToDraw.html +0 -140
  155. package/dist/paperjs/examples/Paperjs.org/Simplify.html +0 -63
  156. package/dist/paperjs/examples/Paperjs.org/SpiralRaster.html +0 -120
  157. package/dist/paperjs/examples/Paperjs.org/Tadpoles.html +0 -283
  158. package/dist/paperjs/examples/Paperjs.org/Voronoi.html +0 -134
  159. package/dist/paperjs/examples/Rasters/PhyllotaxisRaster.html +0 -96
  160. package/dist/paperjs/examples/Rasters/Raster.html +0 -34
  161. package/dist/paperjs/examples/Rasters/RotationRaster.html +0 -44
  162. package/dist/paperjs/examples/Rasters/Smoothing.html +0 -36
  163. package/dist/paperjs/examples/SVG Export/Circle Testing.html +0 -32
  164. package/dist/paperjs/examples/SVG Export/Clipping.html +0 -17
  165. package/dist/paperjs/examples/SVG Export/Compound Path.html +0 -22
  166. package/dist/paperjs/examples/SVG Export/Empty Path Testing.html +0 -28
  167. package/dist/paperjs/examples/SVG Export/Gradients.html +0 -52
  168. package/dist/paperjs/examples/SVG Export/Group Transform.html +0 -25
  169. package/dist/paperjs/examples/SVG Export/Line Testing.html +0 -41
  170. package/dist/paperjs/examples/SVG Export/Random Path Testing.html +0 -39
  171. package/dist/paperjs/examples/SVG Export/Raster.html +0 -21
  172. package/dist/paperjs/examples/SVG Export/Rect and Attribute Testing.html +0 -53
  173. package/dist/paperjs/examples/SVG Export/Rotated Primitives.html +0 -80
  174. package/dist/paperjs/examples/SVG Export/Shapes.html +0 -58
  175. package/dist/paperjs/examples/SVG Export/Symbols.html +0 -27
  176. package/dist/paperjs/examples/SVG Export/Text Testing.html +0 -45
  177. package/dist/paperjs/examples/SVG Export/Tiger.html +0 -23
  178. package/dist/paperjs/examples/SVG Export/Transform Test 1.html +0 -29
  179. package/dist/paperjs/examples/SVG Export/Transform Test 2.html +0 -27
  180. package/dist/paperjs/examples/SVG Import/Arcs.html +0 -78
  181. package/dist/paperjs/examples/SVG Import/Butterfly.html +0 -223
  182. package/dist/paperjs/examples/SVG Import/Circle and Ellipse Testing.html +0 -26
  183. package/dist/paperjs/examples/SVG Import/Clipping.html +0 -100
  184. package/dist/paperjs/examples/SVG Import/From File.html +0 -30
  185. package/dist/paperjs/examples/SVG Import/Gradient.html +0 -138
  186. package/dist/paperjs/examples/SVG Import/Gradients.html +0 -30
  187. package/dist/paperjs/examples/SVG Import/Inkscape Pivot.html +0 -52
  188. package/dist/paperjs/examples/SVG Import/Inkscape.html +0 -88
  189. package/dist/paperjs/examples/SVG Import/Line Testing.html +0 -24
  190. package/dist/paperjs/examples/SVG Import/MoreGradients.html +0 -107
  191. package/dist/paperjs/examples/SVG Import/Multiple Paths Test 1.html +0 -42
  192. package/dist/paperjs/examples/SVG Import/Multiple Paths Test 2.html +0 -33
  193. package/dist/paperjs/examples/SVG Import/Nested Groups Test.html +0 -78
  194. package/dist/paperjs/examples/SVG Import/Polybezier.html +0 -43
  195. package/dist/paperjs/examples/SVG Import/Rect Testing.html +0 -25
  196. package/dist/paperjs/examples/SVG Import/Symbols.html +0 -24
  197. package/dist/paperjs/examples/SVG Import/Testing.html +0 -40
  198. package/dist/paperjs/examples/SVG Import/Text Testing.html +0 -19
  199. package/dist/paperjs/examples/SVG Import/Tiger.html +0 -742
  200. package/dist/paperjs/examples/SVG Import/Transform Testing.html +0 -22
  201. package/dist/paperjs/examples/SVG Import/Viewbox.html +0 -38
  202. package/dist/paperjs/examples/Scripts/Arcs.html +0 -39
  203. package/dist/paperjs/examples/Scripts/BlendModes.html +0 -77
  204. package/dist/paperjs/examples/Scripts/BooleanOperations.html +0 -937
  205. package/dist/paperjs/examples/Scripts/CompoundPath.html +0 -19
  206. package/dist/paperjs/examples/Scripts/CurveTimeParameterization.html +0 -61
  207. package/dist/paperjs/examples/Scripts/HslColor.html +0 -53
  208. package/dist/paperjs/examples/Scripts/PathStructure.html +0 -82
  209. package/dist/paperjs/examples/Scripts/PathTangents.html +0 -73
  210. package/dist/paperjs/examples/Scripts/Resize.html +0 -42
  211. package/dist/paperjs/examples/Scripts/RoundRectangle.html +0 -28
  212. package/dist/paperjs/examples/Scripts/Shapes.html +0 -54
  213. package/dist/paperjs/examples/Scripts/StrokeBounds.html +0 -101
  214. package/dist/paperjs/examples/Scripts/StrokeScaling.html +0 -65
  215. package/dist/paperjs/examples/Tools/BezierTool.html +0 -90
  216. package/dist/paperjs/examples/Tools/Circles.html +0 -28
  217. package/dist/paperjs/examples/Tools/Clouds.html +0 -35
  218. package/dist/paperjs/examples/Tools/DrippingBrush.html +0 -73
  219. package/dist/paperjs/examples/Tools/FancyBrush.html +0 -82
  220. package/dist/paperjs/examples/Tools/Grid.html +0 -44
  221. package/dist/paperjs/examples/Tools/MultiLines.html +0 -44
  222. package/dist/paperjs/examples/Tools/MultipleTools.html +0 -44
  223. package/dist/paperjs/examples/Tools/PathEditing.html +0 -95
  224. package/dist/paperjs/examples/Tools/SquareRounded.html +0 -76
  225. package/dist/paperjs/examples/Tools/Stars.html +0 -38
  226. package/dist/paperjs/examples/Tools/Vektor.html +0 -200
  227. package/dist/paperjs/examples/Tools/Wave.html +0 -50
  228. package/dist/paperjs/examples/Tools/WormFarm.html +0 -88
  229. package/dist/paperjs/examples/Worker/Main.html +0 -53
  230. package/dist/paperjs/examples/Worker/Worker.js +0 -14
  231. package/dist/paperjs/examples/css/style.css +0 -12
package/dist/paper.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Paper.js v0.12.18 - The Swiss Army Knife of Vector Graphics Scripting.
2
+ * Paper.js v0.12.20 - 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 Jul 17 14:57:24 2024 +0200
12
+ * Date: Sun Oct 18 17:04:58 2026 +0200
13
13
  *
14
14
  * This is an auto-generated type definition.
15
15
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paper",
3
- "version": "0.12.18",
3
+ "version": "0.12.20",
4
4
  "description": "The Swiss Army Knife of Vector Graphics Scripting",
5
5
  "license": "MIT",
6
6
  "homepage": "http://paperjs.org",
@@ -26,13 +26,15 @@
26
26
  "jshint": "gulp jshint",
27
27
  "test": "gulp test",
28
28
  "test:browser": "gulp test:browser",
29
- "test:phantom": "gulp test:phantom",
30
29
  "test:node": "gulp test:node"
31
30
  },
32
31
  "files": [
33
32
  "AUTHORS.md",
34
33
  "CHANGELOG.md",
35
- "dist/",
34
+ "dist/paper-*.js",
35
+ "dist/*.d.ts",
36
+ "dist/node/*",
37
+ "dist/docs/**",
36
38
  "examples/",
37
39
  "LICENSE.txt",
38
40
  "README.md"
@@ -51,13 +53,14 @@
51
53
  "./dist/node/self.js": false,
52
54
  "canvas": false,
53
55
  "jsdom": false,
56
+ "jsdom/lib/generated/idl/utils": false,
54
57
  "jsdom/lib/jsdom/living/generated/utils": false,
55
58
  "source-map-support": false
56
59
  },
57
60
  "devDependencies": {
58
61
  "acorn": "~0.5.0",
59
62
  "ansi-colors": "^4.1.3",
60
- "canvas": "^2.11.2",
63
+ "canvas": "^3.2.3",
61
64
  "del": "^5.1.0",
62
65
  "fancy-log": "^1.3.3",
63
66
  "gulp": "^3.9.1",
@@ -76,7 +79,7 @@
76
79
  "gulp-whitespace": "^0.1.0",
77
80
  "gulp-zip": "^5.1.0",
78
81
  "husky": "^4.3.8",
79
- "jsdom": "^16.7.0",
82
+ "jsdom": "^28.1.0",
80
83
  "jshint": "^2.13.6",
81
84
  "jshint-summary": "^0.4.0",
82
85
  "merge-stream": "^2.0.0",
@@ -96,7 +99,8 @@
96
99
  "packages/*"
97
100
  ],
98
101
  "resolutions": {
99
- "graceful-fs": "4.2.2"
102
+ "graceful-fs": "4.2.2",
103
+ "resemblejs/canvas": "^3.2.3"
100
104
  },
101
105
  "keywords": [
102
106
  "vector",
@@ -115,4 +119,4 @@
115
119
  "paper.js",
116
120
  "paperjs"
117
121
  ]
118
- }
122
+ }
@@ -1,23 +0,0 @@
1
- Copyright (c) 2011 - 2020, Jürg Lehni & Jonathan Puckey
2
- http://juerglehni.com/ & https://puckey.studio/
3
- All rights reserved.
4
-
5
- The MIT License (MIT)
6
-
7
- Permission is hereby granted, free of charge, to any person obtaining a copy
8
- of this software and associated documentation files (the "Software"), to deal
9
- in the Software without restriction, including without limitation the rights
10
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- copies of the Software, and to permit persons to whom the Software is
12
- furnished to do so, subject to the following conditions:
13
-
14
- The above copyright notice and this permission notice shall be included in
15
- all copies or substantial portions of the Software.
16
-
17
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
- THE SOFTWARE.
@@ -1,66 +0,0 @@
1
- /*
2
- * Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
3
- * http://paperjs.org/
4
- *
5
- * Copyright (c) 2011 - 2020, Jürg Lehni & Jonathan Puckey
6
- * http://juerglehni.com/ & https://puckey.studio/
7
- *
8
- * Distributed under the MIT license. See LICENSE file for details.
9
- *
10
- * All rights reserved.
11
- */
12
-
13
- // Add some useful extensions to HTMLCanvasElement:
14
- // - HTMLCanvasElement#type, so we can switch to a PDF canvas
15
- // - Various Node-Canvas methods, routed through from HTMLCanvasElement:
16
- // toBuffer, pngStream, createPNGStream, jpegStream, createJPEGStream
17
-
18
- module.exports = function(self, requireName) {
19
- var Canvas;
20
- try {
21
- Canvas = require('canvas').Canvas;
22
- } catch(error) {
23
- // Remove `self.window`, so we still have the global `self` reference,
24
- // but no `window` object:
25
- // - On the browser, this corresponds to a worker context.
26
- // - On Node.js, it basically means the canvas is missing or not working
27
- // which can be treated the same way.
28
- delete self.window;
29
- // Check the required module's name to see if it contains canvas, and
30
- // only complain about its lack if the module requires it.
31
- if (/\bcanvas\b/.test(requireName)) {
32
- throw new Error('Unable to load canvas module.');
33
- }
34
- return;
35
- }
36
-
37
- var HTMLCanvasElement = self.HTMLCanvasElement,
38
- idlUtils = require('jsdom/lib/jsdom/living/generated/utils');
39
-
40
- // Add fake HTMLCanvasElement#type property:
41
- Object.defineProperty(HTMLCanvasElement.prototype, 'type', {
42
- get: function() {
43
- var canvas = idlUtils.implForWrapper(this)._canvas;
44
- return canvas && canvas.type || 'image';
45
- },
46
-
47
- set: function(type) {
48
- // Allow replacement of internal node-canvas, so we can switch to a
49
- // PDF canvas.
50
- var impl = idlUtils.implForWrapper(this),
51
- size = impl._canvas || impl;
52
- impl._canvas = new Canvas(size.width, size.height, type);
53
- impl._context = null;
54
- }
55
- });
56
-
57
- // Extend HTMLCanvasElement with useful methods from the underlying Canvas:
58
- var methods = ['toBuffer', 'pngStream', 'createPNGStream', 'jpegStream',
59
- 'createJPEGStream'];
60
- methods.forEach(function(key) {
61
- HTMLCanvasElement.prototype[key] = function() {
62
- var canvas = idlUtils.implForWrapper(this)._canvas;
63
- return canvas[key].apply(canvas, arguments);
64
- };
65
- });
66
- };
@@ -1,156 +0,0 @@
1
- /*
2
- * Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
3
- * http://paperjs.org/
4
- *
5
- * Copyright (c) 2011 - 2020, Jürg Lehni & Jonathan Puckey
6
- * http://juerglehni.com/ & https://puckey.studio/
7
- *
8
- * Distributed under the MIT license. See LICENSE file for details.
9
- *
10
- * All rights reserved.
11
- */
12
-
13
- var fs = require('fs'),
14
- path = require('path');
15
-
16
- module.exports = function(paper) {
17
- if (paper.PaperScript) {
18
- var sourceMapSupport = 'require("source-map-support").install(paper.PaperScript.sourceMapSupport);\n',
19
- sourceMaps = {};
20
-
21
- paper.PaperScript.sourceMapSupport = {
22
- retrieveSourceMap: function(source) {
23
- var map = sourceMaps[source];
24
- return map ? { url: source, map: map } : null;
25
- }
26
- };
27
-
28
- // Register the .pjs extension for automatic compilation as PaperScript
29
- require.extensions['.pjs'] = function(module, filename) {
30
- // Requiring a PaperScript on Node.js returns an initialize method which
31
- // needs to receive a Canvas object when called and returns the
32
- // PaperScope.
33
- module.exports = function(canvas) {
34
- var source = fs.readFileSync(filename, 'utf8'),
35
- code = sourceMapSupport + source,
36
- compiled = paper.PaperScript.compile(code, {
37
- url: filename,
38
- source: source,
39
- sourceMaps: true,
40
- offset: -1 // remove sourceMapSupport...
41
- }),
42
- scope = new paper.PaperScope();
43
- // Keep track of sourceMaps so retrieveSourceMap() can link them up
44
- scope.setup(canvas);
45
- scope.__filename = filename;
46
- scope.__dirname = path.dirname(filename);
47
- // Expose core methods and values
48
- scope.require = require;
49
- scope.console = console;
50
- sourceMaps[filename] = compiled.map;
51
- paper.PaperScript.execute(compiled, scope);
52
- return scope;
53
- };
54
- };
55
- }
56
-
57
- paper.PaperScope.inject({
58
- createCanvas: function(width, height, type) {
59
- // Do not use CanvasProvider.getCanvas(), since we may be changing
60
- // the underlying node-canvas when requesting PDF support, and don't
61
- // want to release it after back into the pool.
62
- var canvas = paper.document.createElement('canvas');
63
- canvas.width = width;
64
- canvas.height = height;
65
- canvas.type = type;
66
- return canvas;
67
- },
68
-
69
- /**
70
- * @deprecated, use use {@link #createCanvas(width, height)} instead.
71
- */
72
- Canvas: '#createCanvas'
73
- });
74
-
75
- // Override requestAnimationFrame() to avoid setInterval() timers.
76
- // NOTE: In Node.js, we only support manual updating for now, but
77
- // View#exportFrames() below offers a way to emulate animations by exporting
78
- // them frame by frame at the given frame-rate.
79
- paper.DomEvent.requestAnimationFrame = function(callback) {
80
- };
81
-
82
- // Node.js based image exporting code.
83
- paper.CanvasView.inject({
84
- // DOCS: CanvasView#exportFrames(options);
85
- exportFrames: function(options) {
86
- options = paper.Base.set({
87
- fps: 30,
88
- prefix: 'frame-',
89
- amount: 1,
90
- format: 'png' // Supported: 'png' or 'jpeg'
91
- }, options);
92
- if (!options.directory)
93
- throw new Error('Missing options.directory');
94
- if (options.format && !/^(jpeg|png)$/.test(options.format))
95
- throw new Error('Unsupported format. Use "png" or "jpeg"');
96
- var view = this,
97
- count = 0,
98
- frameDuration = 1 / options.fps,
99
- startTime = Date.now(),
100
- lastTime = startTime,
101
- padding = options.padding || ((options.amount - 1) + '').length,
102
- paddedStr = Array(padding + 1).join('0');
103
-
104
- // Start exporting frames by exporting the first frame:
105
- exportFrame(options);
106
-
107
- function exportFrame() {
108
- // Convert to a Base object, for #toString()
109
- view.emit('frame', new paper.Base({
110
- delta: frameDuration,
111
- time: frameDuration * count,
112
- count: count
113
- }));
114
- var file = path.join(options.directory,
115
- options.prefix + (paddedStr + count).slice(-padding)
116
- + '.' + options.format);
117
- var out = view.exportImage(file, function() {
118
- // Once the file has been closed, export the next fame:
119
- var then = Date.now();
120
- if (options.onProgress) {
121
- options.onProgress({
122
- count: count,
123
- amount: options.amount,
124
- percentage: Math.round((count + 1) / options.amount
125
- * 10000) / 100,
126
- time: then - startTime,
127
- delta: then - lastTime
128
- });
129
- }
130
- lastTime = then;
131
- if (++count < options.amount) {
132
- exportFrame();
133
- } else {
134
- // Call onComplete handler when finished:
135
- if (options.onComplete) {
136
- options.onComplete();
137
- }
138
- }
139
- });
140
- }
141
- },
142
-
143
- // DOCS: CanvasView#exportImage(path, callback);
144
- exportImage: function(path, callback) {
145
- this.update();
146
- var out = fs.createWriteStream(path),
147
- format = /\.jp(e?)g$/.test(path) ? 'jpeg' : 'png',
148
- stream = this._element[format + 'Stream']();
149
- stream.pipe(out);
150
- if (callback) {
151
- out.on('close', callback);
152
- }
153
- return out;
154
- }
155
- });
156
- };
@@ -1,58 +0,0 @@
1
- /*
2
- * Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
3
- * http://paperjs.org/
4
- *
5
- * Copyright (c) 2011 - 2020, Jürg Lehni & Jonathan Puckey
6
- * http://juerglehni.com/ & https://puckey.studio/
7
- *
8
- * Distributed under the MIT license. See LICENSE file for details.
9
- *
10
- * All rights reserved.
11
- */
12
-
13
- // Node.js emulation layer of browser environment, based on jsdom with node-
14
- // canvas integration.
15
-
16
- var path = require('path');
17
- // Determine the name by which name the module was required (either 'paper',
18
- // 'paper-jsdom' or 'paper-jsdom-canvas'), and use this to determine if error
19
- // exceptions should be thrown or if loading should fail silently.
20
- var parent = module.parent && module.parent.parent,
21
- requireName = parent && path.basename(path.dirname(parent.filename));
22
- requireName = /^paper/.test(requireName) ? requireName : 'paper';
23
-
24
- var jsdom,
25
- self;
26
-
27
- try {
28
- jsdom = require('jsdom');
29
- } catch(e) {
30
- // Check the required module's name to see if it contains jsdom, and only
31
- // complain about its lack if the module requires it.
32
- if (/\bjsdom\b/.test(requireName)) {
33
- throw new Error('Unable to load jsdom module.');
34
- }
35
- }
36
-
37
- if (jsdom) {
38
- // Create our document and window objects through jsdom.
39
- /* global document:true, window:true */
40
- var document = new jsdom.JSDOM('<html><body></body></html>', {
41
- // Use the current working directory as the document's origin, so
42
- // requests to local files work correctly with CORS.
43
- url: 'file://' + process.cwd() + '/',
44
- resources: 'usable'
45
- });
46
- self = document.window;
47
- require('./canvas.js')(self, requireName);
48
- require('./xml.js')(self);
49
- } else {
50
- self = {
51
- navigator: {
52
- userAgent: 'Node.js (' + process.platform + '; U; rv:' +
53
- process.version + ')'
54
- }
55
- };
56
- }
57
-
58
- module.exports = self;
@@ -1,40 +0,0 @@
1
- /*
2
- * Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
3
- * http://paperjs.org/
4
- *
5
- * Copyright (c) 2011 - 2020, Jürg Lehni & Jonathan Puckey
6
- * http://juerglehni.com/ & https://puckey.studio/
7
- *
8
- * Distributed under the MIT license. See LICENSE file for details.
9
- *
10
- * All rights reserved.
11
- */
12
-
13
- module.exports = function(self) {
14
- // Define XMLSerializer shim, to emulate browser behavior.
15
- // Effort to bring XMLSerializer to jsdom:
16
- // https://github.com/tmpvar/jsdom/issues/1368
17
- self.XMLSerializer = function XMLSerializer() {
18
- };
19
-
20
- self.XMLSerializer.prototype = {
21
- serializeToString: function(node) {
22
- if (!node)
23
- return '';
24
- // Fix a jsdom issue where all SVG tagNames are lowercased:
25
- // https://github.com/tmpvar/jsdom/issues/620
26
- var text = node.outerHTML,
27
- tagNames = ['linearGradient', 'radialGradient', 'clipPath',
28
- 'textPath'];
29
- for (var i = 0, l = tagNames.length; i < l; i++) {
30
- var tagName = tagNames[i];
31
- text = text.replace(
32
- new RegExp('(<|</)' + tagName.toLowerCase() + '\\b', 'g'),
33
- function(match, start) {
34
- return start + tagName;
35
- });
36
- }
37
- return text;
38
- }
39
- };
40
- };
@@ -1 +0,0 @@
1
- import './paper';