xxxxxxxxxx
217
// Uses https://www.npmjs.com/package/p5.createloop
// Be sure that the following script is included in index.html:
// https://unpkg.com/p5.createloop@0.2.8/dist/p5.createloop.js
myPosition = 0
var shake;
var spot = {
x: 100,
y: 50,
}
function setup() {
createCanvas(640, 640);
angleMode(DEGREES)
shake = true;
frameRate(50);
pixelDensity(1);
createLoop({
duration: 4,
gif: true
});
animLoop.noiseFrequency(0.45);
}
function draw() {
background('#27314d');
//blinkingDot(degrees(animLoop.theta))
leftEye();
rightEye();
tearDrop();
//var x = width/2 + map(cos(1 * animLoop.theta), -1, 1, -200,200);
//var y = height/2 + map(sin(2 * animLoop.theta), -1, 1, -200,200);
}
//I contacted Connie last minute, so I didn't have time to finish
function blinkingDot(theta){
push();
let yscale = map(sin(theta), -1, -0.9, 0, 1);
yscale = constrain(yscale, 0, 1);
translate(75, 260);
scale(1, yscale);
rotate(-40)
fill(142, 157, 175)
stroke('#eba09b')
strokeWeight(2)
rect(0, 0, 150,150, 0,100, 0,100);
pop();
}
function leftEye() {
//======LEFT EYE=====
push()
fill('#8e9daf')
stroke('#eba09b')
strokeWeight(2)
translate(320, 320)
rotate(50)
rect(-200, 0, 150, 150, 100, 0, 100, 0);
pop()
push()
fill('#eba09b')
stroke(255)
translate(320, 320)
rotate(50)
rect(-170, 20, 110, 110, 180, 0, 180, 0);
pop()
//===pupil
push()
fill('#ee6471')
stroke('#27314d')
translate(320, 320)
rect(-150, -60, 60, 60, 40, 40, 40, 40);
pop()
push()
fill('#27314d')
noStroke()
translate(320, 320);
rect(-135, -45, 35, 35, 40, 40, 40, 40);
pop()
//===Eye twinkle===
push()
if (shake == true) {
translate(random(-1, 1), random(-1, 1));
}
translate(320, 320);
noStroke()
rect(-135, -45, 15, 15, 40, 40, 40, 40);
pop()
push()
if (shake == true) {
translate(random(-1, 1), random(-1, 1));
}
translate(385, 163);
rotate(90);
noStroke()
fill('#eba09b')
scale(0.5, 1.0);
rect(440,150, 90,90, 40,40,40,40);
pop()
}
function rightEye() {
//======RIGHT EYE=====
push()
fill('#8e9daf')
stroke('#eba09b')
strokeWeight(2)
translate(320, 245)
rotate(225)
rect(-200, 0, 150, 150, 100, 0, 100, 0);
pop()
push()
fill('#eba09b')
stroke(255)
translate(320, 260)
rotate(225)
rect(-170, 20, 110, 110, 180, 0, 180, 0);
pop()
//===pupil
push()
fill('#ee6471')
stroke('#27314d')
translate(375, 185)
rotate(225)
rect(-150, -60, 60, 60, 40, 40, 40, 40);
pop()
push()
noStroke()
fill('#27314d')
translate(370, 190);
rotate(225)
rect(-135, -45, 35, 35, 40, 40, 40, 40);
pop()
//===Eye twinkle===
push()
if (shake == true) {
translate(random(-1, 1), random(-1, 1));
}
translate(385, 163);
rotate(225)
noStroke()
rect(-133, -50, 15, 15, 40, 40, 40, 40);
pop()
push()
if (shake == true) {
translate(random(-1, 1), random(-1, 1));
}
translate(385, 163);
rotate(90);
noStroke()
fill('#eba09b')
scale(0.5, 1.0);
rect(440,-120, 90,90, 40,40,40,40);
pop()
}
function tearDrop() {
//===TEAR DROP: left
push()
fill('#8e9daf')
rectMode(CENTER)
noStroke()
translate(200, 350+myPosition)
scale (0.6, 1)
rotate(45)
rect(40, 0, 40,40, 0,40, 40,40)
var mySpeed = 1.3;
myPosition += mySpeed;
if (myPosition > 300){
myPosition = 0;
}
pop()
//===TEAR DROP: right
push()
fill('#8e9daf')
rectMode(CENTER)
noStroke()
translate(450, 350+myPosition)
scale (0.6, 1)
rotate(45)
rect(0, 50, 40,40, 0,40, 40,40)
//var mySpeed = 1;
myPosition += mySpeed;
if (myPosition > 400){
myPosition = 0;
}
pop()
}