xxxxxxxxxx
105
// RecurseQuad constructor(a, b, c, d, depth, dense, tilt, miss, evenness, col1, col2, backCol)
// a,b,c,d: corners of start quad
// depth: steps of recusrsion
// dense: perc. of tiles with fill color
// 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() {
let mycanvas = createCanvas(1500, 1500);
let colums = 2;
let rows = 2;
let scl = width / colums;
//let offset = width / 58;
let radius = 225;
let all = [];
let scheme = [
[
color("#C3D4BE"),
color("#CACBD3"),
color("#95B6C6"),
color("#FDE2E1"),
],
[
color("#FFE194"),
color("#E8F6EF"),
color("#9cd3c9"),
color("#4C4C6D"),
],
];
let cols = scheme[0];
let borderStrokeW = width / 100;
let borderCol = color(22);
stroke(borderCol);
strokeWeight(1);
let counter = 6;
for (let n = 0; n < colums; n++) {
for (let m = 0; m < rows; m++) {
push();
translate(m * scl, n * scl);
//let cs = cols.slice(1, cols.length - 1);
let cs = cols;
let steps = counter;
let tilt = random(0.08);
let miss = random(0.2);
let evenness = random(0.8, 1);
let explRate = map(counter,6,9,0.05,0.25);
let p = polygon(m * scl + scl / 2, n * scl + scl / 2, radius, 12);
let quads = [];
quads.push(new Quadrilateral(p[0], p[1], p[2], p[3]));
quads.push(new Quadrilateral(p[0], p[3], p[4], p[11]));
quads.push(new Quadrilateral(p[10], p[11], p[4], p[5]));
quads.push(new Quadrilateral(p[9], p[10], p[5], p[6]));
quads.push(new Quadrilateral(p[8], p[9], p[6], p[7]));
for (let k = 0; k < quads.length; k++) {
let c1 = random(cs);
let c2 = random(cs);
let q = new RecurseQuad(
quads[k],
steps,
tilt,
miss,
evenness,
c1,
c2,
explRate,
radius
);
q.recurse();
all.push(q);
}
pop();
counter++;
}
}
for (let i = 0; i < all.length; i++) {
all[i].showScattered();
}
save(mycanvas, "exploding.png");
noLoop();
}
function draw() {}
function polygon(x, y, radius, npoints) {
let angle = TWO_PI / npoints;
let vertices = [];
for (let a = 0; a < TWO_PI; a += angle) {
let sx = x + cos(a) * radius;
let sy = y + sin(a) * radius;
vertices.push(createVector(sx, sy));
}
return vertices;
}