xxxxxxxxxx
292
let sizeX = 375;
let sizeY = 375;
let r = [0, 1, 2]; // random number array
let characterShape = 0; // default shape value. 0 for ellipse
let myText = "HI" // Default text value
// WebGL
function preload() {
//myFont = loadFont('assets/inconsolata.otf');
}
function setup() {
createCanvas(400, 400);
}
function draw() {
background(255);
mX = mouseX - 200;
mY = mouseY - 200;
//Shape Shifting Kirby
strokeWeight(3);
let c = color(255, 200, 200); // Pink
fill(c);
//3D Kirby
if (characterShape == 0) {
ellipse(mX + 200, mY + 200, sizeX + mX, sizeY + mY);
//translate and scale
push();
translate(mouseX - 200, mouseY - 200);
scale(mouseX / 200, mouseY / 200);
//Left Eye
c = color(0); // Black
fill(c);
ellipse(150, 150, 55, 145);
c = color(255); //White
fill(c);
ellipse(150, 125, 45, 90);
c = color(0, 116, 154); // Blue
fill(c);
beginShape();
vertex(125, 170);
bezierVertex(140, 230, 160, 230, 175, 170);
bezierVertex(160, 190, 140, 190, 125, 170);
endShape();
//Right Eye
c = color(0); // Black
fill(c);
ellipse(250, 150, 55, 145);
c = color(255); // White
fill(c);
ellipse(250, 125, 45, 90);
c = color(0, 116, 154); //Blue
fill(c);
beginShape();
vertex(275, 170);
bezierVertex(260, 230, 240, 230, 225, 170);
bezierVertex(240, 190, 260, 190, 275, 170);
endShape();
//Cheeks
c = color(199, 110, 106); //Dark Pink
fill(c);
ellipse(80, 225, 75, 35);
c = color(199, 110, 106); //Dark Pink
fill(c);
ellipse(320, 225, 75, 35);
//Mouth Shape
c = color(197, 83, 98); //Red
fill(c);
beginShape();
vertex(170, 255);
bezierVertex(180, 245, 220, 245, 230, 255);
bezierVertex(240, 265, 220, 300, 200, 300);
bezierVertex(180, 300, 160, 265, 170, 255);
endShape();
//Tongue
c = color(199, 121, 131); //Pink
fill(c);
beginShape();
vertex(170, 275);
bezierVertex(180, 265, 220, 265, 230, 275);
bezierVertex(230, 275, 220, 300, 200, 300);
bezierVertex(180, 300, 160, 265, 170, 255);
endShape();
pop();
fill(0);
text(myText, 20, 40); // Draw text on screen
textSize(28);
}
//Ellipse Kirby
if (characterShape == 1) {
push();
translate(mouseX, mouseY);
fill(208, 239, 255); // Blue
ellipse(mX, mY, sizeX + mX, sizeY + mY);
pop();
//translate and scale
push();
translate(mouseX - 200, mouseY - 200);
scale(mouseX / 200, mouseY / 200);
//Left Eye
c = color(0);
fill(c);
ellipse(150, 150, 55, 145);
c = color(255);
fill(c);
ellipse(150, 125, 45, 90);
c = color(0, 116, 154);
fill(c);
beginShape();
vertex(125, 170);
bezierVertex(140, 230, 160, 230, 175, 170);
bezierVertex(160, 190, 140, 190, 125, 170);
endShape();
//Right Eye
c = color(0);
fill(c);
ellipse(250, 150, 55, 145);
c = color(255);
fill(c);
ellipse(250, 125, 45, 90);
c = color(0, 116, 154);
fill(c);
beginShape();
vertex(275, 170);
bezierVertex(260, 230, 240, 230, 225, 170);
bezierVertex(240, 190, 260, 190, 275, 170);
endShape();
//Cheeks
c = color(142, 203, 243); //Blue
fill(c);
ellipse(80, 225, 75, 35);
c = color(142, 203, 243); //Blue
fill(c);
ellipse(320, 225, 75, 35);
//Mouth Shape
c = color(197, 83, 98);
fill(c);
beginShape();
vertex(170, 255);
bezierVertex(180, 245, 220, 245, 230, 255);
bezierVertex(240, 265, 220, 300, 200, 300);
bezierVertex(180, 300, 160, 265, 170, 255);
endShape();
//Tongue
c = color(199, 121, 131);
fill(c);
beginShape();
vertex(170, 275);
bezierVertex(180, 265, 220, 265, 230, 275);
bezierVertex(230, 275, 220, 300, 200, 300);
bezierVertex(180, 300, 160, 265, 170, 255);
endShape();
pop();
fill(0);
text(myText, 20, 40); // Draw text on screen
textSize(28);
}
// Rectangle Kirby
if (characterShape == 2) {
push();
translate(mouseX, mouseY);
fill(240); //White
rect(-175, -175, mouseX + 150, mouseY + 100);
//rect(-200, -200, sizeX + mX, sizeY + mY);
pop();
//translate and scale
push();
translate(mouseX - 200, mouseY - 200);
scale(mouseX / 200, mouseY / 200);
//Left Eye
c = color(0);
fill(c);
ellipse(150, 150, 55, 145);
c = color(255);
fill(c);
ellipse(150, 125, 45, 90);
c = color(115);
fill(c);
beginShape();
vertex(125, 170);
bezierVertex(140, 230, 160, 230, 175, 170);
bezierVertex(160, 190, 140, 190, 125, 170);
endShape();
//Right Eye
c = color(0);
fill(c);
ellipse(250, 150, 55, 145);
c = color(255);
fill(c);
ellipse(250, 125, 45, 90);
c = color(115);
fill(c);
beginShape();
vertex(275, 170);
bezierVertex(260, 230, 240, 230, 225, 170);
bezierVertex(240, 190, 260, 190, 275, 170);
endShape();
//Cheeks
c = color(175); // Gray
fill(c);
ellipse(80, 225, 75, 35);
c = color(175); // Gray
fill(c);
ellipse(320, 225, 75, 35);
//Mouth Shape
c = color(75);
fill(c);
beginShape();
vertex(170, 255);
bezierVertex(180, 245, 220, 245, 230, 255);
bezierVertex(240, 265, 220, 300, 200, 300);
bezierVertex(180, 300, 160, 265, 170, 255);
endShape();
//Tongue
c = color(120);
fill(c);
beginShape();
vertex(170, 275);
bezierVertex(180, 265, 220, 265, 230, 275);
bezierVertex(230, 275, 220, 300, 200, 300);
bezierVertex(180, 300, 160, 265, 170, 255);
endShape();
pop();
fill(0);
text(myText, 20, 40); // Draw text on screen
textSize(28);
}
}
//Press Key to Randomize Shape
function mousePressed() {
characterShape = random(r);
}
// Press Key to Randomize Word
function keyPressed() {
let words = ['POYO!', 'HIIII!'];
let word = random(words);
myText = word;
}