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 2432d8b commit ecd0485
Show file tree
Hide file tree
Showing 5 changed files with 244 additions and 12 deletions.
23 changes: 23 additions & 0 deletions ift6251/p5/cours2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!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="cours2.js"></script>
</body>

</html>
37 changes: 37 additions & 0 deletions ift6251/p5/cours2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
var w, h, cnv

function setup() {
w = 800
h = 800
cnv = createCanvas(w, h);
var x = (windowWidth - w) / 2;
var y = (windowHeight - h) / 2;
cnv.position(x, y);
colorMode(HSB, 360, 100, 100, 250);
// noLoop()
}

function draw() {
background(0, 0, 0)
stroke(0, 0, 100)
noFill()
rect(0, 0, w, h)
stroke(0, 0, 0)
fill(50, 100, 100)
var size = w * 0.9
// rect(w*0.5-size*0.5,h*0.5-size*0.5,size,size)
var vera = 21
var molnar = 11
var hsize = size * 0.5
var udem=false
for (i = 0; i < molnar; i++) {
if(udem){fill(50, 0, 0, 120);udem=false}
else{fill(50, 100, 100, 120);udem=true}
quad(w * 0.5 - hsize + random(-vera, vera), h * 0.5 - hsize + random(-vera, vera),
w * 0.5 + hsize + random(-vera, vera), h * 0.5 - hsize + random(-vera, vera),
w * 0.5 + hsize + random(-vera, vera), h * 0.5 + hsize + random(-vera, vera),
w * 0.5 - hsize + random(-vera, vera), h * 0.5 + hsize + random(-vera, vera))
hsize -= size * 0.05
}
}

23 changes: 23 additions & 0 deletions ift6251/p5/cours3.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!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="cours3.js"></script>
</body>

</html>
146 changes: 146 additions & 0 deletions ift6251/p5/cours3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
function preload() {
font = loadFont("./FreeMono.otf");
}
var w, h, cnv, stepsize, nbhorizontalsteps, nbvertcicalsteps, grid, font

function setup() {
w = 800
h = 800
cnv = createCanvas(w, h);
var x = (windowWidth - w) / 2;
var y = (windowHeight - h) / 2;
cnv.position(x, y);
colorMode(HSB, 360, 100, 100, 250);
stepsize = Math.floor(w * 0.02)
nbhorizontalsteps = Math.floor(w / stepsize)
nbvertcicalsteps = Math.floor(h / stepsize)
// noLoop()
}

function draw() {
background(0, 0, 100)
stroke(0, 0, 0)
//initgrid1()
//asciigrid()
grid()
noLoop()
}
function grid(){
var res = 50
noStroke()
for(var i=0;i<w;i+=res){
for(var j=0;j<h;j+=res){
if(random()<0.5){
fill(0,100,100)
}
else{
fill(180,100,100)
}
if(random()<0.5){
rect(i,j,res,res)
}
else{
ellipse(i+res*0.5,j+res*0.5,res,res)
}
}
}
}

function grid2() {
grid=[]
var x, y, cx, cy, jardin, a, b, off
alea = []
lesBlocs = []
cx = w * 0.5
cy = h * 0.5
jardin = 5
jazz =floor(180/jardin)
a = 180
for (var i = 0; i < jazz; i++) {
off=random(-a / 90, a / 90); alea.push(off)
x = cx + cos(radians(a)) * w * 0.5
b = 270
for (var j = 0; j < jazz; j++) {
off=random(-b / 360, b / 360); alea.push(off)
y = cy + sin(radians(b)) * h * 0.5
grid.push(createVector(x, y))
ellipse(x,y,7,7)
b += jardin
}
a+=jardin
}

}
function initgrid1() {
grid = []
var yoff = 0.0
var xoff
var inc = 0.1
var v, x, y
for (j = 0; j < nbvertcicalsteps; j++) {
yoff += inc
xoff = 0.0
for (i = 0; i < nbhorizontalsteps; i++) {
x = i * stepsize
y = j * stepsize
xoff += inc
v = noise(xoff, yoff)
grid.push(v)
}
}
}

function asciigrid() {
textFont(font)
textSize(22)
for (j = 0; j < nbvertcicalsteps; j++) {
for (i = 0; i < nbhorizontalsteps; i++) {
x = i * stepsize
y = j * stepsize + stepsize
stroke(0, 0, 0)
fill(0, 0, 0)
var v = Math.floor(grid[j * nbhorizontalsteps + i] * 12)
//var v = Math.floor(random() * 12)
switch (v) {
case 0:
text("#", x, y)
break;
case 1:
text(":", x, y)
break;
case 2:
text("[", x, y)
break;
case 3:
text("]", x, y)
break;
case 4:
text("&", x, y)
break;
case 5:
text("°", x, y)
break;
case 6:
text("{", x, y)
break;
case 7:
text("}", x, y)
break;
case 8:
text("-", x, y)
break;
case 9:
text("_", x, y)
break;
case 9:
text("^", x, y)
break;
case 9:
text("'", x, y)
break;

}
}
}

}
27 changes: 15 additions & 12 deletions p5-experiments/plein003.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

var w, h, boites
var w, h
var cnv

function setup() {
Expand All @@ -22,22 +22,25 @@ function draw() {
background(0, 0, 0)
noStroke()
ellipse(w*0.5,h*0.5,100,100)
rose()
noLoop()
}

function rose(){
noStroke()
fill(330,100,100)
ellipse(0,h*0.5,6,6)
ellipse(w,h*0.5,6,6)
ellipse(w*0.5,0,6,6)
ellipse(w*0.5,h,6,6)
var px1,py1,px2,py2,px3,py3,px4,py4
px1 = 0; py1 = h*0.5
px2 = w*0.5; py2 = 0
px3 = w; py3 = h*0.5
px4 = w*0.5; py4 = h
beginShape();
vertex(ox1, oy1);
bezierVertex(
dx1 + ecartx * i * offx, dy1,
dx2, dx2 * 1.2 + ecarty * i * offy,
dx2, dy2);
vertex(px1, py1);
bezierVertex(px1, py2,px1,py4,px2,py2);
endShape();
rose()
noLoop()
}

function rose(){

ellipse(0,h*0.5,6,6)
}

0 comments on commit ecd0485

Please sign in to comment.