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

              
                <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1200px" height="400px" viewBox="0 0 1200 400" xml:space="preserve">
  <!-- bg -->
  <g class="funnel_bg">
    <rect x="0" y="0" width="100%" height="100%"/>
  </g>

  <g class="funnel_paths">
  </g>

  <g class="funnel_cells">
  </g>

  <g class="funnel_ring_cells">
  </g>

  <!-- mask -->
  <g class="funnel_mask">
    <path fill="#131415" d="M0,371.5V400h1200V270.4C678.366,245.2,392.527,380.5,0,371.5z M0,0
      c370.708,134.199,779.049,89.399,1200,144.199V0H0z"/>
    <linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="-205" y1="759.9831" x2="996" y2="759.9831" gradientTransform="matrix(1 0 0 1 205 -574)">
      <stop  offset="0" style="stop-color:#FFFFFF;stop-opacity:0"/>
      <stop  offset="1" style="stop-color:#FFFFFF"/>
    </linearGradient>
    <path fill="none" stroke="url(#SVGID_1_)" stroke-width="2" stroke-linecap="round" stroke-miterlimit="10" d="M1200,270.312
      C678.799,245.143,393.199,380.275,1,371.286 M1,0.25c370.4,134.031,778.4,89.288,1199,144.019"/>
  </g>
</svg>
              
            
!

CSS

              
                body {
  background-color: #131415;
}
svg {
  display: block;
  margin: 0 auto;
}
.funnel_paths path {
  fill: transparent;
  stroke: transparent;
}
.funnel_ring_cells circle { 
  fill: #f2f2f2; 
}
.funnel_ring_cells circle + circle {
  fill: #121314;
}
.funnel_cells {
}
.funnel_cells circle {
  fill: rgba(255,255,255,.1);
}
              
            
!

JS

              
                var motion_path_animate_time = 20; // lower makes more bouncey
var cell_animation_time = 8; // left to right time, in seconds
var cell_animation_time_variance = 3; // cell_animation_time +/- this, in seconds
var total_cells = 60; // how many cells, more may hamper frame rate (includes rings)
var total_ring_cells = 20; // total amount of rings, must be smaller than total cells
// random number
function randomNumber(max) {
  return Math.floor(Math.random() * max) + 1;
}
// set up
var cells_html = "";
var ring_cells_html = "";
var motion_paths_html = "";
var mp = '<path id="mp_{{id}}" d="M-20 10  Q 400 140, 800 130 Q 1000 130, 1220 160"><animate dur="{{duration}}s" begin="{{begin}}s" repeatCount="indefinite" attributeName="d" values="M-20 360 Q 400 320, 800 260 Q 1000 230, 1220 255; M-20 10  Q 400 140, 800 130 Q 1000 130, 1220 160; M-20 360 Q 400 320, 800 260 Q 1000 230, 1220 255;"/></path>';
var cell = '<g><animateMotion dur="{{duration}}s" repeatCount="indefinite" begin="{{begin}}s"><mpath xlink:href="#mp_{{id}}"/></animateMotion><circle cx="0" cy="0" r="10"></circle></g>';
var ring_cell = '<g><animateMotion dur="{{duration}}s" repeatCount="indefinite" begin="{{begin}}s"><mpath xlink:href="#mp_{{id}}"/></animateMotion><circle cx="0" cy="0" r="10"></circle><circle cx="0" cy="0" r="8"></circle></g>';
//
var cell_animation_time_min = cell_animation_time - cell_animation_time_variance;
var cell_animation_time_max = cell_animation_time + cell_animation_time_variance;
var cell_animation_time_max_diff = cell_animation_time_max - cell_animation_time_min;
// generate
for (var i = 0; i < total_cells; i++) {
  var this_mp_begin = randomNumber(motion_path_animate_time * 100) / -100;
  var this_mp_html = mp.replace("{{id}}",(i+1)).replace("{{begin}}",this_mp_begin).replace("{{duration}}",motion_path_animate_time);
  motion_paths_html += this_mp_html;
  //
  var this_cell_begin = randomNumber(100) / (cell_animation_time * -1);
  var this_cell_animate_time = (randomNumber(cell_animation_time_max_diff * 100) + (cell_animation_time_min * 100)) / 100;
  var this_cell_html = '';
  if (i < (total_cells - total_ring_cells)) {
    this_cell_html = cell.replace("{{id}}",(i+1)).replace("{{begin}}",this_cell_begin).replace("{{duration}}",this_cell_animate_time);
    cells_html += this_cell_html;
  } else {
    this_cell_html = ring_cell.replace("{{id}}",(i+1)).replace("{{begin}}",this_cell_begin).replace("{{duration}}",this_cell_animate_time);
    ring_cells_html += this_cell_html;
  }
}
// append
document.querySelectorAll(".funnel_paths")[0].innerHTML += motion_paths_html;
document.querySelectorAll(".funnel_cells")[0].innerHTML += cells_html;
document.querySelectorAll(".funnel_ring_cells")[0].innerHTML += ring_cells_html;
              
            
!
999px

Console