paper 0.12.17 → 0.12.18
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 +12 -1
- package/dist/docs/assets/js/paper.js +19 -11
- package/dist/docs/classes/Color.html +2 -2
- package/dist/docs/classes/CompoundPath.html +3 -4
- package/dist/docs/classes/Curve.html +2 -2
- package/dist/docs/classes/CurveLocation.html +2 -2
- package/dist/docs/classes/Event.html +2 -2
- package/dist/docs/classes/Gradient.html +2 -2
- package/dist/docs/classes/GradientStop.html +2 -2
- package/dist/docs/classes/Group.html +3 -4
- package/dist/docs/classes/HitResult.html +2 -2
- package/dist/docs/classes/Item.html +3 -4
- package/dist/docs/classes/Key.html +2 -2
- package/dist/docs/classes/KeyEvent.html +2 -2
- package/dist/docs/classes/Layer.html +3 -4
- package/dist/docs/classes/Matrix.html +2 -2
- package/dist/docs/classes/MouseEvent.html +2 -2
- package/dist/docs/classes/PaperScope.html +2 -2
- package/dist/docs/classes/PaperScript.html +2 -2
- package/dist/docs/classes/Path.html +3 -4
- package/dist/docs/classes/PathItem.html +3 -4
- package/dist/docs/classes/Point.html +2 -2
- package/dist/docs/classes/PointText.html +3 -4
- package/dist/docs/classes/Project.html +3 -2
- package/dist/docs/classes/Raster.html +3 -4
- package/dist/docs/classes/Rectangle.html +2 -2
- package/dist/docs/classes/Segment.html +2 -2
- package/dist/docs/classes/Shape.html +3 -4
- package/dist/docs/classes/Size.html +2 -2
- package/dist/docs/classes/Style.html +2 -2
- package/dist/docs/classes/SymbolDefinition.html +2 -2
- package/dist/docs/classes/SymbolItem.html +3 -4
- package/dist/docs/classes/TextItem.html +3 -4
- package/dist/docs/classes/Tool.html +2 -2
- package/dist/docs/classes/ToolEvent.html +2 -2
- package/dist/docs/classes/Tween.html +2 -2
- package/dist/docs/classes/View.html +3 -3
- package/dist/docs/classes/global.html +2 -2
- package/dist/docs/classes/index.html +2 -2
- package/dist/docs/index.html +1 -1
- package/dist/paper-core.js +19 -11
- package/dist/paper-core.min.js +3 -3
- package/dist/paper-full.js +19 -11
- package/dist/paper-full.min.js +3 -3
- package/dist/paper.d.ts +10 -4
- package/dist/paperjs/LICENSE.txt +23 -0
- package/dist/paperjs/dist/node/canvas.js +66 -0
- package/dist/paperjs/dist/node/extend.js +156 -0
- package/dist/paperjs/dist/node/self.js +58 -0
- package/dist/paperjs/dist/node/xml.js +40 -0
- package/dist/paperjs/dist/paper-core.d.ts +1 -0
- package/dist/paperjs/dist/paper-core.js +15703 -0
- package/dist/paperjs/dist/paper-core.min.js +32 -0
- package/dist/paperjs/dist/paper-full.js +17472 -0
- package/dist/paperjs/dist/paper-full.min.js +32 -0
- package/dist/paperjs/dist/paper.d.ts +7394 -0
- package/dist/paperjs/docs/assets/css/docs.css +414 -0
- package/dist/paperjs/docs/assets/js/codemirror.js +4 -0
- package/dist/paperjs/docs/assets/js/docs.js +493 -0
- package/dist/paperjs/docs/assets/js/jquery.js +6 -0
- package/dist/paperjs/docs/assets/js/paper.js +17472 -0
- package/dist/paperjs/docs/classes/Color.html +2188 -0
- package/dist/paperjs/docs/classes/CompoundPath.html +8877 -0
- package/dist/paperjs/docs/classes/Curve.html +2323 -0
- package/dist/paperjs/docs/classes/CurveLocation.html +672 -0
- package/dist/paperjs/docs/classes/Event.html +176 -0
- package/dist/paperjs/docs/classes/Gradient.html +240 -0
- package/dist/paperjs/docs/classes/GradientStop.html +273 -0
- package/dist/paperjs/docs/classes/Group.html +6864 -0
- package/dist/paperjs/docs/classes/HitResult.html +239 -0
- package/dist/paperjs/docs/classes/Item.html +6628 -0
- package/dist/paperjs/docs/classes/Key.html +139 -0
- package/dist/paperjs/docs/classes/KeyEvent.html +308 -0
- package/dist/paperjs/docs/classes/Layer.html +6850 -0
- package/dist/paperjs/docs/classes/Matrix.html +1744 -0
- package/dist/paperjs/docs/classes/MouseEvent.html +355 -0
- package/dist/paperjs/docs/classes/PaperScope.html +459 -0
- package/dist/paperjs/docs/classes/PaperScript.html +198 -0
- package/dist/paperjs/docs/classes/Path.html +11775 -0
- package/dist/paperjs/docs/classes/PathItem.html +8639 -0
- package/dist/paperjs/docs/classes/Point.html +2699 -0
- package/dist/paperjs/docs/classes/PointText.html +7029 -0
- package/dist/paperjs/docs/classes/Project.html +1305 -0
- package/dist/paperjs/docs/classes/Raster.html +7843 -0
- package/dist/paperjs/docs/classes/Rectangle.html +1654 -0
- package/dist/paperjs/docs/classes/Segment.html +939 -0
- package/dist/paperjs/docs/classes/Shape.html +7363 -0
- package/dist/paperjs/docs/classes/Size.html +1825 -0
- package/dist/paperjs/docs/classes/Style.html +919 -0
- package/dist/paperjs/docs/classes/SymbolDefinition.html +311 -0
- package/dist/paperjs/docs/classes/SymbolItem.html +6755 -0
- package/dist/paperjs/docs/classes/TextItem.html +6869 -0
- package/dist/paperjs/docs/classes/Tool.html +761 -0
- package/dist/paperjs/docs/classes/ToolEvent.html +446 -0
- package/dist/paperjs/docs/classes/Tween.html +374 -0
- package/dist/paperjs/docs/classes/View.html +1772 -0
- package/dist/paperjs/docs/classes/global.html +425 -0
- package/dist/paperjs/docs/classes/index.html +88 -0
- package/dist/paperjs/docs/index.html +11 -0
- package/dist/paperjs/examples/Animated/AnimatedStar.html +53 -0
- package/dist/paperjs/examples/Animated/BooleanOperations.html +115 -0
- package/dist/paperjs/examples/Animated/CandyCrash.html +151 -0
- package/dist/paperjs/examples/Animated/Extruded.html +50 -0
- package/dist/paperjs/examples/Animated/Lines.html +53 -0
- package/dist/paperjs/examples/Animated/Smoothing.html +70 -0
- package/dist/paperjs/examples/Animated/Space.html +86 -0
- package/dist/paperjs/examples/Animated/SpaceUsingShapes.html +79 -0
- package/dist/paperjs/examples/Games/Paperoids.html +569 -0
- package/dist/paperjs/examples/JSON/Circle Testing.html +34 -0
- package/dist/paperjs/examples/JSON/Compound Path.html +25 -0
- package/dist/paperjs/examples/JSON/Empty Path Testing.html +31 -0
- package/dist/paperjs/examples/JSON/Gradients.html +34 -0
- package/dist/paperjs/examples/JSON/Group Transform.html +28 -0
- package/dist/paperjs/examples/JSON/Line Testing.html +44 -0
- package/dist/paperjs/examples/JSON/Random Path Testing.html +42 -0
- package/dist/paperjs/examples/JSON/Raster.html +29 -0
- package/dist/paperjs/examples/JSON/Rect and Attribute Testing.html +56 -0
- package/dist/paperjs/examples/JSON/Rotated Primitives.html +55 -0
- package/dist/paperjs/examples/JSON/Selection.html +43 -0
- package/dist/paperjs/examples/JSON/Shapes.html +54 -0
- package/dist/paperjs/examples/JSON/Symbols.html +30 -0
- package/dist/paperjs/examples/JSON/Text Testing.html +38 -0
- package/dist/paperjs/examples/JSON/Tiger.html +19 -0
- package/dist/paperjs/examples/JSON/Transform Test 1.html +32 -0
- package/dist/paperjs/examples/JSON/Transform Test 2.html +30 -0
- package/dist/paperjs/examples/Node.js/AnimatedStar.js +52 -0
- package/dist/paperjs/examples/Node.js/BooleanOperations.js +36 -0
- package/dist/paperjs/examples/Node.js/JSONtoPDF.js +20 -0
- package/dist/paperjs/examples/Node.js/Raster.js +32 -0
- package/dist/paperjs/examples/Node.js/RasterRemote.js +33 -0
- package/dist/paperjs/examples/Node.js/SvgExport.js +52 -0
- package/dist/paperjs/examples/Node.js/SvgImport.js +23 -0
- package/dist/paperjs/examples/Node.js/Tadpoles.js +16 -0
- package/dist/paperjs/examples/Node.js/Tadpoles.pjs +278 -0
- package/dist/paperjs/examples/Node.js/in.json +1 -0
- package/dist/paperjs/examples/Node.js/in.svg +16 -0
- package/dist/paperjs/examples/Paperjs.org/BooleanOperattions.html +115 -0
- package/dist/paperjs/examples/Paperjs.org/BouncingBalls.html +103 -0
- package/dist/paperjs/examples/Paperjs.org/Chain.html +54 -0
- package/dist/paperjs/examples/Paperjs.org/DivisionRaster.html +72 -0
- package/dist/paperjs/examples/Paperjs.org/FutureSplash.html +122 -0
- package/dist/paperjs/examples/Paperjs.org/HitTesting.html +103 -0
- package/dist/paperjs/examples/Paperjs.org/InteractiveTiger.html +777 -0
- package/dist/paperjs/examples/Paperjs.org/MetaBalls.html +132 -0
- package/dist/paperjs/examples/Paperjs.org/NyanRainbow.html +202 -0
- package/dist/paperjs/examples/Paperjs.org/PathIntersections.html +76 -0
- package/dist/paperjs/examples/Paperjs.org/Qbertify.html +146 -0
- package/dist/paperjs/examples/Paperjs.org/RadialRainbows.html +80 -0
- package/dist/paperjs/examples/Paperjs.org/RoundedRectangles.html +41 -0
- package/dist/paperjs/examples/Paperjs.org/SatieLikedToDraw.html +140 -0
- package/dist/paperjs/examples/Paperjs.org/Simplify.html +63 -0
- package/dist/paperjs/examples/Paperjs.org/SpiralRaster.html +120 -0
- package/dist/paperjs/examples/Paperjs.org/Tadpoles.html +283 -0
- package/dist/paperjs/examples/Paperjs.org/Voronoi.html +134 -0
- package/dist/paperjs/examples/Rasters/PhyllotaxisRaster.html +96 -0
- package/dist/paperjs/examples/Rasters/Raster.html +34 -0
- package/dist/paperjs/examples/Rasters/RotationRaster.html +44 -0
- package/dist/paperjs/examples/Rasters/Smoothing.html +36 -0
- package/dist/paperjs/examples/SVG Export/Circle Testing.html +32 -0
- package/dist/paperjs/examples/SVG Export/Clipping.html +17 -0
- package/dist/paperjs/examples/SVG Export/Compound Path.html +22 -0
- package/dist/paperjs/examples/SVG Export/Empty Path Testing.html +28 -0
- package/dist/paperjs/examples/SVG Export/Gradients.html +52 -0
- package/dist/paperjs/examples/SVG Export/Group Transform.html +25 -0
- package/dist/paperjs/examples/SVG Export/Line Testing.html +41 -0
- package/dist/paperjs/examples/SVG Export/Random Path Testing.html +39 -0
- package/dist/paperjs/examples/SVG Export/Raster.html +21 -0
- package/dist/paperjs/examples/SVG Export/Rect and Attribute Testing.html +53 -0
- package/dist/paperjs/examples/SVG Export/Rotated Primitives.html +80 -0
- package/dist/paperjs/examples/SVG Export/Shapes.html +58 -0
- package/dist/paperjs/examples/SVG Export/Symbols.html +27 -0
- package/dist/paperjs/examples/SVG Export/Text Testing.html +45 -0
- package/dist/paperjs/examples/SVG Export/Tiger.html +23 -0
- package/dist/paperjs/examples/SVG Export/Transform Test 1.html +29 -0
- package/dist/paperjs/examples/SVG Export/Transform Test 2.html +27 -0
- package/dist/paperjs/examples/SVG Import/Arcs.html +78 -0
- package/dist/paperjs/examples/SVG Import/Butterfly.html +223 -0
- package/dist/paperjs/examples/SVG Import/Circle and Ellipse Testing.html +26 -0
- package/dist/paperjs/examples/SVG Import/Clipping.html +100 -0
- package/dist/paperjs/examples/SVG Import/From File.html +30 -0
- package/dist/paperjs/examples/SVG Import/Gradient.html +138 -0
- package/dist/paperjs/examples/SVG Import/Gradients.html +30 -0
- package/dist/paperjs/examples/SVG Import/Inkscape Pivot.html +52 -0
- package/dist/paperjs/examples/SVG Import/Inkscape.html +88 -0
- package/dist/paperjs/examples/SVG Import/Line Testing.html +24 -0
- package/dist/paperjs/examples/SVG Import/MoreGradients.html +107 -0
- package/dist/paperjs/examples/SVG Import/Multiple Paths Test 1.html +42 -0
- package/dist/paperjs/examples/SVG Import/Multiple Paths Test 2.html +33 -0
- package/dist/paperjs/examples/SVG Import/Nested Groups Test.html +78 -0
- package/dist/paperjs/examples/SVG Import/Polybezier.html +43 -0
- package/dist/paperjs/examples/SVG Import/Rect Testing.html +25 -0
- package/dist/paperjs/examples/SVG Import/Symbols.html +24 -0
- package/dist/paperjs/examples/SVG Import/Testing.html +40 -0
- package/dist/paperjs/examples/SVG Import/Text Testing.html +19 -0
- package/dist/paperjs/examples/SVG Import/Tiger.html +742 -0
- package/dist/paperjs/examples/SVG Import/Transform Testing.html +22 -0
- package/dist/paperjs/examples/SVG Import/Viewbox.html +38 -0
- package/dist/paperjs/examples/Scripts/Arcs.html +39 -0
- package/dist/paperjs/examples/Scripts/BlendModes.html +77 -0
- package/dist/paperjs/examples/Scripts/BooleanOperations.html +937 -0
- package/dist/paperjs/examples/Scripts/CompoundPath.html +19 -0
- package/dist/paperjs/examples/Scripts/CurveTimeParameterization.html +61 -0
- package/dist/paperjs/examples/Scripts/HslColor.html +53 -0
- package/dist/paperjs/examples/Scripts/PathStructure.html +82 -0
- package/dist/paperjs/examples/Scripts/PathTangents.html +73 -0
- package/dist/paperjs/examples/Scripts/Resize.html +42 -0
- package/dist/paperjs/examples/Scripts/RoundRectangle.html +28 -0
- package/dist/paperjs/examples/Scripts/Shapes.html +54 -0
- package/dist/paperjs/examples/Scripts/StrokeBounds.html +101 -0
- package/dist/paperjs/examples/Scripts/StrokeScaling.html +65 -0
- package/dist/paperjs/examples/Tools/BezierTool.html +90 -0
- package/dist/paperjs/examples/Tools/Circles.html +28 -0
- package/dist/paperjs/examples/Tools/Clouds.html +35 -0
- package/dist/paperjs/examples/Tools/DrippingBrush.html +73 -0
- package/dist/paperjs/examples/Tools/FancyBrush.html +82 -0
- package/dist/paperjs/examples/Tools/Grid.html +44 -0
- package/dist/paperjs/examples/Tools/MultiLines.html +44 -0
- package/dist/paperjs/examples/Tools/MultipleTools.html +44 -0
- package/dist/paperjs/examples/Tools/PathEditing.html +95 -0
- package/dist/paperjs/examples/Tools/SquareRounded.html +76 -0
- package/dist/paperjs/examples/Tools/Stars.html +38 -0
- package/dist/paperjs/examples/Tools/Vektor.html +200 -0
- package/dist/paperjs/examples/Tools/Wave.html +50 -0
- package/dist/paperjs/examples/Tools/WormFarm.html +88 -0
- package/dist/paperjs/examples/Worker/Main.html +53 -0
- package/dist/paperjs/examples/Worker/Worker.js +14 -0
- package/dist/paperjs/examples/css/style.css +12 -0
- package/package.json +4 -4
package/dist/paper.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Paper.js v0.12.
|
|
2
|
+
* Paper.js v0.12.18 - 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:
|
|
12
|
+
* Date: Wed Jul 17 14:57:24 2024 +0200
|
|
13
13
|
*
|
|
14
14
|
* This is an auto-generated type definition.
|
|
15
15
|
*/
|
|
@@ -1572,7 +1572,7 @@ declare namespace paper {
|
|
|
1572
1572
|
/**
|
|
1573
1573
|
* The index of this item within the list of its parent's children.
|
|
1574
1574
|
*/
|
|
1575
|
-
|
|
1575
|
+
index: number
|
|
1576
1576
|
|
|
1577
1577
|
/**
|
|
1578
1578
|
* The color of the stroke.
|
|
@@ -2054,6 +2054,9 @@ declare namespace paper {
|
|
|
2054
2054
|
* @option [options.embedImages=true] {Boolean} whether raster images should
|
|
2055
2055
|
* be embedded as base64 data inlined in the xlink:href attribute, or
|
|
2056
2056
|
* kept as a link to their external URL.
|
|
2057
|
+
* @option [options.reduceAttributes=true] {Boolean} wether to only include
|
|
2058
|
+
* style attributes in the SVG output that differ from their parents,
|
|
2059
|
+
* or to always include them (much faster but leading to redundancies).
|
|
2057
2060
|
*
|
|
2058
2061
|
* @param options - the export options
|
|
2059
2062
|
*
|
|
@@ -5236,6 +5239,9 @@ declare namespace paper {
|
|
|
5236
5239
|
* @option [options.embedImages=true] {Boolean} whether raster images should
|
|
5237
5240
|
* be embedded as base64 data inlined in the xlink:href attribute, or
|
|
5238
5241
|
* kept as a link to their external URL.
|
|
5242
|
+
* @option [options.reduceAttributes=true] {Boolean} wether to only include
|
|
5243
|
+
* style attributes in the SVG output that differ from their parents,
|
|
5244
|
+
* or to always include them (much faster but leading to redundancies).
|
|
5239
5245
|
*
|
|
5240
5246
|
* @param options - the export options
|
|
5241
5247
|
*
|
|
@@ -6972,7 +6978,7 @@ declare namespace paper {
|
|
|
6972
6978
|
readonly pixelRatio: number
|
|
6973
6979
|
|
|
6974
6980
|
/**
|
|
6975
|
-
* The
|
|
6981
|
+
* The resolution of the underlying canvas / device in pixel per inch (DPI).
|
|
6976
6982
|
* It is `72` for normal displays, and `144` for high-resolution
|
|
6977
6983
|
* displays with a pixel-ratio of `2`.
|
|
6978
6984
|
*/
|
|
@@ -0,0 +1,23 @@
|
|
|
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.
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,156 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
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;
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './paper';
|