You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
997 B
46 lines
997 B
6 months ago
|
class Face {
|
||
|
|
||
|
constructor(image, emotions){
|
||
|
this.image = image;
|
||
|
this.emotions = emotions;
|
||
|
this.position = createVector(width / 2, height /2);
|
||
|
this.destination = createVector(0, 0);
|
||
|
this.isFinished = false;
|
||
|
this.positionRandom();
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
emotionCheck() {
|
||
|
let { neutral, happy, angry, sad, disgusted, surprised, fearful } = this.emotions;
|
||
|
if (happy > 0.5) return true;
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
// Set's a random destination
|
||
|
positionRandom() {
|
||
|
this.destination.set(random(0, windowWidth), random(0, windowHeight));
|
||
|
}
|
||
|
|
||
|
// Draws face to the canvas
|
||
|
drawImage() {
|
||
|
if (!this.isFinished) {
|
||
|
this.checkDistance();
|
||
|
this.position.set(p5.Vector.slerp(this.position, this.destination, 0.1));
|
||
|
image(this.image, this.position.x, this.position.y);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Distance between to vectors
|
||
|
checkDistance() {
|
||
|
if(p5.Vector.dist(this.position, this.destination) < 0.1) this.isFinished = true;
|
||
|
}
|
||
|
|
||
|
// Add's face to the main image
|
||
|
addFaceToImage() {
|
||
|
// Returns
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|