Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <canvas id=c></canvas>
<div id=overlay></div>
<p> followers on codepen: thank <span>you</span> so much! </p>
              
            
!

CSS

              
                canvas {
  position:absolute;
  top: calc( 50vh - 200px );
  left: calc( 50vw - 300px );
  
  background-color: #111;
}
#overlay {
  position:absolute;
  top: calc( 50vh - 200px );
  left: calc( 50vw - 300px );
  width: 600px;
  height: 400px;
  
  background: radial-gradient( ellipse 300px 200px at 300px 200px,  rgba( 0, 0, 0, 0 ), rgba( 0, 0, 0, .2 ), rgba( 0, 0, 0, .5 ) );
}
body {
  background-color: #090909;
}
p {
  font: 20px Verdana;
  color: hsl( 230, 50%, 40% );
  text-shadow: 0 0 2px hsl( 230, 50%, 40% );
  
  position: absolute;
  top: calc( 50vh + 160px );
  left: 0;
  margin: 0 0;
  width: 100vw;
  text-align: center;
}
span {
  
  font-size: 24px;
  color: hsl(230, 50%, 55%)
}
              
            
!

JS

              
                /*
 * This is my 100 followers special!
 * Thanks to everyone for showing
 * interesting in what I do, I really
 * apreciate it! Hope you enjoy the pen!
 *
 */

var w = c.width = 600,
    h = c.height = 400,
    ctx = c.getContext( '2d' ),
    
    particleCount = 300,
    spawnProb = 1,
    hueStart = 200,
    hueEnd = 260,
    minSize = 5,
    maxSize = 15,
    speedMultiplier = .1,
    alphaChanger = .05,
    
    one = {
      x: 90, w: 55,
      y: 90, h: 210
    },
    r1 = 50,
    r2 = 90,
    f0 = { // first zero
      x: 252, 
      y: 200,
    },
    s0 = { // second zero
      x: 410, 
      y: 200,
    }
    
    particles = [],
    squareR1 = r1 * r1,
    squareR2 = r2 * r2,
      
    leftest = one.x,
    rightest = s0.x + r2,
    highest = Math.min( one.y, f0.y - r2, s0.y - r2 ),
    lowest = Math.max( one.y + one.w, f0.y + r2, s0.y + r2 ) + maxSize,
    
    isInText = function( x, y ) {
      
      // check if point is in 1, which is a rectangle
      if( !( x < one.x || x > one.x + one.w ||
             y < one.y || y > one.y + one.h) )
        	return true;
      
      // check if point is in the 0s
      else {
        
        var dX = x - f0.x, // distance in the X from First zero
            dY = y - f0.y, // distance in the Y from First zero
            squareDist = dX * dX + dY * dY;
        
        if( squareDist > squareR1 && squareDist < squareR2 )
          return true;
        
            dX = x - s0.x; // second zero
            dY = y - s0.y;
            squareDist = dX * dX + dY * dY;
        
        if( squareDist > squareR1 && squareDist < squareR2 )
          return true;
      }
      
      return false;
    };

function loop() {
  
  window.requestAnimationFrame( loop );
  
  ctx.globalCompositeOperation = 'source-over';
  ctx.fillStyle = '#111';
  ctx.fillRect( 0, 0, w, h );
  ctx.globalCompositeOperation = 'lighter';
  
  step( true );
}
function step( render ) {
  
  if( particles.length < particleCount && Math.random() < spawnProb )
    particles.push( new Particle );
  
  particles.map( function( par ) { par.step( render ); } );
  
}

function Particle() {
  
  this.reset();
}
Particle.prototype.reset = function() {
  
  this.bigness = 0;
  this.hue = rand( hueStart, hueEnd ) |0;
  this.size = rand( minSize, maxSize ) |0;
  
  this.x = rand( leftest, rightest ) |0;
  this.y = highest - this.size;
  
  this.gradient = ctx.createRadialGradient( 0, 0, 0, 0, 0, this.size * 2);
  this.gradient.addColorStop( 0, 'hsla(hue, 80%, 50%, .8)'.replace( 'hue', this.hue ) );
  this.gradient.addColorStop( .5, 'hsla(hue, 80%, 50%, .8)'.replace( 'hue', this.hue ) );
  this.gradient.addColorStop( 1, 'hsla(hue, 80%, 50%, .0)'.replace( 'hue', this.hue ) );
}
Particle.prototype.step = function( render ) {
  
  this.y += speedMultiplier * this.size;
  
  if( this.y - this.size > lowest ) this.reset();
  
  if( isInText( this.x, this.y ) ){
    
    if( this.bigness < 1 ) this.bigness += alphaChanger; 
  } else if( this.bigness > 0 ) this.bigness -= alphaChanger;
  
  if( render && this.bigness > 0 ) {
    
    ctx.fillStyle = this.gradient;
    ctx.translate( this.x, this.y );
    ctx.scale( this.bigness, this.bigness );
    ctx.beginPath();
    ctx.arc(0, 0, this.size * 2, 0, Math.PI * 2);
    ctx.fill();
    ctx.scale( 1/this.bigness, 1/this.bigness );
    ctx.translate( -this.x, -this.y );
    
  }
}


function rand( min, max ) {
	
  return Math.random() * ( max - min ) + min;
}

for( var n = 0; n < 200; ++n )
  step( false ); // just to have the thing already loaded


loop();

// boundary test 
/*
ctx.fillStyle = ctx.strokeStyle = 'white';
ctx.fillRect( one.x, one.y, one.w, one.h );
ctx.beginPath();
ctx.arc( f0.x, f0.y, r2, 0, Math.PI * 2, true);
ctx.arc( f0.x, f0.y, r1, 0, Math.PI * 2, false);
ctx.fill();
ctx.beginPath();
ctx.arc( s0.x, s0.y, r2, 0, Math.PI * 2, true);
ctx.arc( s0.x, s0.y, r1, 0, Math.PI * 2, false);
ctx.fill();
*/
              
            
!
999px

Console