xxxxxxxxxx
function setup(){
createCanvas(800, 800);
noLoop();
colorMode(HSB, 360, 100, 100, 100);
}
function draw(){
background(0);
grid();
tile();
}
function grid(){
let c = int(random(3, 9));
let w = width/c;
noFill();
for(let i=0; i<c; i++){
for(let j=0; j<c; j++){
let x = i * w;
let y = j * w;
let p = int(random(7));
noStroke();
fill(getCol());
rect(x, y, w, w);
fill(360, 10);
rect(x, y, w, w);
if(random(1) < 0.5){
noStroke();
fill(0);
ellipse(x+w*0.9, y+w*0.8, w*0.05, w*0.05);
}
if(p == 0){
noStroke();
fill(getCol());
heart(x+w*0.5, y+w*0.9, w*0.2, PI);
}
else if(p == 1){
let col = getCol();
col.setAlpha(2);
fill(col);
for(let i=0; i<100; i++){
let d = map(i, 0, 99, 0, w);
ellipse(x+w/2, y+w/2, d, d);
}
}
else if(p == 2){
push();
translate(x+w*0.53, y+w*0.5);
noStroke();
fill(getCol());
for(let i=0; i<5; i++){
let d = map(i, 0, 4, w*0.2, w*0.05);
rotate(PI*0.15+(d*0.0001));
ellipse(w*0.4, 0, d, d);
}
pop();
}
else if(p == 3){
push();
translate(x+w*0.5, y+w*0.5);
noFill();
stroke(getCol());
strokeWeight(0.5);
for(let i=0; i<200; i++){
rotate(PI*0.01);
rect(0, 0, w*0.35, w*0.35);
}
pop();
}
else if(p == 4){
noStroke();
fill(getCol());
beginShape();
vertex(x+w*0.05, y+w*0.7);
vertex(x+w*0.5, y+w*0.85);
vertex(x+w*0.95, y+w*0.7);
vertex(x+w*0.5, y+w*0.95);
endShape(CLOSE);
}
else if(p == 5){
noStroke();
fill(getCol());
beginShape();
vertex(x+w, y+w*0.5);
vertex(x+w*0.5, y+w*0.1);
vertex(x, y+w*0.5);
vertex(x+w*0.5, y+w*0.9);
endShape(CLOSE);
}
else if(p == 6){
noStroke();
for(let i=0; i<500; i++){
let d = random(6);
fill(getCol());
ellipse(x+random(w), y+random(w), d, d);
}
}
eye(x + w * 0.5, y + w * 0.5, w*0.75);
}
}
}
function tile(){
let c = 400;
let w = width/c;
noFill();
stroke(360, 15);
strokeWeight(0.5);
for(let i=0; i<c; i++){
for(let j=0; j<c; j++){
let x = i*w;
let y = j*w;
rect(x, y, w, w);
}
}
}
function eye(x, y, s){
let ss = s*0.5;
let ax = s*0.2;
let ay = s*0.43;
let s1 = s*0.65;
let s2 = s*0.2;
let off1 = s*0.07;
let off2 = s*0.1;
push();
translate(x, y);
rotate(-PI*0.07);
noStroke();
fill(360);
beginShape();
vertex(ss, 0);
bezierVertex(ax, -ay, -ax, -ay, -ss, 0);
bezierVertex(-ax, ay+s*0.05, ax, ay+s*0.05, ss, 0);
endShape();
fill(getCol());
noStroke();
ellipse(0, 0, s1, s1);
grdCircle(0, 0, s1);
noFill();
stroke(getCol());
ellipse(0, 0, s1*0.8, s1*0.8);
stroke(getCol());
ellipse(0, 0, s1*0.5, s1*0.5);
fill(getCol());
noStroke();
ellipse(0, 0, s2, s2);
noStroke();
fill(360);
ellipse(-s1*0.25, -s1*0.25, s*0.25, s*0.25);
fill(0);
beginShape();
vertex(ss+off1*2.5, 0);
bezierVertex(ax, -ay-s*0.03, -ax, -ay-s*0.03, -ss, -1);
bezierVertex(-ax, -ay+off1, ax, -ay+off1, ss, 0);
endShape();
noFill();
stroke(0);
strokeWeight(1);
beginShape();
vertex(ss+off1*1.5, -off2);
bezierVertex(ax, -ay-off2, -ax, -ay-off2, -ss, -off2);
endShape();
pop();
}
function grdCircle(x, y, d){
let c = 50;
let col = getCol();
col.setAlpha(2);
noStroke();
fill(col);
for(let i=0; i<c; i++){
let a = lerp(PI*0.9, 0, i/c);
arc(x, y, d, d, -a - (PI/2), a - (PI/2), CHORD);
}
}
function heart(x, y, s, a){
let hs = s/2;
let py = -hs*0.2;
push();
translate(x, y);
rotate(a);
beginShape();
vertex(0, hs);
bezierVertex(0, hs, -hs, hs*0.5+py, -hs, py);
bezierVertex(-hs, -hs, 0, -hs, 0, py);
bezierVertex(0, -hs, hs, -hs, hs, py);
bezierVertex(hs, hs*0.5+py, 0, hs, 0, hs);
endShape();
pop();
}
function getCol(){
let h = random(60);
let s = random(80, 95);
let b = random(85, 100);
let col1 = color(h, s, b);
let col2 = color(h+(random(180, 300)), s, b);
if(random(1) < 0.5){
return col2;
}
return col1;
}