xxxxxxxxxx
99
// By Roni Kaufman
// https://ronikaufman.github.io/
let colors = ['#df3163', '#fe6901', '#ffe12a', '#b5348b', '#1135a7'];
function setup() {
createCanvas(1080, 1080);
noLoop();
noStroke();
}
function draw() {
let n = 5;
let s = width/n;
let col1, col2;
for (let x = 0; x < width; x += s) {
for (let y = 0; y < height; y += s) {
col1 = random(colors);
fill(col1);
rect (x, y, s);
// rectMode(CORNER);
// pattern ( PTN.checked(d / int(random(5, 20)), d / int(random(5, 20))) );
// rectPattern (x, y, s);
do {
col2 = random(colors);
} while (col1 === col2)
fill(col2);
let r = random();
if (r < 1/2) {
r = random();
if (r < 1/4) {
arc (x, y, s*2, s*2, 0, PI/2);
const d = width*.08;
patternColors(colors);
pattern ( PTN.stripeCircle(d / int(random(6, 12))) );
arcPattern (x, y, s*2, s*2, 0, PI/2);
} else if (r < 1/2) {
arc (x+s, y, s*2, s*2, PI/2, PI);
const d = width*.08;
patternColors(colors);
pattern ( PTN.dot(d / 10, (d / 10) * random(0.2, 1)) );
arcPattern (x+s, y, s*2, s*2, PI/2, PI);
} else if (r < 3/4) {
arc(x+s, y+s, s*2, s*2, PI, 3*PI/2);
const d = width*.08;
patternColors(colors);
pattern ( PTN.stripeRadial(TAU / int(random(6, 30))) );
arcPattern (x+s, y+s, s*2, s*2, PI, 3*PI/2);
} else {
arc (x, y+s, s*2, s*2, 3*PI/2, 0);
const d = width*.08;
patternColors(colors);
pattern ( PTN.wave(d / int(random(1, 3)), d / int(random(10, 20)), d / 5, d / 10) );
arcPattern (x, y+s, s*2, s*2, 3*PI/2, 0);
}
} else {
r = random();
if (r < 1/4) {
arc (x+s/2, y, s, s, 0, PI);
} else if (r < 1/2) {
arc (x+s, y+s/2, s, s, PI/2, 3*PI/2);
} else if (r < 3/4) {
arc (x+s/2, y+s, s, s, PI, 0);
} else {
arc (x, y+s/2, s, s, 3*PI/2, PI/2);
}
}
}
}
}
function randPattern(t) {
const ptArr = [
PTN.noise(0.5),
PTN.noiseGrad(0.4),
PTN.stripe(t / int(random(6, 12))),
PTN.stripeCircle(t / int(random(6, 12))),
PTN.stripePolygon(int(random(3, 7)), int(random(6, 12))),
PTN.stripeRadial(TAU / int(random(6, 30))),
PTN.wave(t / int(random(1, 3)), t / int(random(10, 20)), t / 5, t / 10),
PTN.dot(t / 10, (t / 10) * random(0.2, 1)),
PTN.checked(t / int(random(5, 20)), t / int(random(5, 20))),
PTN.cross(t / int(random(10, 20)), t / int(random(20, 40))),
PTN.triangle(t / int(random(5, 20)), t / int(random(5, 20))),
];
return random(ptArr);
}