xxxxxxxxxx
let coolors = createCols('https://coolors.co/0d3b66-faf0ca-f4d35e-fc6c2f-86a5d9')
function setup() {
createCanvas(windowWidth, windowHeight);
rectMode(CENTER)
}
function draw () {
background(70)
let nums = 8
let len = 1200
let gap = len/nums
let radius = 50
for(let x = width/2 - len/2 + gap/2; x < width/2 + len/2; x+= gap) {
for(let y = height/2 - len/2 + gap/2; y < height/2 + len/2; y+= gap) {
push()
translate(x, y)
fill(random(coolors))
noStroke()
let speed = radians(x*100);
let count = Math.floor(map(x, width/2-300, width/2+300, 3, 10))
let d = Math.floor(map(x, width/2-300, width/2+300, 9, 20))
let n = Math.floor(map(y, height/2-300, height/2+300, 14, 3))
let k = n / d;
let angle = radians(x+y);
for(let i=0; i< TWO_PI; i+= radians(360/count) ) {
rotate(radians(360/count));
push();
beginShape();
for (let a = 0; a < TWO_PI * d; a+= angle) {
let r = radius * cos(k * a + speed)
let posx = r * cos(a);
let posy = r * sin(a);
drawLeaf(posx, posy)
}
endShape();
pop();
}
pop()
}
}
noLoop()
}
function drawLeaf(x, y) {
beginShape();
vertex(x, y);
// vertex(30, 20);
bezierVertex(x+10, y-4, x+10, y+10, x, y+18);
bezierVertex(x+4, y+12, x-10, y+6, x, y);
endShape();
}
function createCols(url)
{
let slaIndex = url.lastIndexOf("/");
let colStr = url.slice(slaIndex + 1);
let colArr = colStr.split("-");
for(let i = 0; i < colArr.length; i++)colArr[i] = "#" + colArr[i];
return colArr;
}