patterns = {
let chance = new Chance(seed);
function pattern1(i) {
let rndx0 = chance.floating({ min: 0, max: width / 2 });
let rndx1 = chance.floating({ min: rndx0, max: width });
let rndy0 = chance.floating({ min: height / 2, max: height });
let rndy1 = chance.floating({ min: rndy0, max: height });
let r = chance.floating({ min: radiusRange[0], max: radiusRange[1] });
let offset = r * chance.floating({ min: 0.95, max: 3.5 });
let fill = chance.pick(colors);
if (i !== 0 && chance.bool({ likelihood: 33 })) fill = colors[0];
return generatePattern1(
chance,
rndx0,
rndx1,
rndy0,
rndy1,
r,
offset,
fill
);
}
function pattern2(i) {
let rndx0 = chance.floating({ min: 0, max: width / 2 });
let rndx1 = chance.floating({ min: rndx0 + 25, max: width / 2 + rndx0 });
let rndy0 = chance.floating({ min: 0, max: height / 2 });
let rndy1 = chance.floating({ min: rndy0 + 25, max: height / 2 + rndy0 });
let lineWidth = chance.floating({ min: 0.2, max: 2 });
let offset = lineWidth * chance.floating({ min: 0.9, max: 5 });
let fill = chance.pick(colors);
if (i !== 0 && chance.bool({ likelihood: 33 })) fill = colors[0];
return generatePattern2(
chance,
rndx0,
rndx1,
rndy0,
rndy1,
offset,
lineWidth,
fill
);
}
let patterns = [];
let circles = Math.round(patternCount * .7);
let lines = Math.round(patternCount * .3);
for (let i = 0; i < circles; i++) {
patterns.push(pattern1(i));
}
for (let i = 0; i < lines; i++) {
patterns.push(pattern2(i));
}
return patterns;
}