xxxxxxxxxx
144
let x, y, h;
function setup() {
createCanvas(400, 600);
angleMode(DEGREES);
rectMode(CENTER);
}
function draw() {
background(0,0,35,25);
//blinking stars
var galaxy = {
locationX : random(width),
locationY : random(height),
size : random(1,6)
}
fill(255)
ellipse(galaxy.locationX ,galaxy.locationY, galaxy.size, galaxy.size);
translate(0, 30);
legs();
head();
torso();
}
function head() {
push();
x = map(mouseX, 0, 400, -45, 45, [true]);
translate(width / 2, 190);
rotate(x);
push();
strokeWeight(3);
stroke("#4e4b60");
line(0, -105, 0, -165);
pop();
let r = random(0, 255);
let g = random(0, 255);
let b = random(0, 255);
fill(r, g, b);
ellipse(0, -165, 10, 10);
fill("#4e4b60");
rect(0, -115, 20, 30);
fill("#d5d4d8");
rect(0, -135, 20, 10);
pop();
fill("#d5d4d8");
arc(width / 2, 130, 160, 100, 180, 0, CHORD);
fill(80);
triangle(width / 2 - 30, 130, width / 2 + 30, 130, width / 2, 100);
fill(250, 180, 5);
y = map(mouseX, 0, 400, width / 2 - 5, width / 2 + 5, [true]);
ellipse(y, 115, 10, 15);
push();
noStroke();
fill(255, 255, 255, 90);
let z = map(mouseX, 0, 400, 130, 270, [true]);
if (mouseX < 200) {
h = map(mouseX, 0, 200, 10, 55, [true]);
} else {
h = map(mouseX, 200, 400, 55, 10, [true]);
}
rect(z, 110, 5, h, 3, 3, 0, 0);
pop();
}
function torso() {
fill("#5c2d7a");
rect(width / 2, 230, 200, 200, 10, 10, 0, 0);
fill("#992576");
triangle(width / 2 - 10, 130, width / 2 - 50, 130, width / 2 - 10, 150);
triangle(width / 2 + 10, 130, width / 2 + 50, 130, width / 2 + 10, 150);
fill("#d41574");
triangle(width / 2, 130, width / 2 - 15, 120, width / 2 - 15, 140);
triangle(width / 2, 130, width / 2 + 15, 120, width / 2 + 15, 140);
rect(width / 2, 130, 10, 10, 2, 2, 2, 2);
ellipse(width / 2, 180, 10, 10);
ellipse(width / 2, 220, 10, 10);
ellipse(width / 2, 260, 10, 10);
push();
noStroke();
fill(255, 255, 255, 90);
let z = map(mouseX, 0, 400, width / 2 - 3, width / 2 + 3, [true]);
rect(z, 180, 2, 5);
rect(z, 220, 2, 5);
rect(z, 260, 2, 5);
pop();
}
function legs() {
let x = random(-5,5)
let y=random(-5,5)
if(mouseIsPressed){
if(mouseX>100 && mouseX<300 && mouseY>360 && mouseY<490)
{
fill(255);
rect(width / 2 - 50, 440-x, 60, 30, 0, 0, 20, 20);
rect(width / 2 + 50, 440+x, 60, 30, 0, 0, 20, 20);
fill("#7e88db");
rect(width / 2 - 50, 420-x, 60, 40, 0, 0, 10, 10);
rect(width / 2 + 50, 420+x, 60, 40, 0, 0, 10, 10);
fill("#e191ba");
rect(width / 2 - 50, 330-x, 100, 180, 0, 0, 40, 50);
rect(width / 2 + 50, 330+x, 100, 180, 0, 0, 50, 40);
fill(255);
arc(width / 2 +x, 330, 160, 120, 0, 180, CHORD);
}
else{
fill(255);
rect(width / 2 - 50, 440, 60, 30, 0, 0, 20, 20);
rect(width / 2 + 50, 440, 60, 30, 0, 0, 20, 20);
fill("#7e88db");
rect(width / 2 - 50, 420, 60, 40, 0, 0, 10, 10);
rect(width / 2 + 50, 420, 60, 40, 0, 0, 10, 10);
fill("#e191ba");
rect(width / 2 - 50, 330, 100, 180, 0, 0, 40, 50);
rect(width / 2 + 50, 330, 100, 180, 0, 0, 50, 40);
fill(255);
arc(width / 2, 330, 160, 120, 0, 180, CHORD);
}
}
else{
fill(255);
rect(width / 2 - 50, 440, 60, 30, 0, 0, 20, 20);
rect(width / 2 + 50, 440, 60, 30, 0, 0, 20, 20);
fill("#7e88db");
rect(width / 2 - 50, 420, 60, 40, 0, 0, 10, 10);
rect(width / 2 + 50, 420, 60, 40, 0, 0, 10, 10);
fill("#e191ba");
rect(width / 2 - 50, 330, 100, 180, 0, 0, 40, 50);
rect(width / 2 + 50, 330, 100, 180, 0, 0, 50, 40);
fill(255);
arc(width / 2, 330, 160, 120, 0, 180, CHORD);
}
arc(width / 2, 330, 160, 120, 0, 180, CHORD);
// console.log("hi")
}