-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHLV3Hmotion10.html
More file actions
76 lines (66 loc) · 1.94 KB
/
HLV3Hmotion10.html
File metadata and controls
76 lines (66 loc) · 1.94 KB
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
71
72
73
74
75
76
<html>
<head>
<title>Art / Dev - Motion 2</title>
<script src="p5.min.js"></script>
<script>
var IMAGE_WIDTH = 640; // Don't change this.
var IMAGE_HEIGHT = 640; // Don't change this.
var particleCount = 150;
var particles = [];
var particleCounter = 0;
var time = 0;
//=============== DO ALL YOUR WORK HERE =======================
function setup() {
createCanvas(IMAGE_WIDTH, IMAGE_HEIGHT); // don't change this
noCursor();
for (var i=0; i<particleCount; i++) {
particles[i] = {
// x:320 + magnitude*cos(angle),
// y:320 + magnitude*sin(angle),
r: random(5,12),
s: random(0,50),
hue: random(0,1)
// x:random(1,640),
// y:random(1,640),
};
}
noStroke()
colorMode(HSB, 1)
}
function draw() {
fill(.5,0,.4,.4)
rect(0,0,width,height)
var currentParticle = particles[particleCounter]
var speed = random(0,7)
var angle = random(0,2*PI)
time += .025
currentParticle.x = mouseX
currentParticle.y = mouseY
currentParticle.vx = speed*cos(angle)
currentParticle.vy = speed*sin(angle)
currentParticle.hue = particleCounter/particleCount//*2*PI/particleCount)
particleCounter = (particleCounter+1) % particleCount;
particles.forEach(calculateParticle)
particles.forEach(drawParticle)
}
function calculateParticle(particle) {
particle.x += particle.vx // this is the rotation of the particles
particle.y += particle.vy
particle.vx += .1*particle.vy
particle.vy += -.1*particle.vx
particle.vy -= .25
}
function drawParticle(particle) {
fill(particle.hue,.5,1,.25)
ellipse(particle.x,particle.y,particle.r,particle.r)
}
// =============== STOP WORKING HERE ==========================
</script>
<style>
body { padding: 0; margin: 5% 0 0; background-color: #666;}
canvas { margin: 0 auto; display:block; }
</style>
</head>
<body>
</body>
</html>