source: main/trunk/model-sites-dev/von-sparql/js/paper/examples/Tools/Grid.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: 942 bytes
Line 
1<!DOCTYPE html>
2<html>
3<head>
4 <meta charset="UTF-8">
5 <title>Grid</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 /////////////////////////////////////////////////////////////////////
10 // Values
11
12 tool.fixedDistance = 10;
13
14 var values = { size: tool.fixedDistance };
15
16 /////////////////////////////////////////////////////////////////////
17 // Mouse handling
18
19 var point, path;
20
21 function getPos(pt) {
22 return (pt / values.size).round() * values.size;
23 }
24
25 function onMouseDown(event) {
26 point = getPos(event.point);
27 path = new Path();
28 path.strokeColor = 'black';
29 path.add(point);
30 }
31
32 function onMouseDrag(event) {
33 var p = getPos(event.point);
34 if (point != p) {
35 path.add(p);
36 point = p;
37 }
38 }
39 </script>
40</head>
41<body>
42 <canvas id="canvas" resize></canvas>
43</body>
44</html>
Note: See TracBrowser for help on using the repository browser.