source: main/trunk/model-sites-dev/von-sparql/js/paper/examples/Paperjs.org/RoundedRectangles.html@ 28914

Last change on this file since 28914 was 28914, checked in by ak19, 10 years ago

Supporting javascript libraries and bespoke code written by Steffan to support the von-sparql user interface

File size: 1.1 KB
Line 
1<!DOCTYPE html>
2<html>
3<head>
4 <meta charset="UTF-8">
5 <title>Rounded Rectangles</title>
6 <link rel="stylesheet" href="../css/style.css">
7 <script type="text/javascript" src="../../dist/paper.js"></script>
8 <script type="text/paperscript" canvas="canvas">
9 var mousePoint = view.center;
10 var amount = 25;
11 var colors = ['red', 'white', 'blue', 'white'];
12
13 for (var i = 0; i < amount; i++) {
14 var rect = new Rectangle([0, 0], [25, 25]);
15 rect.center = mousePoint;
16 var path = new Path.Rectangle(rect, 6);
17 path.fillColor = colors[i % 4];
18 var scale = (1 - i / amount) * 20;
19 path.scale(scale);
20 }
21
22 function onMouseMove(event) {
23 mousePoint = event.point;
24 }
25
26 var children = project.activeLayer.children;
27 function onFrame(event) {
28 for (var i = 0, l = children.length; i < l; i++) {
29 var item = children[i];
30 var delta = (mousePoint - item.position) / (i + 5);
31 item.rotate(Math.sin((event.count + i) / 10) * 7);
32 if (delta.length > 0.1)
33 item.position += delta;
34 }
35 }
36 </script>
37</head>
38<body>
39 <canvas id="canvas" resize hidpi="off"></canvas>
40</body>
41</html>
Note: See TracBrowser for help on using the repository browser.