-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
70 lines (58 loc) · 1.43 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
<!DOCTYPE html>
<html>
<head>
<link rel="shortcut icon" type="image/png" href="https://cdn.glitch.com/6c4467e4-305a-4627-95b2-acfca2d590e0%2Fpixdrawing_icon.png?v=1582148630731"/>
<!-- ************** PIXEL DRAWING APP - CREATED BY Y_S - 11.11.2019 ************** -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.3/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.3/addons/p5.dom.min.js"></script>
<style> body {padding: 0; margin: 0; position:fixed;} </style>
<script>
let bubbles = [];
function setup() {
createCanvas(windowWidth, windowHeight);
frameRate(33);
}
function mouseMoved() {
let r = random(-5,10);
let b = new Bubble(mouseX, mouseY, r);
bubbles.push(b);
}
function mouseDragged() {
let r = random(0,10);
let b = new Bubble(mouseX, mouseY, r);
bubbles.push(b);
}
function draw() {
background("#202020");
for (let bubble of bubbles) {
bubble.move();
bubble.show();
}
for (let i = 0; i < bubbles.length; i++) {
bubbles[i].move();
bubbles[i].show();
}
}
class Bubble {
constructor(x, y, r) {
this.x = x;
this.y = y;
this.r = r;
}
move() {
this.x = this.x + random(-5, 5);
this.y = this.y + random(-5, 5);
}
show() {
stroke(255);
strokeWeight(1);
noFill()
ellipse(this.x, this.y, this.r * 2);
}
}
</script>
<title>P5.js simple animated interactive effect - javascript</title>
</head>
<body>
</body>
</html>