• fullscreen
  • for_class.pde
  • boolean button = false;
    
    int x = 0;
    int y = 0;
    int distance = 25;
    
    int a = 460;
    int b = 20;
    int h = 20;
    int w = 20;
    
    float r;
    float g;
    float c;
    float d;
        
    void setup() {
      size (500, 500);
     
     
    }
      
    void draw() {
      r = random(100);
      g = random(100);
      c = random(100);
      d = random(255);
      
      background(0);
      strokeWeight(1);
      stroke(r,g,c);
      smooth();
     
     if (button) {
      for (int i=0; i<21; i++)
      {
        line(i*distance, 0, mouseX, mouseY);
      }
      for (int j=x; j<21; j++)
      {
        line(mouseX,mouseY, (j*distance),500);
      }
     }
     stroke(0);
     fill(0, 255, 255);
     rect(a,b,w,h);
    }
    
    void mousePressed() {
      if (mouseX > a && mouseX < a+w && mouseY > b && mouseY < b+h && mousePressed ) {
       button = !button;
      } else {
      noStroke();
      fill(r,g,c,a);
      ellipse(mouseX,mouseY,100,100);
      }
    }
    
    

    code

    tweaks (0)

    about this sketch

    This sketch is running as Java applet, exported from Processing.

    license

    advertisement

    Sara Rasmussen

    Learning Variables, Conditionals and Loops

    Add to Faves Me Likey@!
    You must login/register to add this sketch to your favorites.

    Built using code from Sharon Hoosein (http://www.openprocessing.org/visuals/?visualID=38045)

    You need to login/register to comment.