By ron liu
m = 10; m2 = 10; n = 25; r = 10 ^ 20; let canvasWidth = 1700; let canvasHeight = 800; let colors = ['black']; let scolors = ["white"]; let x, y; function pick(inputArray) { return inputArray[Math.floor(inputArray.length * Math.random())]; } function randomRange(min, max) { return min + (max - min) * Math.random(); } function buildArray(n, fillFunction) { let outputArray = []; for (let i = 0; i < n; i++) { outputArray.push(fillFunction(i)); } return outputArray; } function setup() { createCanvas(canvasWidth, canvasHeight); background(0, 0, 0); angleMode(DEGREES); x = width / 2; y = height; textSize(10); textAlign(LEFT); //noLoop() //frameRate(5); } //I edited this code and borrow from:https://editor.p5js.org/MK_Does_coding/sketches/SxR-_DX3E class Radiation { constructor(rsize, rColor, x, y) { this.radiationSize = rsize; this.radiationColor = this.radiationColor; this.xposition = randomRange(10, canvasWidth - 10); this.yposition = randomRange(y, 10 + y); } draw() { noFill(); strokeWeight(2.5); stroke(0, 0, 0); circle(width / 2, height / 2, m); stroke(72, 54, 77); circle(width / 2, height / 2, m2 / 10); stroke(245, 66, 242); noFill(); circle(width / 2, height / 2, m2 / 10.5); for (var i = 0; i < 5; i += 1) { m += 1; m2 += 1; } if (m > width && m > height) { m = 0; n += 10; background(51, 51, 51, n); } if (m2 > width * 10 && m2 > height * 10) { m2 = 0; n = 25; } } } 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); } } class Spaceship { constructor(ssize, scolor, maxX, maxY, randomN) { this.shipColor = pick(colors); this.spaceshipesize = ssize; this.spaceship = scolor; this.xposition = randomRange(300, maxX); this.yposition = randomRange(30, maxY); this.n = randomN; } draw(number) { let x = (1 * frameCount) % (-10 + height / 1); let color1 = "beige"; if (Math.random() * 255 > 0) { color1 = "white"; } fill(color(color1)); translate(this.xposition, this.yposition); if (Math.random() < 0.5) stroke(0); fill(250, 92, 156); circle(50, 50, x + 70); fill(3, 236, 252); circle(50, 50, x + 15); fill(0, 0, 0); circle(50, 50, x + 2.5); fill(3, 236, 252); circle(50, 50, x + 0.5); fill(this.shipColor); circle(50, 50, x + -1); resetMatrix(); } } class Spaceshipx { constructor(xposition, yposition, size, inputColor, randomOrNot) { this.xposition = xposition; this.yposition = yposition; this.size = size; this.spaceshipxColor = ["yellow", "pink", "blue", "orange", "purple"]; this.petalShape = ["circle"]; this.petalN = Math.floor(randomRange(5, 10)); this.inputColor = inputColor; this.randomOrNot = randomOrNot; } draw() { let colorPicker = pick(this.spaceshipxColor); let shapePicker = pick(this.petalShape); this.xposition = randomRange(20,canvasWidth - 20); this.yposition = randomRange(0, y); noStroke(); translate(0,0); if (this.randomOrNot != "random" && this.randomOrNot == "no") { colorPicker = this.inputColor; } let g = drawingContext.createLinearGradient( this.xposition + 10, this.yposition + 20, this.xposition + 15, this.yposition + 40 ); translate(this.xposition+10, this.yposition+20); if (Math.random() < 0.5) stroke(0); g.addColorStop(0, "lightblue"); g.addColorStop(1, "pink"); drawingContext.fillStyle = g; beginShape(TESS); vertex(this.xposition + 50*this.size, this.yposition + 90*this.size); vertex(this.xposition - 0*this.size, this.yposition + 30*this.size); vertex(this.xposition - 0*this.size, this.yposition + 30*this.size); vertex(this.xposition + 0*this.size, this.yposition + 10*this.size); vertex(this.xposition + 20*this.size, this.yposition + 30*this.size); vertex(this.xposition + 50*this.size, this.yposition - 10*this.size); vertex(this.xposition + 10*this.size, this.yposition + 20*this.size); vertex(this.xposition + 20*this.size, this.yposition + 30*this.size); endShape(CLOSE); resetMatrix(); } } let Random = Math.random(); let smallShapes = buildArray(20,(i) => new Spaceship(0.25, "white", 1000, 800, 10)); console.log(smallShapes[smallShapes.length-1]) smallShapes[smallShapes.length - 1].shipColor = ' gray' let smallspaceships = buildArray(20,(i) => new Spaceshipx(60*i*Math.random(), 15*i ,1, "pink", "random")); 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(); } } } let myRadiation = new Radiation(200, 0, 300, 300); let s1 = new Spaceshipx(300, 200, 1, "pink", "no"); function draw() { background(10); smallShapes.forEach(x => x.draw()) // myRadiation.draw() for(let i = 0 ; i < 2 ; i++){} let spaceshipx = new Spaceshipx (randomRange(0, 100),randomRange(100, 60) , randomRange(100,0)); //spaceshipx.draw(); s1.draw(); smallspaceships.forEach(x => x.draw()) }