• fullscreen
  • Rain.pde
  • Ray.pde
  • random_rays_in_clumps.pde
  • class Rain {
      float r = random(900);
      float y = random(-height);
    
      void fall() {
         y = y + 7;
        fill(104, 158, 181, rainOpacity);
        noStroke();
        ellipse(r, y, 8, 8);
    
       if(y > height) {
         r = random(mouseX - 250, mouseX + 70);
         y = 0;
        }
       }  
      }
      
    
    
    
    
    class Ray {
      
      int x1, y1, x2, y2;
      
      float opacity = 180;
      
      Ray(int x1, int y1, int x2, int y2) {
        this.x1 = x1;
        this.y1 = y1;
        this.x2 = x2;
        this.y2 = y2;
      }
      
      void fade() {
        
        stroke(250,235,25, opacity);
        opacity -= fade;
        line(x1, y1, x2, y2);
      }
     }
    
    
    import ddf.minim.*;
    import ddf.minim.signals.*;
    import ddf.minim.analysis.*;
    import ddf.minim.effects.*;
    
    Minim m;
    AudioPlayer rainSound;
    
    Minim n;
    AudioPlayer sunnySound;
    
    Minim o;
    AudioPlayer rainEndSound;
    
    Rain[] drops = new Rain[1000];
    Set<Ray> rays = new HashSet<Ray>();
    
    float minGain;
    float maxGain;
    
    float x = 250;
    float y = 250;
    
    boolean sunny = true;
    int fade = 1;
    
    int rainOpacity = 0;
    
    
    void setup() {
      size (500,500);
      background (255);
      smooth();
          
      m = new Minim (this);
      
      rainSound = m.loadFile ("rain.wav");
      
      n = new Minim (this);
      
      sunnySound = n.loadFile ("sunnyDay.wav");
      
      o = new Minim (this);
      
      rainEndSound = o.loadFile ("rainEnding.wav");
      
      minGain = rainSound.gain().getMinimum();
      maxGain = rainSound.gain().getMaximum();
      
      minGain = sunnySound.gain().getMinimum();
      maxGain = sunnySound.gain().getMaximum();
      
      for (int i = 0; i < drops.length; i++) {
        drops[i] = new Rain(); 
       
      }
      
      sunnySound.play();
      sunnySound.loop ();
        
    }
        
     
    void draw() {
    
     fill(255, 253, 227, 80);
     rect(-5, -5, width + 5, height + 5);
      
       if (!sunny) {
       fill (104, 158, 181 ,40);
       rect (-5, -5, width + 5, height + 5);}
      
      if (sunny) {
        rays.add(new Ray(mouseX, mouseY, (int) random(width), (int) random(height)));
        if (rainOpacity > 0) {
          rainOpacity -= 2;
        }
      }
      
      Ray remove = null;
      for (Ray ray : rays) {
        ray.fade();
        if (ray.opacity <= 0) {
          remove = ray;
        }
      }
      rays.remove(remove);
      
      for (Rain drop : drops) {
        drop.fall();
      }
      
      if (!((mouseX<width/2) && (mouseY<height/2) && (mousePressed))) {
        strokeWeight(5);
      
      }
      
      rainSound.setGain(mouseX / (float) width * maxGain);
      sunnySound.setGain(mouseY / (float) width * maxGain);
      
    }
    
    void mousePressed() {
      sunny = !sunny;
      if (sunny) {
        fade = 3;
      } else {
        fade = 1;
        rainOpacity = 250;
    
      }
       
      if (!sunny) {
        sunnySound.rewind();
        sunnySound.pause();
        rainSound.loop();
      } else {
        rainSound.rewind(); 
        rainSound.pause();
        sunnySound.loop();
      }
      
      if (sunny) {
        rainEndSound.play();
        
      } else {
        rainEndSound.rewind();
        rainEndSound.pause();
      }
    }
     
    

    code

    tweaks (0)

    about this sketch

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

    license

    advertisement

    Sophie Macnicol

    Final Weather Transformation

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

    This interactive design works on the process of transformation in weather and the ability of it to change at anytime. Move the curser around to create rays of sunshine and sounds, left click for rain to appear and move around to change sounds. Click again at anytime to return back to sunshine.

    Created with the help of the following sketches:

    http://www.openprocessing.org/visuals/?visualID=8669
    http://www.openprocessing.org/visuals/?visualID=21534
    http://www.openprocessing.org/visuals/?visualID=9299

    Note: For some reason the first intial sunshine screen doesn't allow you to to contro

    You need to login/register to comment.