-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathhello-world-p5js.html
More file actions
38 lines (32 loc) · 971 Bytes
/
hello-world-p5js.html
File metadata and controls
38 lines (32 loc) · 971 Bytes
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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Getting Started with ml5.js</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<!-- p5 -->
<script src="js/vendor/p5.min.js"></script>
<script src="js/vendor/p5.dom.min.js"></script>
<script src="js/vendor/p5.sound.min.js"></script>
<!-- ml5 -->
<script src="js/vendor/ml5.min.js"></script>
</head>
<body>
<script>
console.log('ml5 version:', ml5.version);
function setup(){
createCanvas(400, 400);
background(180);
let txt = createDiv(ml5.version);
txt.position(25,25);
}
function draw(){
drawEllipse(mouseX, mouseY, pmouseX, pmouseY);
}
function drawEllipse(x, y, pX, pY) {
let speed = abs(x - pX) + abs(y - pY);
ellipse(x, y, speed, speed+10); // size correlated to mouse pointer speed
}
</script>
</body>
</html>