====== Larissa's Generative Flower ======
At first, I wanted my flowers to be in a winter wonderland theme, but the instruction says no, so I changed my flowers to different types of various shapes. I went with light pastel colors because I felt like pastel colors just give us more energy.
function buildArray (n, fillFunction) {
let outputArray = [];
for (let i = 0; i < n; i++) {
outputArray.push(fillFunction(i))
}
return outputArray
}
function randomRange(min, max) {
return min + (max - min) * Math.random();
}
function pick(inputArray) {
return inputArray[Math.floor(inputArray.length * Math.random())];
}
let colors = ["white","pink","lavender"];
let shapes = ['ellipse', 'rect','circle']
//let shapes = ['ellipse']
class Flower {
constructor ()
{ this.color = pick(colors);
this.shape = pick(shapes);
this.xposition = randomRange(20,1700);
this.yposition = randomRange(20,700);
this.size = (50,80);
}
draw() {
translate(this.xposition,this.yposition)
for(let i = 0; i < 7; i++){
//fill(235, 64, 52)
fill(this.color);
if (this.shape == 'circle')
{circle(0,60,80)}
else if (this.shape == 'rect')
{rect(0,60,80,80)}
else {ellipse(0,60,80,160)}
rotate(PI/3)
}fill(252, 252, 144)
circle(0, 0, 80);
resetMatrix()
}
}
function setup() {
createCanvas(1700, 800);
//noLoop()
noStroke()
}
let flowers = buildArray (100, i => new Flower());
console.log(flowers);
function draw() {
background(199, 220, 255);
flowers.forEach(f => f.draw())
textSize(15)
text("x:"+mouseX, 0, height/2)
text("y:"+mouseY, 0, height/3)
let move = 0 + sin(frameCount/10)*20;
let X = (2) * frameCount % (30 + height/2);
}