Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
// Karanvir Sidhu
float R= random(0, 255);
float G= random(0, 255);
float B= random(0, 255);

float r= random(0, 255);
float g= random(0, 255);
float b= random(0, 255);

float starX= 0;

void setup() {
  size(600, 600);
  background(R, G, B); //setup canvas color

  smooth(); //smooth the edge
  mouseX=width/2; 
  mouseY=height/2; //start from the center
}
void draw() { 
  while (starX<600) {
    //Stars
    noStroke();
    triangle(300+starX, 200, 320+starX, 250, 280+starX, 250);
    triangle(350+starX, 250, 320+starX, 250, 320+starX, 280);
    triangle(320+starX, 280, 350+starX, 330, 300+starX, 300);
    triangle(300+starX, 300, 250+starX, 330, 280+starX, 280);
    triangle(280+starX, 280, 250+starX, 250, 280+starX, 250);
    quad(280+starX, 250, 320+starX, 250, 320+starX, 280, 280+starX, 280); 
    starX=starX+100;
  }



  stroke(0, 0, 0);
  //change the look when pressing mouse
  if (mousePressed) {
    fill(r, g, b);
  } else {
    fill(255);
  }
  rectMode (CORNER);
  rect(mouseX, mouseY, 40, 30, 180); //draw the rectangle by the rounded corner
}