====== Ingram's Surprising Space: Movement ======
[[Ingram-chung| by Ingram chung]]
function setup() {
createCanvas(1700, 800);
//frameRate(5);
noLoop()
}
let shapes = ["ellipse","triangle","rect"];
let colors = ["pink","yellow","white","red","lavender"]
function pick (inputArray) {
return inputArray[Math.floor(inputArray.length * Math.random())]
}
// start from 75 (tip of ellipse, 150/2), since ellipse is 150 wide
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())
}
class SuperNova {
constructor (xposition,yposition,maxSize,myColor)
{ this.color = pick(colors);
this.shape = pick(shapes);// start from 75 (tip of ellipse, 150/2), since ellipse is 150 wide
//this.xposition = randomRange(400,1750);
this.xposition = xposition;
this.yposition = yposition;
this.size = randomRange(1,maxSize);
}
draw () {
fill(this.color);
translate(this.xposition,this.yposition);
rotate(radians(40));
ellipse(75, 0, 150 * this.size , 50);
rotate(radians(40));
ellipse(75, 0, 150 * this.size, 50);
rotate(radians(40));
ellipse(75, 0, 150 * this.size, 50);
rotate(radians(40));
ellipse(75, 0, 150 * this.size, 50);
rotate(radians(40));
ellipse(75, 0, 150 * this.size, 50);
rotate(radians(40));
ellipse(75, 0, 150 * this.size, 50);
rotate(radians(40));
ellipse(75, 0, 150 * this.size, 50);
rotate(radians(40));
ellipse(75, 0, 150 * this.size, 50);
rotate(radians(40));
ellipse(75, 0, 150 * this.size, 50);
resetMatrix()
}
}
class Star {
constructor (xposition,yposition,maxSize,myColor)
{ this.color = pick(colors);
this.shape = pick(shapes);// start from 75 (tip of ellipse, 150/2), since ellipse is 150 wide
//this.xposition = randomRange(400,1750);
this.xposition = xposition;
this.yposition = yposition;
this.size = randomRange(1,maxSize);
}
draw () {
if (this.color == "white")
{this.xposition > 275 && this.xposition < 800;
}
if (this.color == "pink" && "red")
{this.size * 2;
}
//if (this.xposition > 500 && (this.xposition = 600));
if (this.xposition > 500);
{ stroke(255);
// fill(255, 244, 25);
// left side random color flowers
fill(this.color);
translate(this.xposition,this.yposition);
rotate(radians(40));
ellipse(75, 0, 150 * this.size, 50);
rotate(radians(40));
ellipse(75, 0, 150 * this.size, 50);
rotate(radians(40));
ellipse(75, 0, 150 * this.size, 50);
rotate(radians(40));
ellipse(75, 0, 150 * this.size, 50);
rotate(radians(40));
ellipse(75, 0, 150 * this.size, 50);
rotate(radians(40));
ellipse(75, 0, 150 * this.size, 50);
rotate(radians(40));
ellipse(75, 0, 150 * this.size, 50);
rotate(radians(40));
ellipse(75, 0, 150 * this.size, 50);
rotate(radians(40));
ellipse(75, 0, 150 * this.size, 50);
}
resetMatrix()
}
}
// check buildArray on the wiki to make 10 objects
let nova = buildArray (1, x => new SuperNova(900,400,15,"white"));
let g = drawingContext.createLinearGradient(500, 250, -10, -30, -10, 90);
g.addColorStop(1, 'rgb(0,0,0)k');
g.addColorStop(0.5, '#9E9E9E');
g.addColorStop(0, 'rgb(255,255,255)');
drawingContext.fillStyle = g;
triangle(500, 250, -10, -30, -10, 90);
noStroke();
function draw() {
background(20);
console.log (nova);
nova.forEach ( x => x.draw());
}