xxxxxxxxxx
120
function setup() {
createCanvas(800, 800);
background(color("#C8E3D4"));
rectMode(CENTER);
colorMode(HSL);
let cols = [color("#87AAAA"), color("#F6EABE"), color("#FFBF86")];
let r = 320;
let lowerPoints = [];
let upperPoints = [];
let outerPoints = [];
for (let i = 0; i < 600; i++) {
let x = random(width);
let y = random(height / 2, height);
while (dist(width / 2, height / 2, x, y) > r) {
x = random(width);
y = random(height / 2, height);
}
let flag = true;
for (let p of lowerPoints) {
if (dist(p.x, p.y, x, y) < 20) {
flag = false;
}
}
if (flag) {
let v = createVector(x, y);
let v2 = createVector(x, height - y);
lowerPoints.push(v);
upperPoints.push(v2);
}
}
for (let i = 0; i < 600; i++) {
let x = random(width);
let y = random(height);
while (dist(width / 2, height / 2, x, y) < r + 85) {
x = random(width);
y = random(height);
}
let flag = true;
for (let p of outerPoints) {
if (dist(p.x, p.y, x, y) < 10) {
flag = false;
}
}
if (flag) {
let v = createVector(x, y);
outerPoints.push(v);
}
}
let s = r / 10;
let s2 = r / 20;
strokeWeight(2);
stroke(40);
for (let p of lowerPoints) {
let d = dist(0, p.y, 0, height / 2);
let c = floor(map(d, 0, r, 0, 3));
fill(cols[c]);
rect(p.x, p.y + 30, random(s / 6, s), random(s / 6, s));
}
for (let p of upperPoints) {
let d = dist(0, p.y, 0, height / 2);
let c = floor(map(d, 0, r, 0, 3));
fill(cols[c]);
rect(p.x, p.y - 30, random(s / 6, s), random(s / 6, s));
}
for (let p of outerPoints) {
fill(color("#F9F3DF"));
rect(p.x, p.y, random(s2 / 6, s2), random(s2 / 6, s2));
}
strokeWeight(4);
line(0, height / 2 + random(12, 16), width, height / 2 + random(10));
line(0, height / 2 - random(10), width, height / 2 - random(12, 16));
noFill();
circle(width / 2+ random(-50,50), height / 2, r);
circle(width / 2, height / 2, 2*r+100);
stroke(color("#C8E3D4"));
strokeWeight(35);
rect(width / 2, height / 2, width, height);
save("rectsCircle");
}
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;
}
function drawnCircle(xPos, yPos, r, acc, fillCol = null) {
let points = polygon(xPos, yPos, r, 20);
points.push(points[0], points[1]);
let diviation = r * (1 - acc);
for (let i = 0; i < points.length; i++) {
points[i].x += random(-diviation, diviation);
points[i].y += random(-diviation, diviation);
}
let c = new Curve(points, 0.25);
beginShape();
for (let i = 0; i < c.lines.length; i++) {
vertex(c.lines[i].p1.x, c.lines[i].p1.y);
vertex(c.lines[i].p2.x, c.lines[i].p2.y);
}
endShape();
}