Pen Settings

HTML

CSS

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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

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.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
              
            
!

CSS

              
                canvas {
  border: 1px solid #333;
}
              
            
!

JS

              
                let balls = [];
let white = 200;
let black = 33;
let mess1 = "The invasion of microorganisms";
let mess2 = "that are not normally present";
let mess3 = "and may remain localized or spread is called?";
let answer = "Infection";
window.mobilecheck = function() {
  var check = false;
  (function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))) check = true;})(navigator.userAgent||navigator.vendor||window.opera);
  return check;
};
function setup(){
  createCanvas(windowWidth-24, windowHeight-24);
  background(255, 217, 179);
  randomFunk(64);
}
function draw(){
  live();
  // this is for proformance on moblie may need to be even less
  if(balls.length >= 500){
    balls.splice(0,5);
  }
  displayCounter();
  if (typeof window.orientation !== 'undefined'){
    mobileConditions();
  }else{
    textConditions();
  }    
}

// DISPLAY FUNCTIONS 
// these are the functions that display the TEXT
function displayCounter(){
  let x;
  fill(22)
  rect(0,0,25,25)
  fill(255)
  textSize(12)
  // this is used as an offset for larger numbers
  if(balls.length >= 100){
    x = 2;
  }else{
    x = 8;
  }
  // show the number of microorganisms on the screen
  text(balls.length,x,5,2,15)
}
// text will show in center of canvas
function centerText(txt,offset,sz){
  if(sz === undefined){
    sz = 18
  }
  textSize(sz);
  fill(black);
  text(txt, width/2 - (txt.length*5.2)+1, (height/2 - offset)+1);
  textSize(sz);
  fill(white);
  text(txt, width/2 - txt.length*5.2, height/2 - offset);
}
function textConditions(){
  switch(balls.length){
    case 40:
      centerText("CLICK TO MAKE MORE", -200 )    
    case 42:
    case 43:
    case 44:
    case 45:
    case 46:
      centerText(answer, 0, 32);
      break;   
    case 48:
    case 49:
    case 50:
    case 51:
    case 52:      
      centerText(mess3, 200, 24);
      break;    
    case 54:
    case 55:
    case 56:
    case 57:
    case 58:
      centerText(mess2, 250, 24);
      break;    
    case 60:
    case 61:
    case 62:
    case 63:
    case 64:
      centerText(mess1, 300, 24);
      break;
    case 450:
    case 451:
    case 452:
    case 453:
    case 454:
    case 455:
    case 456:
    case 457:
      centerText("MIGHT WANT TO WAIT!", 0, 32);
      break;
    case 465:
    case 466:
    case 467:
    case 468:
    case 469:
    case 470:
    case 471:
    case 472:
    case 473:
    case 474:
    case 475:
    case 476:
    case 477:
    case 478:
    case 479:
    case 480:
      centerText("Borderline to many.", 50, 32); 
      centerText("Max is 500!", 0, 32);
      break;
         } 
}
function mobileConditions(){
  switch(balls.length){
    case 59:
    case 60:
      centerText("Touch for More", 0);
    case 61:
    case 62:
      centerText(" Or", 25);
    case 63:
    case 64:
      centerText("Watch Them.", 50);
      break;
  }
}
// __________________________
function randomFunk(num){ 
  for(let clicked = 0; clicked < num; clicked++){
    balls.push(new TheFunk(random(width), random(height)));
  }
}
function clickFunk(num){
  for(let clicked = 0; clicked < num; clicked++){
    balls.push(new TheFunk(mouseX,mouseY))
  }
}
function mouseReleased(){
   clickFunk(6)      
}
function live(){
  for(let i = 0; i < balls.length; i++){    
    balls[i].show()
    balls[i].move()
    balls[i].lifeSpan()
    if(balls[i].isOutOfBounds()){     
      balls[i].isDead = true;
    }
    if(balls[i].isDead){     
      balls.splice(i,1);
    }    
  }
}
function TheFunk(x,y){
  this.x = x;
  this.y = y;
  this.isDead = false;
  this.moveSpeed = 3;
  // used for the color red
  this.r = random(200,255);
  // used for alpha 
  this.a = random(30, 200);  
  this.size = random(5,50);
  this.lifeSpan = function(){
    this.size -=0.01
    if(this.size < 0){
      this.isDead = true
    }
  }
  this.isOutOfBounds = function(){
    let radius = this.size / 2;
    if(this.x > 0-radius && this.x > width+radius && this.y > 0-radius && this.y < height+radius){      
      return true;
    }else{  
      return false;
    }
  }
  this.show = function(){
    strokeWeight(2)
    fill(this.r,0,0,this.a)
    ellipse(this.x,this.y,this.size)
  }
  this.move = function(){
    this.x = this.x + random(-this.moveSpeed, this.moveSpeed)
    this.y = this.y + random(-this.moveSpeed, this.moveSpeed)
  }
   
}

              
            
!
999px

Console