@turbowarp/paper 0.12.202407161743
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/AUTHORS.md +18 -0
- package/CHANGELOG.md +701 -0
- package/LICENSE.txt +23 -0
- package/README.md +381 -0
- package/dist/node/canvas.js +66 -0
- package/dist/node/extend.js +156 -0
- package/dist/node/self.js +58 -0
- package/dist/node/xml.js +40 -0
- package/dist/paper-core.js +15805 -0
- package/dist/paper-full.js +17574 -0
- package/examples/Animated/AnimatedStar.html +53 -0
- package/examples/Animated/BooleanOperations.html +115 -0
- package/examples/Animated/CandyCrash.html +151 -0
- package/examples/Animated/Extruded.html +50 -0
- package/examples/Animated/Lines.html +53 -0
- package/examples/Animated/Smoothing.html +70 -0
- package/examples/Animated/Space.html +86 -0
- package/examples/Animated/SpaceUsingShapes.html +79 -0
- package/examples/Games/Paperoids.html +569 -0
- package/examples/JSON/Circle Testing.html +34 -0
- package/examples/JSON/Compound Path.html +25 -0
- package/examples/JSON/Empty Path Testing.html +31 -0
- package/examples/JSON/Gradients.html +34 -0
- package/examples/JSON/Group Transform.html +28 -0
- package/examples/JSON/Line Testing.html +44 -0
- package/examples/JSON/Random Path Testing.html +42 -0
- package/examples/JSON/Raster.html +29 -0
- package/examples/JSON/Rect and Attribute Testing.html +56 -0
- package/examples/JSON/Rotated Primitives.html +55 -0
- package/examples/JSON/Selection.html +43 -0
- package/examples/JSON/Shapes.html +54 -0
- package/examples/JSON/Symbols.html +30 -0
- package/examples/JSON/Text Testing.html +38 -0
- package/examples/JSON/Tiger.html +19 -0
- package/examples/JSON/Transform Test 1.html +32 -0
- package/examples/JSON/Transform Test 2.html +30 -0
- package/examples/Node.js/AnimatedStar.js +52 -0
- package/examples/Node.js/BooleanOperations.js +36 -0
- package/examples/Node.js/JSONtoPDF.js +20 -0
- package/examples/Node.js/Raster.js +32 -0
- package/examples/Node.js/RasterRemote.js +33 -0
- package/examples/Node.js/SvgExport.js +52 -0
- package/examples/Node.js/SvgImport.js +23 -0
- package/examples/Node.js/Tadpoles.js +16 -0
- package/examples/Node.js/Tadpoles.pjs +278 -0
- package/examples/Node.js/in.json +1 -0
- package/examples/Node.js/in.svg +16 -0
- package/examples/Paperjs.org/BooleanOperattions.html +115 -0
- package/examples/Paperjs.org/BouncingBalls.html +103 -0
- package/examples/Paperjs.org/Chain.html +54 -0
- package/examples/Paperjs.org/DivisionRaster.html +72 -0
- package/examples/Paperjs.org/FutureSplash.html +122 -0
- package/examples/Paperjs.org/HitTesting.html +103 -0
- package/examples/Paperjs.org/InteractiveTiger.html +777 -0
- package/examples/Paperjs.org/MetaBalls.html +132 -0
- package/examples/Paperjs.org/NyanRainbow.html +202 -0
- package/examples/Paperjs.org/PathIntersections.html +76 -0
- package/examples/Paperjs.org/Qbertify.html +146 -0
- package/examples/Paperjs.org/RadialRainbows.html +80 -0
- package/examples/Paperjs.org/RoundedRectangles.html +41 -0
- package/examples/Paperjs.org/SatieLikedToDraw.html +140 -0
- package/examples/Paperjs.org/Simplify.html +63 -0
- package/examples/Paperjs.org/SpiralRaster.html +120 -0
- package/examples/Paperjs.org/Tadpoles.html +283 -0
- package/examples/Paperjs.org/Voronoi.html +134 -0
- package/examples/Rasters/PhyllotaxisRaster.html +96 -0
- package/examples/Rasters/Raster.html +34 -0
- package/examples/Rasters/RotationRaster.html +44 -0
- package/examples/Rasters/Smoothing.html +48 -0
- package/examples/SVG Export/Circle Testing.html +32 -0
- package/examples/SVG Export/Clipping.html +17 -0
- package/examples/SVG Export/Compound Path.html +22 -0
- package/examples/SVG Export/Empty Path Testing.html +28 -0
- package/examples/SVG Export/Gradients.html +52 -0
- package/examples/SVG Export/Group Transform.html +25 -0
- package/examples/SVG Export/Line Testing.html +41 -0
- package/examples/SVG Export/Random Path Testing.html +39 -0
- package/examples/SVG Export/Raster.html +21 -0
- package/examples/SVG Export/Rect and Attribute Testing.html +53 -0
- package/examples/SVG Export/Rotated Primitives.html +80 -0
- package/examples/SVG Export/Shapes.html +58 -0
- package/examples/SVG Export/Symbols.html +27 -0
- package/examples/SVG Export/Text Testing.html +45 -0
- package/examples/SVG Export/Tiger.html +23 -0
- package/examples/SVG Export/Transform Test 1.html +29 -0
- package/examples/SVG Export/Transform Test 2.html +27 -0
- package/examples/SVG Import/Arcs.html +78 -0
- package/examples/SVG Import/Butterfly.html +223 -0
- package/examples/SVG Import/Circle and Ellipse Testing.html +26 -0
- package/examples/SVG Import/Clipping.html +100 -0
- package/examples/SVG Import/From File.html +30 -0
- package/examples/SVG Import/Gradient.html +138 -0
- package/examples/SVG Import/Gradients.html +30 -0
- package/examples/SVG Import/Inkscape Pivot.html +52 -0
- package/examples/SVG Import/Inkscape.html +88 -0
- package/examples/SVG Import/Line Testing.html +24 -0
- package/examples/SVG Import/MoreGradients.html +107 -0
- package/examples/SVG Import/Multiple Paths Test 1.html +42 -0
- package/examples/SVG Import/Multiple Paths Test 2.html +33 -0
- package/examples/SVG Import/Nested Groups Test.html +78 -0
- package/examples/SVG Import/Polybezier.html +43 -0
- package/examples/SVG Import/Rect Testing.html +25 -0
- package/examples/SVG Import/Symbols.html +24 -0
- package/examples/SVG Import/Testing.html +40 -0
- package/examples/SVG Import/Text Testing.html +19 -0
- package/examples/SVG Import/Tiger.html +742 -0
- package/examples/SVG Import/Transform Testing.html +22 -0
- package/examples/SVG Import/Viewbox.html +38 -0
- package/examples/Scripts/Arcs.html +39 -0
- package/examples/Scripts/BlendModes.html +77 -0
- package/examples/Scripts/BooleanOperations.html +937 -0
- package/examples/Scripts/CompoundPath.html +19 -0
- package/examples/Scripts/CurveTimeParameterization.html +61 -0
- package/examples/Scripts/HslColor.html +53 -0
- package/examples/Scripts/PathStructure.html +82 -0
- package/examples/Scripts/PathTangents.html +73 -0
- package/examples/Scripts/Resize.html +42 -0
- package/examples/Scripts/RoundRectangle.html +28 -0
- package/examples/Scripts/Shapes.html +54 -0
- package/examples/Scripts/StrokeBounds.html +101 -0
- package/examples/Scripts/StrokeScaling.html +65 -0
- package/examples/Tools/BezierTool.html +90 -0
- package/examples/Tools/Circles.html +28 -0
- package/examples/Tools/Clouds.html +35 -0
- package/examples/Tools/DrippingBrush.html +73 -0
- package/examples/Tools/FancyBrush.html +82 -0
- package/examples/Tools/Grid.html +44 -0
- package/examples/Tools/MultiLines.html +44 -0
- package/examples/Tools/MultipleTools.html +44 -0
- package/examples/Tools/PathEditing.html +95 -0
- package/examples/Tools/SquareRounded.html +76 -0
- package/examples/Tools/Stars.html +38 -0
- package/examples/Tools/Vektor.html +200 -0
- package/examples/Tools/Wave.html +50 -0
- package/examples/Tools/WormFarm.html +88 -0
- package/examples/Worker/Main.html +53 -0
- package/examples/Worker/Worker.js +14 -0
- package/examples/css/style.css +12 -0
- package/package.json +109 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Vektor</title>
|
|
6
|
+
<link rel="stylesheet" href="../css/style.css">
|
|
7
|
+
<script type="text/javascript" src="../../dist/paper-full.js"></script>
|
|
8
|
+
<script type="text/paperscript" canvas="canvas">
|
|
9
|
+
|
|
10
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
11
|
+
// Interface
|
|
12
|
+
|
|
13
|
+
var values = {
|
|
14
|
+
fixLength: false,
|
|
15
|
+
fixAngle: false,
|
|
16
|
+
showCircle: false,
|
|
17
|
+
showAngleLength: true,
|
|
18
|
+
showCoordinates: false
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
22
|
+
// Vector
|
|
23
|
+
|
|
24
|
+
var vectorStart, vector, vectorPrevious;
|
|
25
|
+
var vectorItem, items, dashedItems;
|
|
26
|
+
|
|
27
|
+
function processVector(event, drag) {
|
|
28
|
+
vector = event.point - vectorStart;
|
|
29
|
+
if (vectorPrevious) {
|
|
30
|
+
if (values.fixLength && values.fixAngle) {
|
|
31
|
+
vector = vectorPrevious;
|
|
32
|
+
} else if (values.fixLength) {
|
|
33
|
+
vector.length = vectorPrevious.length;
|
|
34
|
+
} else if (values.fixAngle) {
|
|
35
|
+
vector = vector.project(vectorPrevious);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
drawVector(drag);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function drawVector(drag) {
|
|
42
|
+
if (items) {
|
|
43
|
+
for (var i = 0, l = items.length; i < l; i++) {
|
|
44
|
+
items[i].remove();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (vectorItem)
|
|
48
|
+
vectorItem.remove();
|
|
49
|
+
items = [];
|
|
50
|
+
var arrowVector = vector.normalize(10);
|
|
51
|
+
var end = vectorStart + vector;
|
|
52
|
+
vectorItem = new Group(
|
|
53
|
+
new Path(vectorStart, end),
|
|
54
|
+
new Path(
|
|
55
|
+
end + arrowVector.rotate(135),
|
|
56
|
+
end,
|
|
57
|
+
end + arrowVector.rotate(-135)
|
|
58
|
+
)
|
|
59
|
+
);
|
|
60
|
+
vectorItem.strokeWidth = 0.75;
|
|
61
|
+
vectorItem.strokeColor = '#e4141b';
|
|
62
|
+
// Display:
|
|
63
|
+
dashedItems = [];
|
|
64
|
+
// Draw Circle
|
|
65
|
+
if (values.showCircle) {
|
|
66
|
+
dashedItems.push(new Path.Circle(vectorStart, vector.length));
|
|
67
|
+
}
|
|
68
|
+
// Draw Labels
|
|
69
|
+
if (values.showAngleLength) {
|
|
70
|
+
drawAngle(vectorStart, vector, !drag);
|
|
71
|
+
if (!drag)
|
|
72
|
+
drawLength(vectorStart, end, vector.angle < 0 ? -1 : 1, true);
|
|
73
|
+
}
|
|
74
|
+
var quadrant = vector.quadrant;
|
|
75
|
+
if (values.showCoordinates && !drag) {
|
|
76
|
+
drawLength(vectorStart, vectorStart + [vector.x, 0],
|
|
77
|
+
[1, 3].indexOf(quadrant) != -1 ? -1 : 1, true, vector.x, 'x: ');
|
|
78
|
+
drawLength(vectorStart, vectorStart + [0, vector.y],
|
|
79
|
+
[1, 3].indexOf(quadrant) != -1 ? 1 : -1, true, vector.y, 'y: ');
|
|
80
|
+
}
|
|
81
|
+
for (var i = 0, l = dashedItems.length; i < l; i++) {
|
|
82
|
+
var item = dashedItems[i];
|
|
83
|
+
item.strokeColor = 'black';
|
|
84
|
+
item.dashArray = [1, 2];
|
|
85
|
+
items.push(item);
|
|
86
|
+
}
|
|
87
|
+
// Update palette
|
|
88
|
+
values.x = vector.x;
|
|
89
|
+
values.y = vector.y;
|
|
90
|
+
values.length = vector.length;
|
|
91
|
+
values.angle = vector.angle;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function drawAngle(center, vector, label) {
|
|
95
|
+
var radius = 25, threshold = 10;
|
|
96
|
+
if (vector.length < radius + threshold || Math.abs(vector.angle) < 15)
|
|
97
|
+
return;
|
|
98
|
+
var from = new Point(radius, 0);
|
|
99
|
+
var through = from.rotate(vector.angle / 2);
|
|
100
|
+
var to = from.rotate(vector.angle);
|
|
101
|
+
var end = center + to;
|
|
102
|
+
dashedItems.push(new Path.Line(center,
|
|
103
|
+
center + new Point(radius + threshold, 0)));
|
|
104
|
+
dashedItems.push(new Path.Arc(center + from, center + through, end));
|
|
105
|
+
var arrowVector = to.normalize(7.5).rotate(vector.angle < 0 ? -90 : 90);
|
|
106
|
+
dashedItems.push(new Path([
|
|
107
|
+
end + arrowVector.rotate(135),
|
|
108
|
+
end,
|
|
109
|
+
end + arrowVector.rotate(-135)
|
|
110
|
+
]));
|
|
111
|
+
if (label) {
|
|
112
|
+
// Angle Label
|
|
113
|
+
var text = new PointText(center
|
|
114
|
+
+ through.normalize(radius + 10) + new Point(0, 3));
|
|
115
|
+
text.content = Math.floor(vector.angle * 100) / 100 + '\xb0';
|
|
116
|
+
items.push(text);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function drawLength(from, to, sign, label, value, prefix) {
|
|
121
|
+
var lengthSize = 5;
|
|
122
|
+
if ((to - from).length < lengthSize * 4)
|
|
123
|
+
return;
|
|
124
|
+
var vector = to - from;
|
|
125
|
+
var awayVector = vector.normalize(lengthSize).rotate(90 * sign);
|
|
126
|
+
var upVector = vector.normalize(lengthSize).rotate(45 * sign);
|
|
127
|
+
var downVector = upVector.rotate(-90 * sign);
|
|
128
|
+
var lengthVector = vector.normalize(
|
|
129
|
+
vector.length / 2 - lengthSize * Math.SQRT2);
|
|
130
|
+
var line = new Path();
|
|
131
|
+
line.add(from + awayVector);
|
|
132
|
+
line.lineBy(upVector);
|
|
133
|
+
line.lineBy(lengthVector);
|
|
134
|
+
line.lineBy(upVector);
|
|
135
|
+
var middle = line.lastSegment.point;
|
|
136
|
+
line.lineBy(downVector);
|
|
137
|
+
line.lineBy(lengthVector);
|
|
138
|
+
line.lineBy(downVector);
|
|
139
|
+
dashedItems.push(line);
|
|
140
|
+
if (label) {
|
|
141
|
+
// Length Label
|
|
142
|
+
var textAngle = Math.abs(vector.angle) > 90
|
|
143
|
+
? textAngle = 180 + vector.angle : vector.angle;
|
|
144
|
+
// Label needs to move away by different amounts based on the
|
|
145
|
+
// vector's quadrant:
|
|
146
|
+
var away = (sign >= 0 ? [1, 4] : [2, 3]).indexOf(vector.quadrant) != -1
|
|
147
|
+
? 8 : 0;
|
|
148
|
+
var text = new PointText(middle + awayVector.normalize(away + lengthSize));
|
|
149
|
+
text.rotate(textAngle);
|
|
150
|
+
text.justification = 'center';
|
|
151
|
+
value = value || vector.length;
|
|
152
|
+
text.content = (prefix || '') + Math.floor(value * 1000) / 1000;
|
|
153
|
+
items.push(text);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
158
|
+
// Mouse Handling
|
|
159
|
+
|
|
160
|
+
var dashItem;
|
|
161
|
+
|
|
162
|
+
function onMouseDown(event) {
|
|
163
|
+
var end = vectorStart + vector;
|
|
164
|
+
var create = false;
|
|
165
|
+
if (event.modifiers.shift && vectorItem) {
|
|
166
|
+
vectorStart = end;
|
|
167
|
+
create = true;
|
|
168
|
+
} else if (vector && (event.modifiers.option
|
|
169
|
+
|| end && end.getDistance(event.point) < 10)) {
|
|
170
|
+
create = false;
|
|
171
|
+
} else {
|
|
172
|
+
vectorStart = event.point;
|
|
173
|
+
}
|
|
174
|
+
if (create) {
|
|
175
|
+
dashItem = vectorItem;
|
|
176
|
+
vectorItem = null;
|
|
177
|
+
}
|
|
178
|
+
processVector(event, true);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function onMouseDrag(event) {
|
|
182
|
+
if (!event.modifiers.shift && values.fixLength && values.fixAngle)
|
|
183
|
+
vectorStart = event.point;
|
|
184
|
+
processVector(event, event.modifiers.shift);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function onMouseUp(event) {
|
|
188
|
+
processVector(event, false);
|
|
189
|
+
if (dashItem) {
|
|
190
|
+
dashItem.dashArray = [1, 2];
|
|
191
|
+
dashItem = null;
|
|
192
|
+
}
|
|
193
|
+
vectorPrevious = vector;
|
|
194
|
+
}
|
|
195
|
+
</script>
|
|
196
|
+
</head>
|
|
197
|
+
<body>
|
|
198
|
+
<canvas id="canvas" resize></canvas>
|
|
199
|
+
</body>
|
|
200
|
+
</html>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Wave</title>
|
|
6
|
+
<link rel="stylesheet" href="../css/style.css">
|
|
7
|
+
<script type="text/javascript" src="../../dist/paper-full.js"></script>
|
|
8
|
+
<script type="text/paperscript" canvas="canvas">
|
|
9
|
+
//////////////////////////////////////////////////////////////////////
|
|
10
|
+
// Values
|
|
11
|
+
|
|
12
|
+
tool.minDistance = 10;
|
|
13
|
+
|
|
14
|
+
var values = {
|
|
15
|
+
curviness: 0.5,
|
|
16
|
+
distance: tool.minDistance,
|
|
17
|
+
offset: 10,
|
|
18
|
+
mouseOffset: true
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
//////////////////////////////////////////////////////////////////////
|
|
22
|
+
// Mouse handling
|
|
23
|
+
|
|
24
|
+
var path;
|
|
25
|
+
function onMouseDown(event) {
|
|
26
|
+
path = new Path({
|
|
27
|
+
strokeColor: '#000000'
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
var mul = 1;
|
|
32
|
+
function onMouseDrag(event) {
|
|
33
|
+
var step = event.delta.rotate(90 * mul);
|
|
34
|
+
|
|
35
|
+
if (!values.mouseOffset)
|
|
36
|
+
step.length = values.offset;
|
|
37
|
+
|
|
38
|
+
path.add({
|
|
39
|
+
point: event.point + step,
|
|
40
|
+
handleIn: -event.delta * values.curviness,
|
|
41
|
+
handleOut: event.delta * values.curviness
|
|
42
|
+
});
|
|
43
|
+
mul *= -1;
|
|
44
|
+
}
|
|
45
|
+
</script>
|
|
46
|
+
</head>
|
|
47
|
+
<body>
|
|
48
|
+
<canvas id="canvas" resize></canvas>
|
|
49
|
+
</body>
|
|
50
|
+
</html>
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Worm Farm</title>
|
|
6
|
+
<link rel="stylesheet" href="../css/style.css">
|
|
7
|
+
<script type="text/javascript" src="../../dist/paper-full.js"></script>
|
|
8
|
+
<script type="text/paperscript" canvas="canvas">
|
|
9
|
+
/////////////////////////////////////////////////////////////////////
|
|
10
|
+
// Values
|
|
11
|
+
|
|
12
|
+
var values = {
|
|
13
|
+
minDistance: 10,
|
|
14
|
+
maxDistance: 30,
|
|
15
|
+
varyThickness: true
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// All newly created items will inherit the following styles:
|
|
19
|
+
project.currentStyle = {
|
|
20
|
+
fillColor: 'white',
|
|
21
|
+
strokeColor: 'black'
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/////////////////////////////////////////////////////////////////////
|
|
25
|
+
// Mouse handling
|
|
26
|
+
|
|
27
|
+
tool.minDistance = values.minDistance;
|
|
28
|
+
tool.maxDistance = values.maxDistance;
|
|
29
|
+
|
|
30
|
+
var worm;
|
|
31
|
+
|
|
32
|
+
// Every time the user clicks the mouse to drag we create a path
|
|
33
|
+
// and when a user drags the mouse we add points to it
|
|
34
|
+
function onMouseDown(event) {
|
|
35
|
+
worm = new Path();
|
|
36
|
+
worm.add(event.point, event.point);
|
|
37
|
+
worm.closed = true;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function onMouseDrag(event) {
|
|
41
|
+
// the vector in the direction that the mouse moved
|
|
42
|
+
var step = event.delta;
|
|
43
|
+
|
|
44
|
+
// if the vary thickness checkbox is marked
|
|
45
|
+
// divide the length of the step vector by two:
|
|
46
|
+
if (values.varyThickness) {
|
|
47
|
+
step.length = step.length / 2;
|
|
48
|
+
} else {
|
|
49
|
+
// otherwise set the length of the step vector to half of
|
|
50
|
+
// minDistance
|
|
51
|
+
step.length = values.minDistance / 2;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// the top point: the middle point + the step rotated by -90
|
|
55
|
+
// degrees
|
|
56
|
+
// -----*
|
|
57
|
+
// |
|
|
58
|
+
// ------
|
|
59
|
+
var top = event.middlePoint + step.rotate(-90);
|
|
60
|
+
|
|
61
|
+
// the bottom point: the middle point + the step rotated by 90
|
|
62
|
+
// degrees
|
|
63
|
+
// ------
|
|
64
|
+
// |
|
|
65
|
+
// -----*
|
|
66
|
+
var bottom = event.middlePoint + step.rotate(90);
|
|
67
|
+
|
|
68
|
+
// add the top point to the end of the path
|
|
69
|
+
worm.add(top);
|
|
70
|
+
|
|
71
|
+
// insert the bottom point after the first segment of the path
|
|
72
|
+
worm.insert(1, bottom);
|
|
73
|
+
|
|
74
|
+
// make a new line path from top to bottom
|
|
75
|
+
new Path(top, bottom);
|
|
76
|
+
|
|
77
|
+
// This is the point at the front of the worm:
|
|
78
|
+
worm.firstSegment.point = event.point;
|
|
79
|
+
|
|
80
|
+
// smooth the segments of the path
|
|
81
|
+
worm.smooth();
|
|
82
|
+
}
|
|
83
|
+
</script>
|
|
84
|
+
</head>
|
|
85
|
+
<body>
|
|
86
|
+
<canvas id="canvas" resize></canvas>
|
|
87
|
+
</body>
|
|
88
|
+
</html>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Shapes</title>
|
|
6
|
+
<link rel="stylesheet" href="../css/style.css">
|
|
7
|
+
<script type="text/javascript" src="../../dist/paper-full.js"></script>
|
|
8
|
+
<script type="text/paperscript" canvas="canvas">
|
|
9
|
+
if (window.Worker) { // Check if Browser supports the Worker API.
|
|
10
|
+
var worker = new Worker("Worker.js");
|
|
11
|
+
|
|
12
|
+
// Create two paths, and send them to the worker to perform a boolean
|
|
13
|
+
// operation on them.
|
|
14
|
+
|
|
15
|
+
var circle = new Path.Circle({
|
|
16
|
+
center: [200, 200],
|
|
17
|
+
radius: 100,
|
|
18
|
+
fillColor: 'red'
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
var rectangle = new Path.Rectangle({
|
|
22
|
+
point: [200, 200],
|
|
23
|
+
size: [200, 200],
|
|
24
|
+
fillColor: 'blue'
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
var data = [
|
|
28
|
+
circle.exportJSON(),
|
|
29
|
+
rectangle.exportJSON()
|
|
30
|
+
];
|
|
31
|
+
console.log('Sent', data);
|
|
32
|
+
worker.postMessage(data);
|
|
33
|
+
|
|
34
|
+
// The worker sends the result back in a message, from which we can then
|
|
35
|
+
// create a new path item and siplay it.
|
|
36
|
+
worker.onmessage = function(event) {
|
|
37
|
+
var data = event.data;
|
|
38
|
+
if (data) {
|
|
39
|
+
console.log('Received', data);
|
|
40
|
+
var result = project.activeLayer.importJSON(data);
|
|
41
|
+
result.fillColor = 'yellow';
|
|
42
|
+
result.fillColor.alpha = 0.5;
|
|
43
|
+
result.position += [400, 0];
|
|
44
|
+
result.fullySelected = true;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
</script>
|
|
49
|
+
</head>
|
|
50
|
+
<body>
|
|
51
|
+
<canvas id="canvas" resize></canvas>
|
|
52
|
+
</body>
|
|
53
|
+
</html>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
importScripts('../../dist/paper-full.js');
|
|
2
|
+
paper.install(this);
|
|
3
|
+
paper.setup([640, 480]);
|
|
4
|
+
|
|
5
|
+
onmessage = function(event) {
|
|
6
|
+
var data = event.data;
|
|
7
|
+
if (data) {
|
|
8
|
+
var path1 = project.importJSON(data[0]);
|
|
9
|
+
var path2 = project.importJSON(data[1]);
|
|
10
|
+
console.log(path1, path2);
|
|
11
|
+
var result = path1.unite(path2);
|
|
12
|
+
postMessage(result.exportJSON());
|
|
13
|
+
}
|
|
14
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@turbowarp/paper",
|
|
3
|
+
"version": "0.12.202407161743",
|
|
4
|
+
"description": "The Swiss Army Knife of Vector Graphics Scripting",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "http://paperjs.org",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/scratchfoundation/paper.js"
|
|
10
|
+
},
|
|
11
|
+
"bugs": "https://github.com/scratchfoundation/paper.js/issues",
|
|
12
|
+
"contributors": [
|
|
13
|
+
"Jürg Lehni <juerg@scratchdisk.com> (http://scratchdisk.com)",
|
|
14
|
+
"Jonathan Puckey <jonathan@puckey.studio> (http://studiomoniker.com)"
|
|
15
|
+
],
|
|
16
|
+
"main": "dist/paper-full.js",
|
|
17
|
+
"types": "dist/paper.d.ts",
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "gulp build",
|
|
20
|
+
"dist": "gulp dist",
|
|
21
|
+
"zip": "gulp zip",
|
|
22
|
+
"docs": "gulp docs",
|
|
23
|
+
"load": "gulp load",
|
|
24
|
+
"jshint": "gulp jshint",
|
|
25
|
+
"test": "gulp test"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"AUTHORS.md",
|
|
29
|
+
"CHANGELOG.md",
|
|
30
|
+
"dist/",
|
|
31
|
+
"examples/",
|
|
32
|
+
"LICENSE.txt",
|
|
33
|
+
"README.md"
|
|
34
|
+
],
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=8.0.0"
|
|
37
|
+
},
|
|
38
|
+
"husky": {
|
|
39
|
+
"hooks": {
|
|
40
|
+
"pre-commit": "gulp jshint --ensure-branch develop",
|
|
41
|
+
"pre-push": "gulp test --ensure-branch develop"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"overrides": {
|
|
45
|
+
"graceful-fs": "^4.2.11"
|
|
46
|
+
},
|
|
47
|
+
"browser": {
|
|
48
|
+
"canvas": false,
|
|
49
|
+
"jsdom": false,
|
|
50
|
+
"jsdom/lib/jsdom/living/generated/utils": false,
|
|
51
|
+
"source-map-support": false,
|
|
52
|
+
"./dist/node/self.js": false,
|
|
53
|
+
"./dist/node/extend.js": false
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"acorn": "0.5.0",
|
|
57
|
+
"canvas": "2.11.2",
|
|
58
|
+
"del": "4.1.1",
|
|
59
|
+
"gulp": "3.9.1",
|
|
60
|
+
"gulp-cached": "1.1.1",
|
|
61
|
+
"gulp-git-streamed": "2.10.1",
|
|
62
|
+
"gulp-jshint": "2.1.0",
|
|
63
|
+
"gulp-json-editor": "2.6.0",
|
|
64
|
+
"gulp-prepro": "2.4.0",
|
|
65
|
+
"gulp-qunits": "2.1.2",
|
|
66
|
+
"gulp-rename": "1.4.0",
|
|
67
|
+
"gulp-shell": "0.8.0",
|
|
68
|
+
"gulp-symlink": "2.1.4",
|
|
69
|
+
"gulp-typescript": "5.0.1",
|
|
70
|
+
"gulp-uglify": "1.5.4",
|
|
71
|
+
"gulp-uncomment": "0.3.0",
|
|
72
|
+
"gulp-util": "3.0.8",
|
|
73
|
+
"gulp-webserver": "0.9.1",
|
|
74
|
+
"gulp-whitespace": "0.1.0",
|
|
75
|
+
"gulp-zip": "3.2.0",
|
|
76
|
+
"jsdom": "15.2.1",
|
|
77
|
+
"jshint": "2.13.6",
|
|
78
|
+
"jshint-summary": "0.4.0",
|
|
79
|
+
"merge-stream": "2.0.0",
|
|
80
|
+
"minimist": "1.2.8",
|
|
81
|
+
"mustache": "3.2.1",
|
|
82
|
+
"prepro": "2.4.0",
|
|
83
|
+
"qunitjs": "1.23.1",
|
|
84
|
+
"require-dir": "1.2.0",
|
|
85
|
+
"resemblejs": "3.2.5",
|
|
86
|
+
"run-sequence": "2.2.1",
|
|
87
|
+
"source-map-support": "0.5.21",
|
|
88
|
+
"stats.js": "0.17.0",
|
|
89
|
+
"straps": "3.0.1",
|
|
90
|
+
"typescript": "4.9.5"
|
|
91
|
+
},
|
|
92
|
+
"keywords": [
|
|
93
|
+
"vector",
|
|
94
|
+
"graphic",
|
|
95
|
+
"graphics",
|
|
96
|
+
"2d",
|
|
97
|
+
"geometry",
|
|
98
|
+
"bezier",
|
|
99
|
+
"curve",
|
|
100
|
+
"curves",
|
|
101
|
+
"path",
|
|
102
|
+
"paths",
|
|
103
|
+
"canvas",
|
|
104
|
+
"svg",
|
|
105
|
+
"paper",
|
|
106
|
+
"paper.js",
|
|
107
|
+
"paperjs"
|
|
108
|
+
]
|
|
109
|
+
}
|