xxxxxxxxxx
88
function setup() {
createCanvas(800, 800);
noStroke();
frameRate(100);
// angleMode(degrees);
}
function draw() {
background(100);
translate(mouseX, 80);
//head
push();
fill("#c5e4ed");
rect(110, 80, 180, 150);
eyes(150, 140, 40);
fill("#ed815c");
rect(155, 165, 85, 30);
pop();
//body
fill("#a7cad4");
legL(0, 0, 40, 100);
legR(0, 0, 40, 100);
fill("#c5e4ed");
circle(200, 235, 40);
rect(125, 250, 150, 100);
fill("#a7cad4");
armL(0, 0, 40, 110);
armR(0, 0, 40, 110);
}
function eyes(x, y, z) {
fill(0);
circle(x, y, z);
circle(x + 95, y, z);
fill(255);
circle(x, y - 10, z - 20);
circle(x + 95, y - 10, z - 20);
}
function armL(x, y, l, w) {
let a = mouseX - 90;
let b = mouseY - 10;
let c = atan2(b, a);
push();
translate(100, 260);
rotate(PI / 2 - c);
rect(x, y, l, w);
pop();
}
function armR(x, y, l, w) {
let a = mouseX + 15;
let b = mouseY - 250;
let c = atan2(a, b);
push();
translate(245, 260);
rotate(c - PI / 2);
rect(x, y, l, w);
pop();
}
function legL(x, y, l, w) {
let a = mouseX - 140;
let b = mouseY - 50;
let c = atan2(b, a);
push();
translate(150, 350);
rotate(c - PI / 2);
rect(x, y, l, w);
pop();
}
function legR(x, y, l, w) {
let a = mouseX + 205;
let b = mouseY - 340;
let c = atan2(a, b);
push();
translate(215, 350);
rotate(c - PI / 2);
rect(x, y, l, w);
pop();
}