xxxxxxxxxx
100
let randoX = [];
let randoY = [];
let smileys = [];
let faces = [];
let yLimit;
function preload() {
smileys[0] = loadImage("smiley-53.png")
smileys[1] = loadImage("smiley-01.png")
smileys[2] = loadImage("smiley-02.png")
smileys[3] = loadImage("smiley-03.png")
smileys[4] = loadImage("smiley-04.png")
smileys[5] = loadImage("smiley-05.png")
smileys[6] = loadImage("smiley-06.png")
smileys[7] = loadImage("smiley-07.png")
smileys[8] = loadImage("smiley-08.png")
smileys[9] = loadImage("smiley-09.png")
for (let i = 10; i < 26; i++) {
let filename = "smiley-" + i + ".png"
//console.log(typeof filename)
smileys[i] = loadImage(filename);
}
for (let i = 26; i < 53; i++) {
let fileno = i + 1
let filename = "smiley-" + fileno + ".png"
//console.log(typeof filename)
smileys.push(loadImage(filename));
}
// console.log(smileys.length)
}
function setup() {
// 1080, 1920
createCanvas(1080/3, 1920/3);
background(255,255,255);
frameRate(60);
angleMode(DEGREES)
//blendMode(LIGHTEST)
//for (let i = 0; i < 100; i++) {
faces.push(new Face());
//}
yLimit = height * .9;
}
function draw() {
background(255,255,255);
if (frameCount % 3 === 0) {
faces.push(new Face());
console.log(frameCount);
yLimit-= .25;
}
for (let i = 0; i < faces.length; i++) {
faces[i].display();
faces[i].move();
}
if (frameCount < 3600) {
//save("smiley_gaussian_vert-"+frameCount+".png");
} else {
console.log("done")
}
}
function Face() { // a constructor object
this.xPos = randomGaussian(width/2, width/4);
this.yPos = random(100);
this.img = random(smileys);
this.rotation = random(360)
this.s = random(width * .02, width * .18)
this.yEnd = random(yLimit, height);
this.speed = random(2, 10);
this.rSpeed = random(1, 3)
// these lines set up the methods
this.display = function() {
push();
translate(this.xPos,this.yPos);
rotate(this.rotation);
image(this.img, 0, 0, this.s,this.s);
pop();
}
this.move = function() {
if (this.yPos < this.yEnd) {
this.yPos+=this.speed;
this.rotation+=this.rSpeed;
}
}
}
function mouseClicked() {
save();
background(255);
}