Skip to content

Commit

Permalink
-.[}><{].-
Browse files Browse the repository at this point in the history
  • Loading branch information
bbaudry committed Jan 30, 2025
1 parent ecd0485 commit 007dc69
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
24 changes: 24 additions & 0 deletions ift6251/p5/cours7.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<html>

<head>
<meta charset="UTF-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.5.0/p5.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.11/addons/p5.dom.min.js"></script>
<script src="https://unpkg.com/[email protected]"></script>
<style>
body {
padding: 0;
margin: 0;
background-color: black;
}
</style>
</head>

<body>
<script src="cours7.js"></script>
<script src="particle.js"></script>
</body>

</html>
36 changes: 36 additions & 0 deletions ift6251/p5/cours7.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
function preload() {
font = loadFont("./FreeMono.otf");
}

var w, h, cnv, stepsize, x, y, p
var dust=[]
var amp=42


function setup() {
w = 800
h = 800
cnv = createCanvas(w, h);
x = (windowWidth - w) / 2;
y = (windowHeight - h) / 2;
cnv.position(x, y);
colorMode(HSB, 360, 100, 100, 250);
stepsize = 7
x=0
y=random(h)
for(var i=0;i<amp;i++){
dust.push(new Particle)
}
}

function draw() {
background(0, 0, 0, 10)
noFill()
stroke(0,0,100)
rect(0,0,w,h)
for(var i=0;i<amp;i++){
dust[i].update()
dust[i].display()
}

}
23 changes: 23 additions & 0 deletions ift6251/p5/particle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class Particle {
constructor() {
this.x=random(w)
this.y=random(h)
this.speed=Math.floor(random(7,9))
this.rad=Math.floor(random(2,7))
this.dir=random([-1,1])
}

update() {
this.x+=this.dir*this.speed
this.x=(this.x+w)%w
this.y+=this.dir*this.speed
this.y=(this.y+w)%h
}

display() {
fill(0,0,100)
noStroke()
ellipse(this.x,this.y,this.rad*2,this.rad*2)
}

}

0 comments on commit 007dc69

Please sign in to comment.