surprisingSpaceAnomaly

by Yiler_Huang

CSS

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  background: #030614;
}

svg {
  filter: drop-shadow(1px 1px 10px rgb(255 200 200));
}

JavaScript

let draw = SVG().addTo('body').size(800, 800)

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;
}

class Star {
  constructor() {
    let starGlow = [
      "#0087D2",
      "#3C6A5E",
      "#9C6837",
      "#5B2023",
      "#B6CFE5",
      "#C53308",
      "#DBD5FE",
      "#1029e8"
    ]
    this.glowColor = starGlow[Math.floor(randomRange(0, starGlow.length))];
    this.width = randomRange(0.2, 10)
    this.length = randomRange(0.2, 10)
    this.glow = randomRange(4, 16)
    this.xPosition = randomRange(0, 800)
    this.yPosition = randomRange(0, 800)
  }
  addToSVG(drawing) {
    return drawing.ellipse(this.width, this.length).move(this.xPosition, this.yPosition).fill("lightBlue")
  }
}

class AnomalyStar {
  constructor() {
    let starGlow = [
      "#0087D2",
      "#3C6A5E",
      "#9C6837",
      "#5B2023",
      "#B6CFE5",
      "#C53308",
      "#DBD5FE",
      "#1029e8"
    ]
    this.glowColor = starGlow[Math.floor(randomRange(0, starGlow.length))];
    this.width = randomRange(20, 30)
    this.length = randomRange(20, 30)
    this.glow = randomRange(4, 16)
    this.xPosition = randomRange(0, 800)
    this.yPosition = randomRange(0, 800)
  }
  addToSVG(drawing) {
    return drawing.ellipse(this.width, this.length).move(this.xPosition, this.yPosition).fill(this.glowColor)
  }
}

class SmallStars {
  constructor() {
    let starGlow = [
      "#0087D2",
      "#3C6A5E",
      "#9C6837",
      "#5B2023",
      "#B6CFE5",
      "#C53308",
      "#DBD5FE"
    ]
    this.glowColor = starGlow[Math.floor(randomRange(0, starGlow.length))];
    this.size = randomRange(0.1, 0.3)
    if (this.glowColor == starGlow[1]) {
      this.size = 1
    } else {
      this.glow = randomRange(3, 4)
    }
    this.xPosition = randomRange(0, 800)
    this.yPosition = randomRange(0,...