@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,53 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Animated Star</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
|
+
var layer = project.activeLayer;
|
|
10
|
+
|
|
11
|
+
var values = {
|
|
12
|
+
count: 34,
|
|
13
|
+
points: 32
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
for (var i = 0; i < values.count; i++) {
|
|
17
|
+
var path = new Path({
|
|
18
|
+
fillColor: i % 2 ? 'red' : 'black',
|
|
19
|
+
closed: true
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
var offset = new Point(20 + 10 * i, 0);
|
|
23
|
+
var l = offset.length;
|
|
24
|
+
for (var j = 0; j < values.points * 2; j++) {
|
|
25
|
+
offset.angle += 360 / values.points;
|
|
26
|
+
var vector = offset.normalize(l * (j % 2 ? 0.1 : -0.1));
|
|
27
|
+
path.add(offset + vector);
|
|
28
|
+
}
|
|
29
|
+
path.smooth({ type: 'continuous' });
|
|
30
|
+
layer.insertChild(0, new Group({
|
|
31
|
+
children: [path],
|
|
32
|
+
applyMatrix: false
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function onFrame(event) {
|
|
37
|
+
for (var i = 0; i < values.count; i++) {
|
|
38
|
+
var item = layer.children[i];
|
|
39
|
+
var angle = (values.count - i) * Math.sin(event.count / 128) / 10;
|
|
40
|
+
item.rotate(angle);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Reposition the paths whenever the window is resized:
|
|
45
|
+
function onResize(event) {
|
|
46
|
+
layer.position = view.center;
|
|
47
|
+
}
|
|
48
|
+
</script>
|
|
49
|
+
</head>
|
|
50
|
+
<body>
|
|
51
|
+
<canvas id="canvas" resize stats hidpi="off"></canvas>
|
|
52
|
+
</body>
|
|
53
|
+
</html>
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Boolean Operations</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
|
+
var text = new PointText({
|
|
10
|
+
position: view.center + [0, 200],
|
|
11
|
+
fillColor: 'black',
|
|
12
|
+
justification: 'center',
|
|
13
|
+
fontSize: 20
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
var originals = new Group({ insert: false }); // Don't insert in DOM.
|
|
17
|
+
|
|
18
|
+
var square = new Path.Rectangle({
|
|
19
|
+
position: view.center,
|
|
20
|
+
size: 300,
|
|
21
|
+
parent: originals,
|
|
22
|
+
fillColor: 'white'
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// Make a ring using subtraction of two circles:
|
|
26
|
+
var inner = new Path.Circle({
|
|
27
|
+
center: view.center,
|
|
28
|
+
radius: 100,
|
|
29
|
+
parent: originals,
|
|
30
|
+
fillColor: 'white'
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
var outer = new Path.Circle({
|
|
34
|
+
center: view.center,
|
|
35
|
+
radius: 140,
|
|
36
|
+
parent: originals,
|
|
37
|
+
fillColor: 'white'
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
var ring = outer.subtract(inner);
|
|
41
|
+
|
|
42
|
+
var operations = ['unite', 'intersect', 'subtract', 'exclude', 'divide'];
|
|
43
|
+
var colors = ['red', 'green', 'blue', 'black'];
|
|
44
|
+
var curIndex = -1;
|
|
45
|
+
var operation, result, activeItem;
|
|
46
|
+
|
|
47
|
+
// Change the mode every 3 seconds:
|
|
48
|
+
setInterval(setMode, 3000);
|
|
49
|
+
|
|
50
|
+
// Set the initial mode:
|
|
51
|
+
setMode();
|
|
52
|
+
|
|
53
|
+
function setMode() {
|
|
54
|
+
curIndex++;
|
|
55
|
+
if (curIndex == operations.length * 2)
|
|
56
|
+
curIndex = 0;
|
|
57
|
+
operation = operations[curIndex % operations.length];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function onMouseDown(event) {
|
|
61
|
+
var hitResult = originals.hitTest(event.point);
|
|
62
|
+
activeItem = hitResult && hitResult.item;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function onMouseDrag(event) {
|
|
66
|
+
if (activeItem)
|
|
67
|
+
activeItem.position = event.point;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function onMouseUp() {
|
|
71
|
+
activeItem = null;
|
|
72
|
+
square.position = view.center;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function onFrame(event) {
|
|
76
|
+
if (activeItem != ring) {
|
|
77
|
+
// Move the ring around:
|
|
78
|
+
var offset = new Point(140, 80) * [Math.sin(event.count / 60), Math.sin(event.count / 40)];
|
|
79
|
+
ring.position = view.center + offset;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Remove the result of the last path operation:
|
|
83
|
+
if (result)
|
|
84
|
+
result.remove();
|
|
85
|
+
|
|
86
|
+
// Perform the path operation on the ring:
|
|
87
|
+
if (curIndex < operations.length) {
|
|
88
|
+
result = square[operation](ring);
|
|
89
|
+
text.content = 'square.' + operation + '(ring)';
|
|
90
|
+
} else {
|
|
91
|
+
result = ring[operation](square);
|
|
92
|
+
text.content = 'ring.' + operation + '(square)';
|
|
93
|
+
}
|
|
94
|
+
result.selected = true;
|
|
95
|
+
result.fillColor = colors[curIndex % colors.length];
|
|
96
|
+
result.moveBelow(text);
|
|
97
|
+
|
|
98
|
+
// If the result is a group, color each of its children differently:
|
|
99
|
+
if (result instanceof Group) {
|
|
100
|
+
for (var i = 0; i < result.children.length; i++) {
|
|
101
|
+
result.children[i].fillColor = colors[i];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
function onResize() {
|
|
107
|
+
text.position = view.center + [0, 200];
|
|
108
|
+
square.position = view.center;
|
|
109
|
+
}
|
|
110
|
+
</script>
|
|
111
|
+
</head>
|
|
112
|
+
<body>
|
|
113
|
+
<canvas id="canvas" resize stats></canvas>
|
|
114
|
+
</body>
|
|
115
|
+
</html>
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Candy Crash</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
|
+
// kynd.info 2014
|
|
10
|
+
|
|
11
|
+
function Ball(r, p, v) {
|
|
12
|
+
this.radius = r;
|
|
13
|
+
this.point = p;
|
|
14
|
+
this.vector = v;
|
|
15
|
+
this.maxVec = 15;
|
|
16
|
+
this.numSegment = Math.floor(r / 3 + 2);
|
|
17
|
+
this.boundOffset = [];
|
|
18
|
+
this.boundOffsetBuff = [];
|
|
19
|
+
this.sidePoints = [];
|
|
20
|
+
this.path = new Path({
|
|
21
|
+
fillColor: {
|
|
22
|
+
hue: Math.random() * 360,
|
|
23
|
+
saturation: 1,
|
|
24
|
+
brightness: 1
|
|
25
|
+
},
|
|
26
|
+
blendMode: 'lighter'
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
for (var i = 0; i < this.numSegment; i ++) {
|
|
30
|
+
this.boundOffset.push(this.radius);
|
|
31
|
+
this.boundOffsetBuff.push(this.radius);
|
|
32
|
+
this.path.add(new Point());
|
|
33
|
+
this.sidePoints.push(new Point({
|
|
34
|
+
angle: 360 / this.numSegment * i,
|
|
35
|
+
length: 1
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
Ball.prototype = {
|
|
41
|
+
iterate: function() {
|
|
42
|
+
this.checkBorders();
|
|
43
|
+
if (this.vector.length > this.maxVec)
|
|
44
|
+
this.vector.length = this.maxVec;
|
|
45
|
+
this.point += this.vector;
|
|
46
|
+
this.updateShape();
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
checkBorders: function() {
|
|
50
|
+
var size = view.size;
|
|
51
|
+
if (this.point.x < -this.radius)
|
|
52
|
+
this.point.x = size.width + this.radius;
|
|
53
|
+
if (this.point.x > size.width + this.radius)
|
|
54
|
+
this.point.x = -this.radius;
|
|
55
|
+
if (this.point.y < -this.radius)
|
|
56
|
+
this.point.y = size.height + this.radius;
|
|
57
|
+
if (this.point.y > size.height + this.radius)
|
|
58
|
+
this.point.y = -this.radius;
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
updateShape: function() {
|
|
62
|
+
var segments = this.path.segments;
|
|
63
|
+
for (var i = 0; i < this.numSegment; i ++)
|
|
64
|
+
segments[i].point = this.getSidePoint(i);
|
|
65
|
+
|
|
66
|
+
this.path.smooth();
|
|
67
|
+
for (var i = 0; i < this.numSegment; i ++) {
|
|
68
|
+
if (this.boundOffset[i] < this.radius / 4)
|
|
69
|
+
this.boundOffset[i] = this.radius / 4;
|
|
70
|
+
var next = (i + 1) % this.numSegment;
|
|
71
|
+
var prev = (i > 0) ? i - 1 : this.numSegment - 1;
|
|
72
|
+
var offset = this.boundOffset[i];
|
|
73
|
+
offset += (this.radius - offset) / 15;
|
|
74
|
+
offset += ((this.boundOffset[next] + this.boundOffset[prev]) / 2 - offset) / 3;
|
|
75
|
+
this.boundOffsetBuff[i] = this.boundOffset[i] = offset;
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
react: function(b) {
|
|
80
|
+
var dist = this.point.getDistance(b.point);
|
|
81
|
+
if (dist < this.radius + b.radius && dist != 0) {
|
|
82
|
+
var overlap = this.radius + b.radius - dist;
|
|
83
|
+
var direc = (this.point - b.point).normalize(overlap * 0.015);
|
|
84
|
+
this.vector += direc;
|
|
85
|
+
b.vector -= direc;
|
|
86
|
+
|
|
87
|
+
this.calcBounds(b);
|
|
88
|
+
b.calcBounds(this);
|
|
89
|
+
this.updateBounds();
|
|
90
|
+
b.updateBounds();
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
getBoundOffset: function(b) {
|
|
95
|
+
var diff = this.point - b;
|
|
96
|
+
var angle = (diff.angle + 180) % 360;
|
|
97
|
+
return this.boundOffset[Math.floor(angle / 360 * this.boundOffset.length)];
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
calcBounds: function(b) {
|
|
101
|
+
for (var i = 0; i < this.numSegment; i ++) {
|
|
102
|
+
var tp = this.getSidePoint(i);
|
|
103
|
+
var bLen = b.getBoundOffset(tp);
|
|
104
|
+
var td = tp.getDistance(b.point);
|
|
105
|
+
if (td < bLen) {
|
|
106
|
+
this.boundOffsetBuff[i] -= (bLen - td) / 2;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
getSidePoint: function(index) {
|
|
112
|
+
return this.point + this.sidePoints[index] * this.boundOffset[index];
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
updateBounds: function() {
|
|
116
|
+
for (var i = 0; i < this.numSegment; i ++)
|
|
117
|
+
this.boundOffset[i] = this.boundOffsetBuff[i];
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
//--------------------- main ---------------------
|
|
122
|
+
|
|
123
|
+
var balls = [];
|
|
124
|
+
var numBalls = 18;
|
|
125
|
+
for (var i = 0; i < numBalls; i++) {
|
|
126
|
+
var position = Point.random() * view.size;
|
|
127
|
+
var vector = new Point({
|
|
128
|
+
angle: 360 * Math.random(),
|
|
129
|
+
length: Math.random() * 10
|
|
130
|
+
});
|
|
131
|
+
var radius = Math.random() * 60 + 60;
|
|
132
|
+
balls.push(new Ball(radius, position, vector));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function onFrame() {
|
|
136
|
+
for (var i = 0; i < balls.length - 1; i++) {
|
|
137
|
+
for (var j = i + 1; j < balls.length; j++) {
|
|
138
|
+
balls[i].react(balls[j]);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
for (var i = 0, l = balls.length; i < l; i++) {
|
|
142
|
+
balls[i].iterate();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
</script>
|
|
147
|
+
</head>
|
|
148
|
+
<body>
|
|
149
|
+
<canvas id="canvas" resize hidpi="off" style="background:black"></canvas>
|
|
150
|
+
</body>
|
|
151
|
+
</html>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Extruded</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
|
+
var lineGroup = new Group();
|
|
10
|
+
var lineCount = 100;
|
|
11
|
+
for (var i = 0; i < lineCount; i++) {
|
|
12
|
+
var linePath = new Path.Line([0, 0], [0, 0]);
|
|
13
|
+
lineGroup.addChild(linePath);
|
|
14
|
+
}
|
|
15
|
+
lineGroup.strokeColor = 'red';
|
|
16
|
+
|
|
17
|
+
var path1 = new Path('M63.39307,265.71387c10.8667,6.96631 26.4707,12.26025 43.18896,12.26025c24.79932,0 39.28857,-13.09619 39.28857,-32.04346c0,-17.27588 -10.03125,-27.58545 -35.38721,-37.05908c-30.65088,-11.146 -49.59814,-27.30713 -49.59814,-53.49902c0,-29.25732 24.2417,-50.9917 60.74365,-50.9917c18.94727,0 33.1582,4.4585 41.23877,9.19531L156.18018,133.35986c-5.85156,-3.62256 -18.39014,-8.9165 -35.38721,-8.9165c-25.63525,0 -35.3877,15.3252 -35.3877,28.14258c0,17.5542 11.42432,26.19238 37.33789,36.22314c31.76514,12.26025 47.64795,27.58545 47.64795,55.1709c0,28.979 -21.17676,54.33496 -65.48096,54.33496c-18.11133,0 -37.89502,-5.57275 -47.92578,-12.26025z');
|
|
18
|
+
path1.position = view.center;
|
|
19
|
+
|
|
20
|
+
var path2 = path1.clone();
|
|
21
|
+
path1.scale(1.5);
|
|
22
|
+
path2.scale(2);
|
|
23
|
+
|
|
24
|
+
var length1 = path1.length;
|
|
25
|
+
var length2 = path2.length;
|
|
26
|
+
function onFrame(event) {
|
|
27
|
+
var vector = new Point({
|
|
28
|
+
angle: -event.count % 360,
|
|
29
|
+
length: 100
|
|
30
|
+
});
|
|
31
|
+
path1.rotate(-0.5);
|
|
32
|
+
path1.position = view.center - vector;
|
|
33
|
+
|
|
34
|
+
path2.rotate(-0.5);
|
|
35
|
+
path2.position = view.center + vector.normalize(50);
|
|
36
|
+
|
|
37
|
+
for (var i = 0; i < lineCount; i++) {
|
|
38
|
+
var path = lineGroup.children[i];
|
|
39
|
+
var l1 = (length1 / lineCount * (i + event.count / 10)) % length1;
|
|
40
|
+
var l2 = (length2 / lineCount * (i + event.count / 10)) % length2;
|
|
41
|
+
path.firstSegment.point = path1.getPointAt(l1),
|
|
42
|
+
path.lastSegment.point = path2.getPointAt(l2);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
</script>
|
|
46
|
+
</head>
|
|
47
|
+
<body>
|
|
48
|
+
<canvas id="canvas" resize></canvas>
|
|
49
|
+
</body>
|
|
50
|
+
</html>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Lines</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
|
+
var amount = 45;
|
|
10
|
+
for (var i = 0; i < amount; i++) {
|
|
11
|
+
var path = new Path({
|
|
12
|
+
fillColor: {
|
|
13
|
+
hue: 1,
|
|
14
|
+
saturation: 1,
|
|
15
|
+
brightness: Math.random()
|
|
16
|
+
},
|
|
17
|
+
closed: true
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
var position = view.center;
|
|
22
|
+
var mousePos = view.center;
|
|
23
|
+
var children = project.activeLayer.children;
|
|
24
|
+
|
|
25
|
+
function iterate(count) {
|
|
26
|
+
var delta = mousePos - position;
|
|
27
|
+
position += delta / 10;
|
|
28
|
+
for (var i = 1; i < amount; i++) {
|
|
29
|
+
var path = children[i];
|
|
30
|
+
var length = Math.abs(Math.sin(i + count / 40) * 300);
|
|
31
|
+
path.segments = [
|
|
32
|
+
position + delta / 1.5,
|
|
33
|
+
position + { angle: i / amount * 360, length: length },
|
|
34
|
+
position + { angle: (i + 1) / amount * 360, length: length }
|
|
35
|
+
];
|
|
36
|
+
path.fillColor.hue = count - length;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function onFrame(event) {
|
|
41
|
+
iterate(event.count);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function onMouseMove(event) {
|
|
45
|
+
iterate();
|
|
46
|
+
mousePos = event.point;
|
|
47
|
+
}
|
|
48
|
+
</script>
|
|
49
|
+
</head>
|
|
50
|
+
<body style="background:black">
|
|
51
|
+
<canvas id="canvas" resize></canvas>
|
|
52
|
+
</body>
|
|
53
|
+
</html>
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Smoothing</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
|
+
var width, height, center;
|
|
10
|
+
var points = 10;
|
|
11
|
+
var smooth = true;
|
|
12
|
+
var path = new Path({
|
|
13
|
+
fillColor: 'black'
|
|
14
|
+
});
|
|
15
|
+
var mousePos = view.center / 2;
|
|
16
|
+
var pathHeight = mousePos.y;
|
|
17
|
+
initializePath();
|
|
18
|
+
|
|
19
|
+
function initializePath() {
|
|
20
|
+
center = view.center;
|
|
21
|
+
width = view.size.width;
|
|
22
|
+
height = view.size.height / 2;
|
|
23
|
+
path.segments = [];
|
|
24
|
+
path.add(view.bounds.bottomLeft);
|
|
25
|
+
for (var i = 1; i < points; i++) {
|
|
26
|
+
var point = new Point(width / points * i, center.y);
|
|
27
|
+
path.add(point);
|
|
28
|
+
}
|
|
29
|
+
path.add(view.bounds.bottomRight);
|
|
30
|
+
path.fullySelected = true;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function onFrame(event) {
|
|
34
|
+
pathHeight += (center.y - mousePos.y - pathHeight) / 10;
|
|
35
|
+
for (var i = 1; i < points; i++) {
|
|
36
|
+
var sinSeed = event.count + (i + i % 10) * 100;
|
|
37
|
+
var sinHeight = Math.sin(sinSeed / 200) * pathHeight;
|
|
38
|
+
var yPos = Math.sin(sinSeed / 100) * sinHeight + height;
|
|
39
|
+
path.segments[i].point.y = yPos;
|
|
40
|
+
}
|
|
41
|
+
if (smooth)
|
|
42
|
+
path.smooth({ type: 'continuous' });
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function onMouseMove(event) {
|
|
46
|
+
mousePos = event.point;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function onMouseDown(event) {
|
|
50
|
+
smooth = !smooth;
|
|
51
|
+
if (!smooth) {
|
|
52
|
+
// If smooth has been turned off, we need to reset
|
|
53
|
+
// the handles of the path:
|
|
54
|
+
for (var i = 0, l = path.segments.length; i < l; i++) {
|
|
55
|
+
var segment = path.segments[i];
|
|
56
|
+
segment.handleIn = segment.handleOut = null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Reposition the path whenever the window is resized:
|
|
62
|
+
function onResize(event) {
|
|
63
|
+
initializePath();
|
|
64
|
+
}
|
|
65
|
+
</script>
|
|
66
|
+
</head>
|
|
67
|
+
<body>
|
|
68
|
+
<canvas id="canvas" resize></canvas>
|
|
69
|
+
</body>
|
|
70
|
+
</html>
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Space</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
|
+
// The amount of symbol we want to place;
|
|
10
|
+
var count = 150;
|
|
11
|
+
|
|
12
|
+
// Create a symbol, which we will use to place instances of later:
|
|
13
|
+
var path = new Path.Circle({
|
|
14
|
+
center: new Point(0, 0),
|
|
15
|
+
radius: 5,
|
|
16
|
+
fillColor: 'white',
|
|
17
|
+
strokeColor: 'black'
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
var symbol = new SymbolDefinition(path);
|
|
21
|
+
|
|
22
|
+
// Place the instances of the symbol:
|
|
23
|
+
for (var i = 0; i < count; i++) {
|
|
24
|
+
// The center position is a random point in the view:
|
|
25
|
+
var center = Point.random() * view.size;
|
|
26
|
+
var placed = symbol.place(center);
|
|
27
|
+
var scale = (i + 1) / count;
|
|
28
|
+
placed.scale(scale);
|
|
29
|
+
placed.data.vector = new Point({
|
|
30
|
+
angle: Math.random() * 360,
|
|
31
|
+
length : scale * Math.random() / 5
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
var vector = new Point({
|
|
36
|
+
angle: 45,
|
|
37
|
+
length: 0
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
var mouseVector = vector.clone();
|
|
41
|
+
|
|
42
|
+
function onMouseMove(event) {
|
|
43
|
+
mouseVector = view.center - event.point;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// The onFrame function is called up to 60 times a second:
|
|
47
|
+
function onFrame(event) {
|
|
48
|
+
vector = vector + (mouseVector - vector) / 30;
|
|
49
|
+
|
|
50
|
+
// Run through the active layer's children list and change
|
|
51
|
+
// the position of the placed symbols:
|
|
52
|
+
for (var i = 0; i < count; i++) {
|
|
53
|
+
var item = project.activeLayer.children[i];
|
|
54
|
+
var size = item.bounds.size;
|
|
55
|
+
var length = vector.length / 10 * size.width / 10;
|
|
56
|
+
item.position += vector.normalize(length) + item.data.vector;
|
|
57
|
+
keepInView(item);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function keepInView(item) {
|
|
62
|
+
var position = item.position;
|
|
63
|
+
var itemBounds = item.bounds;
|
|
64
|
+
var bounds = view.bounds;
|
|
65
|
+
if (itemBounds.left > bounds.width) {
|
|
66
|
+
position.x = -item.bounds.width;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (position.x < -itemBounds.width) {
|
|
70
|
+
position.x = bounds.width + itemBounds.width;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (itemBounds.top > view.size.height) {
|
|
74
|
+
position.y = -itemBounds.height;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (position.y < -itemBounds.height) {
|
|
78
|
+
position.y = bounds.height + itemBounds.height / 2;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
</script>
|
|
82
|
+
</head>
|
|
83
|
+
<body>
|
|
84
|
+
<canvas id="canvas" resize hidpi="off" style="background:black"></canvas>
|
|
85
|
+
</body>
|
|
86
|
+
</html>
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Space</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
|
+
// The amount of symbol we want to place;
|
|
10
|
+
var count = 150;
|
|
11
|
+
|
|
12
|
+
project.currentStyle = {
|
|
13
|
+
fillColor: 'white'
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// Place the instances of the symbol:
|
|
17
|
+
for (var i = 0; i < count; i++) {
|
|
18
|
+
// The center position is a random point in the view:
|
|
19
|
+
var center = Point.random() * view.size;
|
|
20
|
+
var scale = (i + 1) / count;
|
|
21
|
+
var path = new Shape.Circle(center, 5 * scale);
|
|
22
|
+
path.data.vector = new Point({
|
|
23
|
+
angle: Math.random() * 360,
|
|
24
|
+
length : scale * Math.random() / 5
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var vector = new Point({
|
|
29
|
+
angle: 45,
|
|
30
|
+
length: 0
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
var mouseVector = vector.clone();
|
|
34
|
+
|
|
35
|
+
function onMouseMove(event) {
|
|
36
|
+
mouseVector = view.center - event.point;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// The onFrame function is called up to 60 times a second:
|
|
40
|
+
function onFrame(event) {
|
|
41
|
+
vector = vector + (mouseVector - vector) / 30;
|
|
42
|
+
|
|
43
|
+
// Run through the active layer's children list and change
|
|
44
|
+
// the position of the placed symbols:
|
|
45
|
+
for (var i = 0; i < count; i++) {
|
|
46
|
+
var item = project.activeLayer.children[i];
|
|
47
|
+
var size = item.bounds.size;
|
|
48
|
+
var length = vector.length / 10 * size.width / 10;
|
|
49
|
+
item.position += vector.normalize(length) + item.data.vector;
|
|
50
|
+
keepInView(item);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function keepInView(item) {
|
|
55
|
+
var position = item.position;
|
|
56
|
+
var itemBounds = item.bounds;
|
|
57
|
+
var bounds = view.bounds;
|
|
58
|
+
if (itemBounds.left > bounds.width) {
|
|
59
|
+
position.x = -item.bounds.width;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (position.x < -itemBounds.width) {
|
|
63
|
+
position.x = bounds.width + itemBounds.width;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (itemBounds.top > view.size.height) {
|
|
67
|
+
position.y = -itemBounds.height;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (position.y < -itemBounds.height) {
|
|
71
|
+
position.y = bounds.height + itemBounds.height / 2;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
</script>
|
|
75
|
+
</head>
|
|
76
|
+
<body>
|
|
77
|
+
<canvas id="canvas" resize hidpi="off" style="background:black"></canvas>
|
|
78
|
+
</body>
|
|
79
|
+
</html>
|