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.

            
              <canvas></canvas>

<div id="Profile">
  <img src="https://s3-us-west-2.amazonaws.com/harriscarney/images/150x150.png"/>
  <span>Harris Carney</span>
</div>

<a href="https://codepen.io/HarrisCarney/pen/JGmqC" target="_blank">Click here for the updated version!</a>
            
          
!
            
              @import url(https://fonts.googleapis.com/css?family=Oswald:300);
@import url(https://fonts.googleapis.com/css?family=Abel);

body {
  margin: 0;
  overflow: hidden;
  background: #E9E9E9;
}

#Profile {
  position: absolute;
  margin: auto;
  top: 0; right: 0; bottom: 0; left: 0;
  width: 150px; height: 150px;
  border-radius: 150px;
}

#Profile:before {
  content: '';
  position: absolute;
  top: -8px; left: -8px;
  width: 162px; height: 162px;
  border-radius: 162px;
  border: 2px solid #BCBCBC;
}

#Profile:after {
  content: '';
  position: absolute;
  top: -13px; left: -13px;
  width: 172px; height: 172px;
  border-radius: 172px;
  border: 2px solid #FF9900;
}

#Profile img {
  border-radius: 150px;
}

#Profile span {
  position: absolute;
  bottom: -60px;
  display: block;
  width: 150px;
  text-align: center;
  font-family: 'Oswald';
  color: #333;
  font-size: 25px;
}

a {
  position: absolute;
  right: 0; top: 0; left: 0;
  text-align: center;
  font-family: 'Abel';
  background: #7ECEFD;
  padding: 6px;
  color: #fff;
  text-decoration: none;
  font-size: 20px;
}


            
          
!
            
              var canvas = $('canvas')[0];
var context = canvas.getContext('2d');

canvas.width = window.innerWidth;
canvas.height = window.innerHeight;

var Dots = [];
var colors = ['#FF9900', '#424242', '#BCBCBC', '#3299BB'];
var maximum = 70;

function Initialize() {
  GenerateDots();

  Update();
}

function Dot() {
  this.active = true;

  this.diameter = Math.random() * 7;

  this.x = Math.round(Math.random() * canvas.width);
  this.y = Math.round(Math.random() * canvas.height);

  this.velocity = {
    x: (Math.random() < 0.5 ? -1 : 1) * Math.random() * 0.7,
    y: (Math.random() < 0.5 ? -1 : 1) * Math.random() * 0.7
  };

  this.alpha = 0.1;
  this.hex = colors[Math.round(Math.random() * 3)];
  this.color = HexToRGBA(this.hex, this.alpha);
}

Dot.prototype = {
  Update: function() {
    if(this.alpha < 0.8) {
      this.alpha += 0.01;
      this.color = HexToRGBA(this.hex, this.alpha);
    }

    this.x += this.velocity.x;
    this.y += this.velocity.y;

    if(this.x > canvas.width + 5 || this.x < 0 - 5 || this.y > canvas.height + 5 || this.y < 0 - 5) {
      this.active = false;
    }
  },

  Draw: function() {
    context.fillStyle = this.color;
    context.beginPath();
    context.arc(this.x, this.y, this.diameter, 0, Math.PI * 2, false);
    context.fill();
  }
}

function Update() {
  GenerateDots();

  Dots.forEach(function(Dot) {
    Dot.Update();
  });

  Dots = Dots.filter(function(Dot) {
    return Dot.active;
  });

  Render();
  requestAnimationFrame(Update);
}

function Render() {
  context.clearRect(0, 0, canvas.width, canvas.height);
  Dots.forEach(function(Dot) {
    Dot.Draw();
  });
}

function GenerateDots() {
  if(Dots.length < maximum) {
    for(var i = Dots.length; i < maximum; i++) {
      Dots.push(new Dot());
    }
  }

  return false;
}

function HexToRGBA(hex, alpha) {
  var red = parseInt((TrimHex(hex)).substring(0, 2), 16);
  var green = parseInt((TrimHex(hex)).substring(2, 4), 16);
  var blue = parseInt((TrimHex(hex)).substring(4, 6), 16);

  return 'rgba(' + red + ', ' + green + ', ' + blue + ', ' + alpha + ')';
}

function TrimHex(hex) {
  return (hex.charAt(0) == "#") ? hex.substring(1, 7) : h;
}

$(window).resize(function() {
  Dots = [];
  canvas.width = window.innerWidth;
  canvas.height = window.innerHeight;
});

Initialize();
            
          
!
999px
Loading ..................

Console