Week 4 – Black Hole

For this weeks assignment, I have decided to write a code that will draw a black hole.

Zrzut ekranu 2018-10-07 o 13.27.01.png

 

CODE:

void setup() {

  size(1000, 1000);
  background(0);
  noLoop();
}

void draw() {

  translate (width/2, height/2);
  for (int i =0; i<500; i=i+1) {
    strokeWeight(random(0.5, 0.75));
    stroke(166, 214, 242);
    rotate(radians(random(0, 360)));
    float a= random(150, 300);
    float b= random(40, 100);
    line(b, b, a, a);
  }

  for (int l =0; l<500; l=l+1) {
    stroke(166, 214, 242);
    rotate(radians(random(0, 360)));
    float z= random(150, 300);
    float x= random(40, 100);
    line(x, x, z, z);
  }

  for (int z =0; z<300; z=z+1) {
    stroke(127, 110, 152);
    rotate(radians(random(0, 360)));
    float c= random(220, 400);
    float d= random(80, 150);
    line(d, d, c, c);
  }

  for (int v =0; v<100; v=v+1) {
    stroke (196, 46, 24);
    rotate(radians(random(0, 360)));
    float e= random(220, 400);
    float f= random(80, 150);
    line(f, f, e, e);
  }

  for (int s=0; s<100; s+=1) {
    noStroke();
    float m= random (-500, 500);
    float n= random(-500, 500);
    fill(255);

    ellipse (n, m, 5, 5);
  }
}

 

.zip link

Leave a comment