forked from paperjs/paperjs.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
134 lines (128 loc) · 3.79 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-touch-fullscreen" content="yes"/>
<meta name="msapplication-tap-highlight" content="no"/>
<link rel="stylesheet" href="/assets/css/style.css"/>
<link rel="icon" href="/assets/favicon.ico" type="image/x-icon"/>
<link rel="shortcut icon" href="/assets/favicon.ico"/>
<script src="/assets/js/jquery.js"></script>
<script src="/assets/js/paper.js"></script>
<script src="/assets/js/codemirror.js"></script>
<script src="/assets/js/scripts.js"></script>
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-10082945-6']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<title>Paper.js</title>
</head>
<body class="fullscreen">
<nav>
<h1><a href="/">Paper.js</a></h1>
<ul>
<li><a href="/about/">About</a>
</li>
<li><a href="/features/">Features</a>
</li>
<li class="spacer"></li>
<li><a href="/examples/">Examples</a>
</li>
<li><a href="/showcase/">Showcase</a>
</li>
<li class="spacer"></li>
<li><a href="/tutorials/">Tutorials</a>
</li>
<li><a href="/reference/">Reference</a>
</li>
<li><a href="http://sketch.paperjs.org/">Sketch</a>
</li>
<li class="spacer"></li>
<li><a href="/download/">Download</a>
</li>
<li><a href="/donation/">Donation</a>
</li>
<li><a href="/license/">License</a>
</li>
<li class="spacer"></li>
<li><a href="http://groups.google.com/group/paperjs" target="_blank">Mailing List</a>
</li>
<li><a href="http://twitter.com/PaperJS" target="_blank">Follow on Twitter</a>
</li>
<li><a href="http://github.com/paperjs/paper.js" target="_blank">Watch on Github</a>
</li>
</ul>
</nav>
<article><div class="paperscript">
<div class="buttons">
<div class="button run">Source</div>
<div class="explain">
</div>
</div>
<script type="text/paperscript" canvas="canvas-1">
var width, height, center;
var points = 10;
var smooth = true;
var path = new Path();
var mousePos = view.center / 2;
var pathHeight = mousePos.y;
path.fillColor = 'black';
initializePath();
function initializePath() {
center = view.center;
width = view.size.width;
height = view.size.height / 2;
path.segments = [];
path.add(view.bounds.bottomLeft);
for (var i = 1; i < points; i++) {
var point = new Point(width / points * i, center.y);
path.add(point);
}
path.add(view.bounds.bottomRight);
path.fullySelected = true;
}
function onFrame(event) {
pathHeight += (center.y - mousePos.y - pathHeight) / 10;
for (var i = 1; i < points; i++) {
var sinSeed = event.count + (i + i % 10) * 100;
var sinHeight = Math.sin(sinSeed / 200) * pathHeight;
var yPos = Math.sin(sinSeed / 100) * sinHeight + height;
path.segments[i].point.y = yPos;
}
if (smooth)
path.smooth({ type: 'continuous' });
}
function onMouseMove(event) {
mousePos = event.point;
}
function onMouseDown(event) {
smooth = !smooth;
if (!smooth) {
// If smooth has been turned off, we need to reset
// the handles of the path:
for (var i = 0, l = path.segments.length; i < l; i++) {
var segment = path.segments[i];
segment.handleIn = segment.handleOut = null;
}
}
}
// Reposition the path whenever the window is resized:
function onResize(event) {
initializePath();
}
</script>
<div class="canvas">
<canvas resize="true" id="canvas-1"></canvas>
</div>
</div>
</article>
</body>
</html>