Oh, that naughty sketch! Please let us know what the issue is below.
Apply Template
Applying this template will reset your sketch and remove all your changes. Are you sure you would like to continue?
Report Sketch
Report Comment
Please confirm that you would like to report the comment below.
We will review your submission and take any actions necessary per our Community Guidelines. In addition to reporting this comment, you can also block the user to prevent any future interactions.
Please report comments only when necessary. Unnecessary or abusive use of this tool may result in your own account being suspended.
Are you sure you want to delete your sketch?
Any files uploaded will be deleted as well.
Delete Comment?
This will also delete all the replies to this comment.
Delete this tab? Any code in it will be deleted as well.
Select a collection to submit your sketch
We Need Your Support
Since 2008, OpenProcessing has provided tools for creative coders to learn, create, and share over a million open source projects in a friendly environment.
Niche websites like ours need your continued support for future development and maintenance, while keeping it an ad-free platform that respects your data and privacy!
Please consider subscribing below to show your support with a "Plus" badge on your profile and get access to many other features!
A fork of Grains a_d by yokoul
CC Attribution NonCommercial ShareAlike
Grains a_da
xxxxxxxxxx
let poteau_width = 80;
let poteau_height = 200;
let shadow_length = 120;
let gap = 100; // Espace entre les poteaux
let border = 20; // Épaisseur du cadre
let rows, cols; // Nombre de lignes et de colonnes de poteaux
let depth = 30; // Profondeur des poteaux
let padding = 50; // Espace entre le cadre et les poteaux
let colorScale7 = chroma.scale(["#FFFFFF42", "#CAC6C660", "#79797999", "#464646D1", "#000000E8"]).domain([-50, 50]);
function setup() {
createCanvas(windowWidth, windowHeight);
angleMode(DEGREES);
p5grain.setup();
// Déterminer le nombre de lignes et de colonnes en fonction de la taille de l'écran, du padding et de l'ombre
rows = Math.floor((height - 2 * (border + padding) - shadow_length) / (poteau_height + gap));
cols = Math.floor((width - 2 * (border + padding)) / (poteau_width + gap));
}
function draw() {
background(255);
noStroke();
for(let i = 0; i < rows; i++) {
for(let j = 0; j < cols; j++) {
let x = j * (poteau_width + gap) + poteau_width / 2 + gap + border + padding;
let y = i * (poteau_height + gap) + poteau_height / 2 + gap + border + padding;
// Ajout de l'effet isométrique
y += i * gap / 2;
// Poteau
push();
translate(x, y);
fill(0);
rect(-poteau_width / 2, -poteau_height, poteau_width, poteau_height);
pop();
// Ombre
push();
randomSeed(PI * i * j);
translate(x, y);
fill(colorScale7(Math.floor(Math.random(-50, 50))).hex());
beginShape();
vertex(-poteau_width / 2, 0);
vertex(poteau_width / 2, 0);
vertex(poteau_width / 2 - shadow_length / 2, shadow_length / 2);
vertex(-poteau_width / 2 - shadow_length / 2, shadow_length / 2);
endShape(CLOSE);
pop();
// Ajout du volume
stroke(180);
//line(x - poteau_width / 2, y - poteau_height, x - poteau_width / 2 + depth, y - poteau_height - depth);
//line(x + poteau_width / 2, y - poteau_height, x + poteau_width / 2 + depth, y - poteau_height - depth);
line(x - poteau_width / 2 + depth, y - poteau_height - depth, x + poteau_width / 2 + depth, y - poteau_height - depth);
line(x - poteau_width / 2 + depth, y - poteau_height - depth, x - poteau_width / 2 + depth, poteau_height / 2 - depth);
line(x + poteau_width / 2 + depth, y - poteau_height - depth, x + poteau_width / 2 + depth, poteau_height + depth);
}
}
// Ajouter un cadre noir
noFill();
stroke(0);
strokeWeight(border);
rect(border / 2, border / 2, width - border, height - border);
// Utiliser p5grain pour ajouter du grain à l'image
granulateSimple(64);
noLoop();
}
function windowResized() {
setup();
}
function keyPressed() {
// Press [S] to save frame
if (keyCode === 83) {
saveCanvas('export.png');
}
}
See More Shortcuts