-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path09.html
66 lines (48 loc) · 1.22 KB
/
09.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
<html>
<!--
A simple animation in which the ball follows the mouse and leaves a small
trail behind. Note that the ball's (ellipse's) position is set to the mouse
position in [line 42](https://github.com/DGMD-E-15/Processing-
Tutorial-01/blob/master/09.html#L42).
-->
<head>
<script src='processing-1.4.1.js'></script>
<style>
canvas {
outline: none;
}
/* So that when we click, the canvas isn't outlined */
</style>
</head>
<body>
<canvas></canvas>
</body>
<script>
var canvas = document.getElementsByTagName('canvas')[0];
function sketch(p) {
var x, y;
function setup() {
p.size(200, 200);
p.ellipseMode(p.CENTER);
p.println("width: " + p.width + ", height: " + p.height);
x = p.width / 2;
y = p.height / 2;
//p.noLoop();
}
function draw() {
// p.background(0);
p.fill(0, 15);
p.rect(0, 0, p.width, p.height);
trace(p.mouseX, p.mouseY, 25, 25);
}
function trace(x, y) {
p.fill(255);
p.noStroke();
p.ellipse(x, y, 25, 25);
}
p.setup = setup;
p.draw = draw;
}
var p = new Processing(canvas, sketch); // actually attach and run the sketch
</script>
</html>