xxxxxxxxxx
173
// RecurseQuad constructor(a, b, c, d, depth, tilt, miss, evenness, col1, col2)
// a,b,c,d: corners of start quad
// depth: steps of recusrsion
// tilt: max tilt of segmentation of one quad from range 0 - 0.5
// miss: perc. of one quad not beeing splittet
// evenness: perc. of split beeing regularly alternating btw. horizontal and vertical
function setup() {
createCanvas(1500, 1500);
let grid = 3;
let scl = width / grid;
let offset = 40;
let globalDots = [];
let vals = ["dbc3ad", "ebd4bb", "ebdfc1", "dad8b9", "c8d1b1", "bcc2a6"];
//let cols = makePalette(vals);
let scheme = [
[
color("#C3D4BE"),
color("#CACBD3"),
color("#95B6C6"),
color("#FDE2E1"),
],
[color("#BEDBBB"), color("#8DB596"), color("#92817A"), color("#707070")],
[color("#ABABC4"), color("#E8F6EF"), color("#9cd3c9"), color("#5c5c84")],
];
let lineScheme = [
[color("#6F494C"), color("#402A2C")],
[color("#C3423F"), color("#4e1918")],
];
let cols = scheme[0];
let lineCols = lineScheme[1];
let borderStrokeW = width / 100;
let borderCol = color(30);
for (let x = 0; x < grid; x++) {
for (let y = 0; y < grid; y++) {
push();
translate(x * scl, y * scl);
let a = createVector(offset, offset);
let b = createVector(scl - offset, offset);
let c = createVector(scl - offset, scl - offset);
let d = createVector(offset, scl - offset);
let dots = [a, b, c, d];
if (random() < 0.55) {
let dot = random(dots);
globalX = dot.x + x * scl;
globalY = dot.y + y * scl;
globalDots.push(createVector(globalX, globalY));
}
strokeWeight(borderStrokeW);
stroke(borderCol);
rect(a.x, a.y, scl - 2 * offset, scl - 2 * offset);
strokeWeight(1);
if (random() < 0.70) {
let c1 = random(cols);
let c2 = random(cols);
let c3 = random(cols);
let steps = floor(random(8, 13));
let tilt = random(0.2);
let miss = random(0.3);
let evenness = random(0.9, 1);
let q = new RecurseQuad(
a,
b,
c,
d,
steps,
tilt,
miss,
evenness,
c1,
c2,
c3
);
q.recurse();
q.show();
push();
while (random() < 0.60) {
scale(random(0.7, 0.9));
rotate(random(0.03, 0.08));
translate(random(20, 30), random(5, 15));
strokeWeight(borderStrokeW);
rect(a.x, a.y, scl - 2 * offset, scl - 2 * offset);
strokeWeight(1);
let c1 = random(cols);
let c2 = random(cols);
let c3 = random(cols);
let q = new RecurseQuad(
a,
b,
c,
d,
steps,
tilt,
miss,
evenness,
c1,
c2,
c3
);
q.recurse();
q.show();
}
pop();
} else {
fill(random(cols));
noStroke();
rect(a.x, a.y, scl - 2 * offset, scl - 2 * offset);
}
pop();
}
}
let c = new Curve();
for (let i = 0; i < globalDots.length; i++) {
c.addPoint(globalDots[i]);
}
c.makeCurve();
c.subdiv(7, 0.25);
strokeWeight(width / 85);
stroke(lineCols[0]);
c.show();
let dots2 = gitterDots(globalDots, 80);
let c2 = new Curve();
for (let i = 0; i < dots2.length; i++) {
c2.addPoint(dots2[i]);
}
c2.makeCurve();
c2.subdiv(7, 0.25);
strokeWeight(width / 150);
stroke(lineCols[1]);
c2.show();
fill(lineCols[0]);
noStroke();
for (let i = 0; i < globalDots.length; i++) {
ellipse(globalDots[i].x, globalDots[i].y, width / 40, width / 40);
}
save("tiles.png");
}
function draw() {}
function makePalette(arr) {
ret = [];
for (let i = 0; i < arr.length; i++) {
let val = "#" + arr[i];
ret.push(color(val));
}
return ret;
}
function gitterDots(dots, val) {
newDots = [];
for (let i = 0; i < dots.length; i++) {
newDot = createVector(
dots[i].x + random(-val, val),
dots[i].y + random(-val, val)
);
newDots.push(newDot);
}
return newDots;
}