let ColsHead = createCols("https://coolors.co/eede68-4b5247-91732b-1a150a");
let ColsBody = createCols("https://coolors.co/868074-e7ce13-476039-333029-c74329");
let ColsLeg = createCols("https://coolors.co/868074-1b3e50-3f4d5a-ebe9e6-7a8f61");
createCanvas(windowWidth, windowHeight,WEBGL);
let dep = max(width,height);
ortho(-width / 2, width / 2, -height / 2, height / 2,-dep*3 , dep*3);
sh = createShader(vert,frag);
sh.setUniform("u_resolution", [width,height]);
sh.setUniform("u_pixelDensity", pixelDensity());
sh.setUniform("u_lightDir", [1,1,-1]);
for(let x = -size/2; x < size/2; x+=span){
for(let z = -size/2; z < size/2; z+=span){
let height = random(0.35,0.8)*span;
let wid = random(0.12,0.2)*span;
humans.push(new Human(createVector(x,0,z),cycle,height,wid,ColsHead[int(random(ColsHead.length))], ColsBody[int(random(ColsBody.length))], ColsLeg[int(random(ColsLeg.length))]));
function createCols(_url)
let slash_index = _url.lastIndexOf('/');
let pallate_str = _url.slice(slash_index + 1);
let arr = pallate_str.split('-');
for (let i = 0; i < arr.length; i++) {
constructor(pos,cycle,height,wid,colFace,colBody,colLeg){
this.legL = new Leg(p5.Vector.add(pos,createVector(0,-this.height*0.4,-this.weight)),height*0.25,PI/2+PI*0.2, PI/2-PI*0.1,cycle,0, height*0.25,-PI*0.3,0,cycle,0.2,this.weight);
this.legR = new Leg(p5.Vector.add(pos,createVector(0,-this.height*0.4,this.weight)), height*0.25,PI/2+PI*0.2, PI/2-PI*0.1,cycle,0.5, height*0.25,-PI*0.3,0,cycle,0.7,this.weight);
this.armL = new Leg(p5.Vector.add(pos,createVector(0,-this.height+this.weight*4,-this.weight*2)),height*0.2,PI/2+PI*0.125, PI/2-PI*0.125,cycle,0.5, height*0.2,0,PI*0.25,cycle,0,this.weight*0.8);
this.armR = new Leg(p5.Vector.add(pos,createVector(0,-this.height+this.weight*4,this.weight*2)),height*0.2,PI/2+PI*0.125, PI/2-PI*0.125,cycle,0, height*0.2,0,PI*0.25,cycle,0.5,this.weight*0.8);
this.col = [colFace,colBody,colLeg];
this.legL.setPos(p5.Vector.add(this.pos,createVector(0,-this.height*0.4,-this.weight)));
this.legR.setPos(p5.Vector.add(this.pos,createVector(0,-this.height*0.4,this.weight)));
this.armL.setPos(p5.Vector.add(this.pos,createVector(0,-this.height+this.weight*4,-this.weight*2)));
this.armR.setPos(p5.Vector.add(this.pos,createVector(0,-this.height+this.weight*4,this.weight*2)));
let faceSize = this.weight*3;
let facePos = -this.height+faceSize/2;
translate(p5.Vector.add(this.pos,createVector(0,facePos,0)));
sphere(faceSize/2,10,10);
let bodyHeight = this.height*0.5-this.weight*3;
let bodyPos = facePos+faceSize*0.75+bodyHeight/2;
translate(p5.Vector.add(this.pos,createVector(0,bodyPos,0)));
box(this.weight,bodyHeight,this.weight*2.3);
let hipSize = this.weight*1.5;
translate(0,bodyPos+bodyHeight/2+hipSize/2,0);
length1,seg1MinAngle,seg1MaxAngle,seg1Cycle,seg1ratio,
length2,seg2MinAngle,seg2MaxAngle,seg2Cycle,seg2ratio,
this.seg1 = new Segment(pos,length1,seg1MinAngle,seg1MaxAngle,seg1Cycle,seg1ratio,weight);
this.seg2 = new Segment(this.seg1.getEndPos(),length2,seg2MinAngle,seg2MaxAngle,seg2Cycle,seg2ratio,weight);
this.seg2.setPos(this.seg1.getEndPos());
this.seg2.setAngleOffset(this.seg1.getAngle());
translate(this.seg1.pos);
sphere(this.seg1.weight/2,6,6);
return this.seg1.getPos();
constructor(pos,length,minAngle,maxAngle,cycle,ratio,weight)
this.frameOffset = cycle*ratio;
this.minAngle = minAngle;
this.maxAngle = maxAngle;
this.angleOffset = angle;
const ratio = ((frameCount + this.frameOffset)%this.cycle)/this.cycle;
const ratioRad = ratio * TAU;
this.angle = map(sin(ratioRad),-1,1,this.minAngle,this.maxAngle) + this.angleOffset;
let pos = this.pos.copy();
pos.add(createVector(cos(this.angle)*this.length,sin(this.angle)*this.length),0);
let endPos = this.getEndPos();
let cPos = p5.Vector.lerp(this.pos,endPos,0.5);
let h = this.pos.dist(endPos);
rotateZ(this.angle+PI/2);
cylinder(this.weight/2,h,6,1);
sphere(this.weight/2,6,6);