xxxxxxxxxx
96
function setup() {
createCanvas(700, 700);
noLoop(); // Draw once and stop
}
function draw() {
background(240);
noFill();
let gridSize = 6;
let squareSize = width / gridSize;
let colors = ['#D74C4C', '#FFC70C', '#32B5F1'];
// Draw hand-drawn curves
for (let gridX = 0; gridX < gridSize; gridX++) {
for (let gridY = 0; gridY < gridSize; gridY++) {
// strokeWeight(1);
let startX = gridX * squareSize;
let startY = gridY * squareSize;
let nol = int(random(1, 25));
for (let i = 0; i < nol; i++) {
let colorChoice = int(random(colors.length));
stroke(color(colors[colorChoice]),10);
drawHandDrawnCurve(startX, startY, squareSize);
}
}
}
// Draw grid lines
stroke(240); // Adjust the color of the grid lines
strokeWeight(20);
for (let i = 0; i < gridSize+1; i++) {
let gridPos = i * squareSize;
line(gridPos, 0, gridPos, height);
line(0, gridPos, width, gridPos);
}
// Display attribution text at the bottom right corner
noStroke();
textAlign(RIGHT, BOTTOM);
fill(0, 290);
textStyle(NORMAL);
textSize(10);
strokeWeight(0.8);
text("I can’t hold enough of you in my hands.", width - 10, height - 20);
textStyle(ITALIC);
textSize(10);
text("1/1 ", width - 10, height-10);
textSize(15);
textAlign(LEFT, TOP);
textStyle(NORMAL);
text("Ayadi", 10, 10);
noFill();
}
function drawHandDrawnCurve(x, y, size) {
let startCoord = getRandomCoordCase();
let endCoord;
do {
endCoord = getRandomCoordCase();
} while (startCoord.case === endCoord.case);
let startX = x + startCoord.x * size;
let startY = y + startCoord.y * size;
let endX = x + endCoord.x * size;
let endY = y + endCoord.y * size;
beginShape();
for (let t = 0; t <= 1; t += 0.1) {
let noiseFactor = map(noise((t + 0.2) * 10), 0, 1, -4, 4);
let curveX = lerp(startX, endX, t) + noiseFactor;
let curveY = lerp(startY, endY, t) + noiseFactor;
vertex(curveX, curveY);
}
endShape();
}
function getRandomCoordCase() {
let rand = int(random(4));
switch (rand) {
case 0:
return { x: 0, y: random(), case: 'Case 0' };
case 1:
return { x: random(), y: 0, case: 'Case 1' };
case 2:
return { x: 1, y: random(), case: 'Case 2' };
case 3:
return { x: random(), y: 1, case: 'Case 3' };
default:
return { x: 0, y: 0, case: 'Case 0' };
}
}