======Ron Liu's Generative Flower====== let canvasWidth = 1700; let canvasHeight = 800; function setup() { createCanvas(canvasWidth,canvasHeight) background(169, 213, 214); angleMode(DEGREES); frameRate(5); noLoop() } function pick (inputArray) { return inputArray[Math.floor(inputArray.length * Math.random())] } let colors = ["white,"] function drawfantasticflower(){ for (let i = 0; i < n ; i++){ } } function redFlowers(){ xposition = [10,200] } class BackgroundPattern { constructor (size, gColor, x,y) { this.backgroundSize = size; this.backgroundColor = gColor; this.xposition = randomRange(20,canvasWidth - 20); this.yposition = randomRange(y, 5 + y); } draw () { fill("pink"); rect(this.xposition, this.yposition, this.backgroundSize, this.backgroundSize); fill("black") ellipse(this.xposition+10, this.yposition+10, this.backgroundSize, this.backgroundSize) fill("white") rect(this.xposition+15, this.yposition+15,this.backgroundSize, this.backgroundSize) } } function randomRange (min, max) { return min + ((max-min) * Math.random()) } class FantasticFlower{ constructor (fsize,fcolor,maxX,maxY) {this.color = pick(colors); this.fantasticflowersize=fsize; this.fantasticflower=fcolor; this.xposition = randomRange(300,maxX); this.yposition = randomRange(50,maxY); } draw(number){ fill(color("beige")); scale(this.fantasticflowersize); translate(this.xposition,this.yposition) //translate(width / 2, height / 2); for (let i = 0; i < number ; i++) { rotate(27) fill(this.color) ellipse(70,120,20,100) if (this.fantasticflowersize < 0.5) {fill(77, 219, 197)} else {fill(51, 64, 62)}; if (this.fantasticflowersize > 0.49) {rect(60,90,20,70)} else {ellipse(60,90,20,50) if (this.fantasticflowersize > 0.75){traingle(80,50,70)} else {square(60,30,20)} }; } resetMatrix() translate(200,600) //translate(width / 2, height / 2) for (let i = 0; i < number ; i++) { rotate(10) } resetMatrix() }} function buildArray (n, fillFunction) { let outputArray = []; for (let i = 0; i < n; i++) { outputArray.push(fillFunction(i)) } return outputArray } //let largeShapes = buildArray(100,i => new FantasticFlower(5, "small", 80, 80)); let smallShapes = buildArray(100,i => new FantasticFlower(0.25, "small", 6200, 3000)); let mediumShapes = buildArray(20,i => new FantasticFlower(0.5, "medium", 1600, 1600)); function backgroundPatternArray (number,x,y) { let outputArray = []; for (let i = 0; i < number ; i++) { outputArray.push(new BackgroundPattern (10,"orange",x + (i * 35),y)) } return outputArray } function Background2 (startingX, startingY, numberOfArrays, arrayLength) { for(let i = 0; i < numberOfArrays ; i++){ let myBackground = backgroundPatternArray (arrayLength, startingX, startingY+(i*35)); for(let i = 0; i < myBackground.length ; i++){ myBackground[i].draw() } } } function draw() { Background2 (20,20,22,200); //let fantasticflower2 = new FantasticFlower (1, "black", 40, 156); //fantasticflower2.draw(40); smallShapes.forEach(x => x.draw(40)) mediumShapes.forEach(x => x.draw(40)) }