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. 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.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

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 Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

              
                <body>
  <canvas id="c"></canvas>  
</body>
              
            
!

CSS

              
                body {
		margin: 0;
		padding: 0;
		height: 100%;
		width: 100%;
	}

canvas {
	  display: block; 
	  position: absolute;
	  background: -moz-radial-gradient(center, ellipse cover,  rgba(171,209,234,0.5) 0%, rgba(125,185,232,0.75) 100%); /* FF3.6+ */
	  background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%,rgba(171,209,234,0.5)), color-stop(100%,rgba(125,185,232,0.75))); /* Chrome,Safari4+ */
	  background: -webkit-radial-gradient(center, ellipse cover,  rgba(171,209,234,0.5) 0%,rgba(125,185,232,0.75) 100%); /* Chrome10+,Safari5.1+ */
	  background: -o-radial-gradient(center, ellipse cover,  rgba(171,209,234,0.5) 0%,rgba(125,185,232,0.75) 100%); /* Opera 12+ */
	  background: -ms-radial-gradient(center, ellipse cover,  rgba(171,209,234,0.5) 0%,rgba(125,185,232,0.75) 100%); /* IE10+ */
	  background: radial-gradient(ellipse at center,  rgba(171,209,234,0.5) 0%,rgba(125,185,232,0.75) 100%); /* W3C */
	  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#80abd1ea', endColorstr='#bf7db9e8',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
	  

	}
              
            
!

JS

              
                //setTimeoue needed to get full screen canvas
setTimeout(function() {
  
function resizeCanvas() {
  ch = window.innerHeight;
  cw = window.innerWidth;
  c.width = cw;
  c.height = ch;    
};
  

var cw, ch,
    c = document.getElementById('c'),
    ctx = c.getContext('2d'),
    parts = [],
    globalTick = 0,
    rand = function(min, max){
        return Math.floor( (Math.random() * (max - min + 1) ) + min);
    };
  
    

var Part = function(){
  this.reset();
};

Part.prototype.reset = function(){
  this.startRadius = rand(1, 10);
  // this.startRadius = rand(20, 25);
  this.radius = this.startRadius;
  this.x = rand(0, c.width);
  this.y = rand(0, c.height);
  this.hue = 210;
  this.saturation = rand(40, 60);
  this.lightness = rand(70, 80);
  this.startAlpha = 0.5;
  this.alpha = this.startAlpha;
  this.decayRate = .3;  
  this.startLife = rand(20, 30);
  // this.startLife = 15;
  this.life = this.startLife;
  this.lineWidth = 1;
}
    
Part.prototype.update = function(){  
  this.alpha = this.startAlpha * (this.life / this.startLife);
  this.radius = this.radius+1;
  this.life -= this.decayRate;  
};
  
Part.prototype.render = function(){
  ctx.beginPath();
  ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2, false);
  ctx.fillStyle = ctx.strokeStyle = 'hsla('+this.hue+', '+this.saturation+'%, '+this.lightness+'%, '+this.alpha+')';
  ctx.lineWidth = this.lineWidth;
  ctx.fill();
  // ctx.stroke();
};

var createParts = function(){
  parts.push(new Part());
};
  
var updateParts = function(){
  var i = parts.length;
  while(i--){
    if (parts[i].life < 0){
      parts.splice(i, 1)
    }
    parts[i].update();
  }
};

var renderParts = function(){
  var i = parts.length;
  while(i--){
    parts[i].render();
  }   
};
    
var clear = function(){
  ctx.globalCompositeOperation = 'destination-out';
  ctx.fillStyle = 'hsla(0, 0%, 0%, 1)';
  ctx.fillRect(0, 0, cw, ch);
  ctx.globalCompositeOperation = 'source-over';
};

//Run through the first iterations to get all the parts ready for rendering.
for (i = 0 ; i < 200 ; i++){
    if (globalTick % 6 == 0){
      createParts();
    }
    updateParts();
    globalTick++;
}
     
var loop = function(){
  window.requestAnimFrame(loop, c);
      clear();

      if (globalTick % 6 == 0){
        createParts();
      }

  		updateParts();
  		renderParts();
  		globalTick++;


};
  
window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){window.setTimeout(a,1E3/60)}}();

  
resizeCanvas();
window.onresize = resizeCanvas;  
  
loop();
  
}, 1);
              
            
!
999px

Console