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

              
                <html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0">
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

	<title>Tomorrow Today</title>
	</head>
<body>

<canvas id="c" width="900" height="700"></canvas>



</body>
</html>
              
            
!

CSS

              
                canvas{
	background-color: #eee;
	width: 1000px;
	margin: auto;
}

body{
	margin: 0;
	background-color: #bacfba;
}



              
            
!

JS

              
                (function() {
  var lastTime = 0;
  var vendors = ['webkit', 'moz'];
  for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
    window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
    window.cancelAnimationFrame =
      window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame'];
  }

  if (!window.requestAnimationFrame)
    window.requestAnimationFrame = function(callback, element) {
      var currTime = new Date().getTime();
      var timeToCall = Math.max(0, 16 - (currTime - lastTime));
      var id = window.setTimeout(function() {
          callback(currTime + timeToCall);
        },
        timeToCall);
      lastTime = currTime + timeToCall;
      return id;
    };

  if (!window.cancelAnimationFrame)
    window.cancelAnimationFrame = function(id) {
      clearTimeout(id);
    };
}());

var main_canvas,
  main_context,
  canvasWidth,
  canvasHeight,
  isPressed = false,
  rad = 6,
  spd = 20;
//
var items = [],
  // ||||| Change itemCount to add more particles |||||
  itemCount = 620,
  itemW,
  itemH;

var colorArr = ['#EC008B', '#A42B39', '#40bbff', '#86d300', '#F6893E', '#CE118C', '#FFF100', '#ED1847', '#44270d'];

window.onload = function() {
  start();
}

function start() {
  //init vars
  main_canvas = document.getElementById("c");
  main_context = main_canvas.getContext("2d");
  canvasHeight = main_canvas.height;
  canvasWidth = main_canvas.width;
  addItems();
  //go time
  initTimer();

}

function initTimer() {
  window.requestAnimationFrame(initTimer);
  build();
}

function build() {
  // main_context.clearRect(0,0,main_canvas.width, main_canvas.height);
  update();
}

function addItems() {
  for (var i = 0; i < itemCount; i++) {
    var itm = {};
    itm.x = Math.floor(Math.random() * canvasWidth);
    itm.y = Math.floor(Math.random() * canvasHeight);
    //randomizes colors
    // itm.color = colorArr[Math.floor(Math.random() * colorArr.length)]

    //keeps colors in order
    itm.color = colorArr[i % colorArr.length]

    items.push(itm);
  }
}

function update() {
  var tgt;
  for (var i = 0; i < items.length; i++) {
    obj = items[i];
    if (i < items.length - 1) {
      tgt = items[i + 1]
    } else {
      tgt = items[0];
    }
    obj.x += (tgt.x - obj.x) / spd;
    obj.y += (tgt.y - obj.y) / spd;
  }

  draw();
}

function draw() {
  var obj;
  var color;
  for (var i = 0; i < items.length; i++) {
    obj = items[i];
    //
    main_context.fillStyle = obj.color;
    main_context.strokeStyle = obj.color;
    main_context.lineWidth = .15;
    //
    main_context.beginPath();
    main_context.arc(obj.x, obj.y, rad*(Math.random()), 0, Math.PI*2, false);
    main_context.fill();

    main_context.moveTo(obj.x, obj.y);
    if (i < items.length - 1) {
      main_context.lineTo(items[i + 1].x, items[i + 1].y);
    } else {
      main_context.lineTo(items[0].x, items[0].y);
    }
    main_context.stroke();

  }

}
              
            
!
999px

Console