Skip to content

Commit

Permalink
}°.°><°.°{
Browse files Browse the repository at this point in the history
  • Loading branch information
bbaudry committed Jan 11, 2025
1 parent b63d2bd commit 223264b
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 6 deletions.
4 changes: 2 additions & 2 deletions ift6251/p5/intro.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ function withcolors() {
translate(w * 0.5, h * 0.5)
noStroke()
fill(0, 0,100, 199)
var cours = "algorithmic art"
var cours = "algo art"
rect(-textWidth(cours)*0.5, -h * noise(xoff)*0.5, textWidth(cours), h * noise(xoff))
if (i > 30 && i < 330) {
fill(0, 0,100, 199)
rect(-w * noise(xoff) * 0.5, -h * 0.05, w * noise(xoff), h * 0.1)
}
if (i > 90 && i < 270) {
fill(0, 0,100, 199)
fill(0, 100,100, 199)
rect(-w * noise(xoff) * 0.5, -h * 0.3, w * noise(xoff) , h * 0.6)
}
if (i > 150 && i < 210) {
Expand Down
90 changes: 90 additions & 0 deletions labyrinthe/cell.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// Daniel Shiffman
// http://codingtra.in
// http://patreon.com/codingtrain

// Videos
// https://youtu.be/HyK_Q5rrcr4
// https://youtu.be/D8UgRyRnvXU
// https://youtu.be/8Ju_uxJ9v44
// https://youtu.be/_p5IH0L63wo

// Depth-first search
// Recursive backtracker
// https://en.wikipedia.org/wiki/Maze_generation_algorithm

function Cell(i, j) {
this.i = i;
this.j = j;
this.walls = [true, true, true, true];
this.visited = false;

this.checkNeighbors = function() {
var neighbors = [];

var top = grid[index(i, j - 1)];
var right = grid[index(i + 1, j)];
var bottom = grid[index(i, j + 1)];
var left = grid[index(i - 1, j)];

if (top && !top.visited) {
neighbors.push(top);
}
if (right && !right.visited) {
neighbors.push(right);
}
if (bottom && !bottom.visited) {
neighbors.push(bottom);
}
if (left && !left.visited) {
neighbors.push(left);
}

if (neighbors.length > 0) {
var r = floor(random(0, neighbors.length));
return neighbors[r];
} else {
return undefined;
}
}

this.highlight = function() {
var x = leftmargin + this.i * density;
var y = topmargin + this.j * density;
noStroke();
fill(320, 100, 100, 100);
rect(x, y, density, density);
}

this.jeton = function(){
var x = leftmargin + this.i * density;
var y = topmargin + this.j * density;
noStroke();
fill(50, 100, 100);
ellipse(x+density*0.5, y+density*0.5, density-7, density-7);
}

this.show = function() {
var x = leftmargin + this.i * density;
var y = topmargin + this.j * density;
stroke(255);

if (this.walls[0]) {
line(x, y, x + density, y);
}
if (this.walls[1]) {
line(x + density, y, x + density, y + density);
}
if (this.walls[2]) {
line(x + density, y + density, x, y + density);
}
if (this.walls[3]) {
line(x, y + density, x, y);
}

if (this.visited) {
noStroke();
fill(255, 0, 255, 100);
rect(x, y, density, density);
}
}
}
5 changes: 3 additions & 2 deletions p5-experiments/field/ptpx002.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ function preload() {
}

function setup() {
//getsvg()
getpng()
getsvg()
//getpng()
centerCanvas();
colorMode(HSB, 360, 100, 100, 250);
strokeCap(SQUARE)
Expand Down Expand Up @@ -48,6 +48,7 @@ function draw() {
}
}
if (gensvg) { save("ptpx002-main.svg") }
noLoop()
}
if (frameCount == 3) {
for (var i = 0; i < 3; i++) {
Expand Down
4 changes: 2 additions & 2 deletions p5-experiments/midiro/midirointro.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ function head(){
textSize(142)
noStroke()
fill(0,0,100)
text("art",0.37*w,0.25*h)
text("génératif",0.13*w,0.93*h)
text("art",w*0.5-textWidth("art")*0.5,0.25*h)
text("génératif",w*0.5-textWidth("génératif")*0.5,0.93*h)
}

function carre(){
Expand Down

0 comments on commit 223264b

Please sign in to comment.