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. 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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                
              
            
!

CSS

              
                html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  background: linear-gradient(#36383f, #2b2b2b);
}

              
            
!

JS

              
                /************************************
  This codepen is part of the svg.js
  advent calendar. You can find all
  the pens at twitter: @svg_js
*************************************/

const width = window.innerWidth
const height = window.innerHeight - 10

// Create SVG and set viewbox so that
// we zoom into the point 0,0
const canvas = SVG()
  .addTo('body')
  .size(width, height)

function perspective ( i, p ) {
  return width / ( 0.8 * ( i - p ) )
}

const aspect = width / height
const cx = width / 2
const cy = height / 2

canvas.ellipse({ x: cx, y: cy, rx: 2, ry: 2  })

const n = 50
for ( let i = 0 ; i < n ; i ++ ) {
  
  // Go through the rects
  const width = perspective ( i, 0 )
  const height = width / aspect

  // Work out the 
  const lastWidth = perspective ( i, 1 )
  const lastHeight = lastWidth / aspect
  
  // Go through the 
  const rect = canvas
    .rect({ x: cx - width / 2 , y: cy - height / 2, width, height })
    .stroke( 'white' )
    .fill( 'none' )  
    .opacity( 0.8 * Math.cos( i / n * Math.PI  ) )
    
  rect.animate()
    .ease( t => t )
    .loop()
    .x( cx - lastWidth / 2 )
    .y( cy - lastHeight / 2 )
    .width ( lastWidth )
    .height( lastHeight )

   rect.animate( 3000, 50 * i, 'now' )
    .ease( t => t )
    .loop()
    .rotate( 180 )
}


              
            
!
999px

Console