xxxxxxxxxx
127
let wx, wy;
function setup() {
createCanvas(400, 400);
frameRate(60)
background(255);
wx = width/2;
wy = height/2;
}
function moveWalker(){
let b = 10;
wx += random(-b,b);
wy += random(-b,b);
}
function draw() {
stroke('black')
fill('black')
moveWalker();
let r = random();
if(r < 0.05){
let minX = width*0.15;
let maxX = width*0.85;
let minY = height*0.15;
let maxY = height*0.85;
let minW = width/20;
let maxW = width/8;
let minH = height/20;
let maxH = height/10;
let x = random(minX, maxX);
let y = random(minY, maxY);
let w = random(minW, maxW);
let h = random(minH, maxH);
person(x,y,w,h);
}
else if(r > 0.90){
doErase();
}
}
function doErase(){
let r = random()
if(r < 0.125){
background(255,random(20,40));
}
}
function person(px, py, pw, ph){
// # draw Body
let o1 = {
x : px,
y : py,
w : pw,
h : ph
}
stroke('#000000');
noFill();
blob(o1);
// # draw Head
let o2 = {
x : px,
y : py-ph,
w : pw/5,
h : ph/5
}
fill('#000000')
blob(o2);
// # draw Left Feet
let o3 = {
x : px-pw/3,
y : py+ph,
w : pw/10,
h : ph/10,
arcStart : 0,
arcEnd : PI/2
}
fill('#000000')
blob(o3);
// # draw Right Feet
let o4 = {
x : px+pw/3,
y : py+ph,
w : pw/10,
h : ph/10,
arcStart : 3*PI/2,
arcEnd : TWO_PI
}
fill('#000000')
blob(o4);
}
function blob(o){
// get options
let cx = o.x || width / 2;
let cy = o.y || height / 2;
let w = o.w || width / 2;
let h = o.h || height / 2;
let res = o.resolution || 50;
let ns = o.noiseScale || 100;
let nm = o.noiseMultiplier || 50;
let arcEnd = o.arcEnd || TWO_PI;
let arcStart = o.arcStart || 0;
beginShape();
for(let i = 0; i < res; i++){
let x = cx + sin(i/res*(arcEnd-arcStart) + arcStart)*w;
let y = cy + cos(i/res*(arcEnd-arcStart) + arcStart)*h;
let nx = x+(noise(x/ns,y/ns)-0.5)*nm;
let ny = y+(noise(y/ns,y/ns)-0.5)*nm;
curveVertex(nx,ny);
}
endShape(CLOSE);
}