createCanvas(windowWidth, windowHeight);
for (let star of stars) {
for (let nebula of nebulae) {
for (let galaxy of galaxies) {
for (let blackHole of blackHoles) {
function generateStars() {
for (let i = 0; i < starCount; i++) {
let brightness = random(200, 255);
stars.push(new Star(x, y, size, brightness));
function generateNebulae() {
for (let i = 0; i < nebulaCount; i++) {
let size = random(200, 400);
let color1 = color(random(100, 255), random(50, 150), random(150, 255), 100);
let color2 = color(random(50, 150), random(100, 255), random(150, 255), 80);
nebulae.push(new Nebula(x, y, size, color1, color2));
function generateGalaxies() {
for (let i = 0; i < galaxyCount; i++) {
let arms = int(random(4, 8));
let radius = random(100, 300);
let color1 = color(random(200, 255), random(200, 255), random(255), 150);
galaxies.push(new Galaxy(x, y, arms, radius, color1));
function generateBlackHoles() {
for (let i = 0; i < blackHoleCount; i++) {
let size = random(50, 100);
blackHoles.push(new BlackHole(x, y, size));
constructor(x, y, size, brightness) {
this.brightness = brightness;
ellipse(this.x, this.y, this.size);
constructor(x, y, size, color1, color2) {
for (let i = 0; i < 50; i++) {
let offsetX = random(-this.size / 2, this.size / 2);
let offsetY = random(-this.size / 2, this.size / 2);
fill(lerpColor(this.color1, this.color2, random(1)));
ellipse(this.x + offsetX, this.y + offsetY, random(10, 30));
constructor(x, y, arms, radius, color1) {
translate(this.x, this.y);
for (let i = 0; i < 1000; i++) {
let angle = random(TWO_PI) + (floor(random(this.arms)) * PI / this.arms);
let dist = pow(random(1), 0.5) * this.radius;
let posX = cos(angle) * dist;
let posY = sin(angle) * dist;
ellipse(posX, posY, 2, 2);
constructor(x, y, size) {
translate(this.x, this.y);
ellipse(0, 0, this.size);
for (let i = 0; i < 10; i++) {
let glowColor = lerpColor(color(255, 100, 0, 50), color(255, 0, 0, 20), i / 10);
ellipse(0, 0, this.size * 1.5 + i * 5);