Tap to save image. Run again for a different layout.
xxxxxxxxxx
let Url = "https://coolors.co/04e762-f5b700-00a1e4-dc0073-89fc00-ed217c-2d3047-f25757";
let noiseGra;
dir= 0
t=0.0
setup=_=>{
createCanvas(w=1112,h=834)
rd= random(100)
background(random(200,255))
noiseGra = createGraphics(width, height);
noiseGra.loadPixels();
for( let x=0; x<=width; x++){
for(let y=0; y<=height; y++){
noiseGra.set(x, y, color(255, noise(x/10,y/10,x*y/50)*random([0,20,50])))
}
}
noiseGra.updatePixels();
}
draw=_=>{
randomSeed(rd)
background(random(180,255))
reKerby(0,0,w,h)
image(noiseGra, 0, 0);
t+=.1
}
function reKerby(x, y, w, h){
//分割数
let num = 2;
for(let yi = 0; yi < num; yi++)
{
for(let xi = 0; xi < num; xi++)
{
let dx = x + w / num * xi;
let dy = y + h / num * yi;
let dw = w / num;
let dh = h / num;
let rn = random();
if(rn < 0.5 && min(dw, dh) > 30) reKerby(dx, dy, dw, dh);
else{
//描画命令
kerby(dx + dw / 2, dy + dh /2,dw/3)
}
}
}
}
function kerby(cx,cy,r){
// 初期化
body= 2*r
handW= body*0.25
handH= body*0.5
footW= body*0.5
footH= body*0.25
eye1W= body*0.12
eye1H= body*0.3
eye2W= eye1W*0.85
eye2H= eye1H*0.85
eye3W= eye2W*0.9
eye3H= eye2H*0.5
eye4W= eye2W*0.76
eye4H= eye2H*0.5
mouthR= body/11*noise(t)
//color
let cols = shuffle(createPalette(Url));
rectMode(CENTER);
ellipseMode(CENTER);
push();
translate(cx,cy);
fill(cols[0])
// handL
push()
translate(-body/2,0)
rotate(5*PI/4*(noise(t)/2+5))
ellipse(0,0,handW,handH)
pop()
// handR
push()
translate(body/2,0)
rotate(-5*PI/4*(noise(t)/2+5))
ellipse(0,0,handW,handH)
pop()
// foot
fill(cols[1])
// footL
push()
translate(-body*0.3,body/2)
rotate(-PI/6)
ellipse(0,0,footW,footH)
pop()
// footR
push()
translate(body*0.3,body/2)
rotate(PI/6)
ellipse(0,0,footW,footH)
pop()
//head
fill(cols[0])
circle(0,0,body)
// eye
fill(1)
ellipse(-body/9,-body/5,eye1W,eye1H)
ellipse(body/9,-body/5,eye1W,eye1H)
fill(cols[2])
arc(-body/9,-body/5,eye2W,eye2H,0,PI)
arc(body/9,-body/5,eye2W,eye2H,0,PI)
fill(1)
ellipse(-body/9,-body*20/100,eye3W,eye3H)
ellipse(body/9,-body*20/100,eye3W,eye3H)
fill(255)
ellipse(-body/9,-body*26/100,eye4W,eye4H)
ellipse(body/9,-body*26/100,eye4W,eye4H)
//mouth
fill("#ff6b6b")
circle(0,mouthR,mouthR)
pop();
}
function createPalette(url){
let slashIndex = url.length-1;//一番後ろの"/"のインデックス
while(slashIndex>-1 && url[slashIndex]!="/"){
slashIndex--;
}
let colStr = url.substring(slashIndex+1,url.length);
let cols = split(colStr,"-");
for(let i = 0; i < cols.length; i++) cols[i] = "#" + cols[i]; //文字列に#をつける
// print(cols)
return cols;
}
mousePressed=()=>{save('pix.jpg');}