cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              var weather = true;
var n=2, n1=200;
var x,y;



function setup() {
  createCanvas(windowWidth,windowHeight);

}

function draw() {
  
  
  //Rainy day
  if(weather) {
    
    background(random(150,255),90);
    fill("#f3f7f8")

      //RAIN
      for(var i=0; i< 15; i++)  {
        var randomX = random(0,width);
        var randomY = random(0,height);
        stroke(255);
        line(randomX,randomY, randomX,0);
        fill(255);
        rect(randomX,randomY, 1,40);
      }

    
      //SCENERY
      //tree
      noStroke();
      ellipseMode(CENTER); 
      fill("#805a3d")
      rectMode(CENTER)
      rect(width/2,height-100,30,200)
      fill("#47c213")
      ellipse(width/2-40,height-200, 50,50)
      ellipse(width/2,height-200, 50,50)
      ellipse(width/2+40,height-200, 50,50)
      ellipse(width/2-20,height-230, 50,50)
      ellipse(width/2+20,height-230, 50,50)
      ellipse(width/2,height-270, 50,50)

      //land
      fill("#333333");
      ellipseMode(CENTER);
      ellipse(width/2,height*1.8, width*2,height*2)
 
    

      //TEXT
      noStroke();
      fill(255);
      textSize(80);
      textFont("futura");
      textAlign(CENTER)
      text("Rainy day",width/2,height/2-70)
 
  } 
  
  //Sunny day
  else {
      background(330,270, 130, 12);
      fill(322,0,0,200);
      stroke(400,100);
      x=width/2;
      y=60;

      // change direction in 65% of the cases
      if(Math.random()>13){
        x+=noise(n);
        y+= noise(n1);  
      }else{
        x-=noise(n1);
        y-=noise(n);
      }

      //circle
      push();
      translate(x, y);
      rotate(n1);
      ellipse(-10,10, 10,10);
      pop();

      //circle 1
      push();
      translate(x,y);
      rotate(n,x);
      ellipse(-50,3, 1,290);
      pop();

      n+=1.03;
      n1+=1.98;
      background(330,270, 130, 22);

      checkEdges();
    }
}


function checkEdges(){
  if(x>width){
    x=0;
  }
  if(x<0){
    x=width;
  }
  if(y>height){
    y=0;
  }
  if(y<0){
    y=height;
  }
  
  //TEXT
  noStroke();
  textSize(80);
  fill("#f14646")
  textFont("futura");
  textAlign(CENTER)
  text("Sunny day",width/2,height/2-70)

  //tree
  ellipseMode(CENTER); 
  fill("#805a3d")
  rectMode(CENTER)
  rect(width/2,height-100,30,200)
  fill("#49c846")
  ellipse(width/2-40,height-200, 50,50)
  ellipse(width/2,height-200, 50,50)
  ellipse(width/2+40,height-200, 50,50)
  ellipse(width/2-20,height-230, 50,50)
  ellipse(width/2+20,height-230, 50,50)
  ellipse(width/2,height-270, 50,50)
  //SCENERY

  fill("#47c213");
  ellipseMode(CENTER);
  ellipse(width/2,height*1.8, width*2,height*2)

}

function mouseClicked() {
  
  background(255);
  
  if(weather) {
    weather = false;
  }else {
    weather = true;
  }
  
}





function windowResized() {
  resizeCanvas(windowWidth, windowHeight);
}

            
          
!
999px
Loading ..................

Console