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.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

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.

            
              <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18">
  <path class="cls-1" d="M15,7,9,11,3,7,9,3ZM9,7,3,11l6,4,6-4ZM9,3V7M3,7v4m6,0v4m6-8v4" />
</svg>

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 11 18">
  <path class="cls-1" d="M8.8,6.2a4,4,0,1,0,0,5.7"/>
</svg>

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 18">
  <circle class="cls-1" cx="6" cy="9" r="4" />
</svg>

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 18">
  <path class="cls-1" d="M9,9a4,4,0,0,1-4,4H2V5H5A4,4,0,0,1,9,9Z"/>
</svg>

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 11 18">
  <path class="cls-1" d="M8,13H2V5H8M6,9H2"/>
</svg>

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 11 18">
  <path class="cls-1" d="M2,10H6A2.5,2.5,0,0,0,6,5H2v8"/>
</svg>

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 11 18">
  <path class="cls-1" d="M8,13H2V5H8M6,9H2"/>
</svg>

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 11 18">
  <polyline class="cls-1" points="2 13 2 5 9 13 9 5"/>
</svg>

            
          
!
            
              body {
  display: -webkit-flex;
  display: flex;
  flex-wrap: wrap;
  margin: 0;
  overflow: hidden;
  background: black;
}

svg {
  height: 36px;
}

/* .glyph--box { width: 36px; }
.glyph--c { width: 22px; } */

svg path,
svg polyline,
svg circle {
  fill: none;
  stroke: white;
  stroke-linecap: round;
  stroke-linejoin: round;
}
            
          
!
            
              var windowWidth = window.innerWidth;
var windowHeight = window.innerHeight;
var origSVGs = selectAll('svg');
var svgHeight = origSVGs[0].clientHeight;


//--------------------------------------//

function Glyph( svg ) {
  this.svg = svg;
  this.shapeNode = svg.querySelector('path') ||
    svg.querySelector('circle') ||
    svg.querySelector('polyline');
  var rect = svg.getBoundingClientRect();
  this.x = rect.left + svg.clientWidth/2;
  this.y = rect.top + svgHeight/2;
  this.screenCenterD = getDistance( this.x, this.y, window.innerWidth/2, window.innerHeight/2 );
  var l = Math.round( this.y / window.innerHeight * 100 );
  var h = Math.round( this.screenCenterD );
  this.render( 0 );
}

Glyph.prototype.render = function( theta ) {
  var offset = this.screenCenterD / 50;
  var strokeWidth = Math.sin( -theta + offset ) * 1.8 + 2.1;
  // console.log( strokeWidth )
  this.shapeNode.setAttribute( 'stroke-width', strokeWidth );
};

//----



var fragment = document.createDocumentFragment();
var wordmarkWidth = 0;
origSVGs.forEach( function( svg ) {
  wordmarkWidth += svg.clientWidth;
})

var rowCount = Math.ceil( windowHeight / svgHeight );
var copyCount = rowCount * windowWidth / wordmarkWidth;


// copy over lots of times
for ( i=0; i < copyCount; i++ ) {
  var svgs = origSVGs.map( mapCloneSVG );
  svgs.forEach(  eachAppendFragment);
}

function mapCloneSVG( svg ) {
  return svg.cloneNode( true );
}

function eachAppendFragment( svg ) {
  fragment.appendChild( svg );
}

document.body.appendChild( fragment );


var allSVGs = selectAll('svg');

var glyphs = allSVGs.map( function( svg ) {
  return new Glyph( svg );
});

var t = 0;

function animate() {
  t += 0.15;
  //console.log( t );
  for ( var i=0; i < glyphs.length; i++ ) {
    glyphs[i].render( t );
  }
  requestAnimationFrame( animate );
}

animate();

//--------------------------------------//

// select & convert to array
function selectAll( selector ) {
  var elems = document.querySelectorAll( selector );
  // convert to array
  return Array.prototype.slice.call( elems );
}

function getDistance( x1, y1, x2, y2 ) {
  var dx = x2 - x1;
  var dy = y2 - y1;
  return Math.sqrt( dx*dx + dy*dy );
}
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console