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
  height 100%
  margin 0
  background-color #0
  transition background-color .5s
svg
  width 100%
  height 100%
  vertical-align top
  fill blue
  // stroke white
  stroke-width 5
  stroke-dasharray 20
  transition fill .5s
path
  cursor pointer
              
            
!

JS

              
                function create(type){
  return document.createElementNS("http://www.w3.org/2000/svg", type)
}
let w // wiewport width
let h // wiewport height
let diag // diagonal
let time = 0 // time from script beginning
const init = Date.now()
const svg = create("svg")
let count = 5
document.body.appendChild(svg)
function createCircle(cx,cy,r){
  return ` M ${cx} ${cy}
    m ${-r}, 0
    a ${r},${r} 0 1,1 ${r * 2},0
    a ${r},${r} 0 1,1 ${-r * 2},0 `
}

const path = create('path')
path.setAttribute('fill-rule', 'evenodd')

svg.appendChild(path)
const radius = 100
const min = .2
function draw() {
  const circles = []
  for(let i = 0; i < count; i++) {
    const ii = i / count + time / count * 2/3
    const ang = ii * Math.PI * 2
    const cos = Math.cos(ang)
    const sin = Math.sin(ang)
    const c = 1/Math.tan(ang / 2)
    const x = cos * radius
    const y = sin * radius
    circles.push([w/2 + x, h / 2 + y + 30 * c, 30 * c])
  }
  if(Math.floor(time * 2/3) % 2)
   circles.push([w/2, h / 2, diag / 2])
  
  path.setAttribute("d", circles.map(c => createCircle(...c)).join(' '))
  const r = -time * 70
  path.setAttribute('transform', `rotate(${r}, ${w/2}, ${h/2})`)
}

function loop() {
  time = (Date.now() - init) / 1000
  draw()
  window.requestAnimationFrame(loop)
}

function resize() {
  w = window.innerWidth
  h = window.innerHeight
  diag = Math.hypot(w, h)
  draw()
}

window.addEventListener('wheel', e => {
  e.preventDefault()
  count = Math.max(1, count + Math.sign(e.deltaY))
  draw()
})
path.addEventListener('click', (e) => {
  e.stopPropagation()
  svg.style.fill = `hsl(${Math.random()*360},100%,${Math.random()*20+30}%)`
})
path.dispatchEvent(new Event('click'))
document.body.addEventListener('click', (e) => {
  e.stopPropagation()
  document.body.style.backgroundColor = `hsl(${Math.random()*360},100%,${Math.random()*20}%)`
})
window.addEventListener('resize', resize)
resize()
loop()
              
            
!
999px

Console