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 id="outer" width="100%" height="100%" viewBox="0 0 1400 1400" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">

  <title>psychedelic clock</title>
  <defs>
    <!--logo-->
    <svg id="logo" viewBox="0 0 1432 970" preserveAspectRatio="xMidYMid meet">
      <title>xz logo</title>
      <defs>
        <mask id="xz-mask">
          <path fill="#808080" d="m 125,375 0,168 195,41 0,-141 z"/>
          <g fill="#333333">
            <path d="m 0,741 54,-15 180,16 -67,12 z"/>
            <path d="m 221,680 -99,27 198,20 112,-20 z"/>
            <path fill="#4d4d4d" d="m 360,406 -139,274 211,27 149,-217 z"/>
            <path d="m 1058,422 -602,165 223,40 551,-95 z"/>
          </g>
          <g fill="white">
            <path d="m 125,375 -71,63 0,144 -54,32 1,127 54,-15 0,142 71,3 0,-165 95,-26 139,-274 -235,137 z"/>
            <path	d="m 1058,2 -386,224 -216,361 602,-165 z"/>
          </g>
          <g fill="#808080">
            <path d="m 126,706.1 0,164.9 194.1,-2.3 0,-141.7 z"/>
            <path d="m 1058,2 0,419.9 172,110.3 0,-297.6 z"/>
          </g>
        </mask>
      </defs>
      <g id="screen" mask="url(#xz-mask)">
        <rect fill="whitesmoke"	width="100%" height="100%"/>
      </g>
    </svg>
    
    <!--browser support info-->
    <g id="not-supported">
        <text >Your browser doesn't support animated SVG.</text>
        <set attributeName="visibility" to="hidden" />
    </g>
  </defs>
  
  <!-- background color amination is now done with CSS -->
  <!--<rect width="100%" height="100%" fill="transparent">-->
    <!--<animate attributeName="fill" dur="173" values="#0cf; #0c5; #f60; #60f; #0cf" repeatCount="indefinite" />-->
  <!--</rect>-->
  
  <g id="clock" transform="translate(700 700) scale(2)" fill="white" stroke="#0cf">
    <animate attributeName="stroke" dur="173" values="#0cf; #0c5; #f60; #60f; #0cf" repeatCount="indefinite" />
    <animateTransform attributeName="transform" type="scale" dur="113s" calcMode="spline" keySplines=".2 0 .8 1; .1 0 .9 1; .3 0 .7 1; .2 0 .8 1" values="1 1; .5 1.5; 1 1; 1.5 .5; 1 1" repeatCount="indefinite" additive="sum" />
    <animateTransform attributeName="transform" type="scale" dur="151s" calcMode="spline" keySplines=".1 0 .8 1; .2 0 .9 1; .1 0 .8 1" values="1 1; 2 2; .3 .3; 1 1" repeatCount="indefinite" additive="sum" />
    <circle r="172" stroke-width="15" stroke-dasharray="5 85"/>
    <g id="clockA" fill="none">
      <path id="hH" d="M0 0 v-77" stroke-width="10" stroke-linecap="round">
        <animateTransform id="aH" attributeName="transform" type="rotate" values="0;3" dur="360s" repeatCount="indefinite" begin="aS.begin" accumulate="sum" additive="sum"/>
        <animate attributeName="stroke-width" dur="311s" calcMode="spline" keySplines=".1 0 .8 1; .2 0 .7 1; .3 0 .6 1" values="10; 23; 3; 10" repeatCount="indefinite" />
      </path>
      <path id="hM" d="M0 0 v-115" stroke-width="7" stroke-linecap="round">
        <animateTransform id="aM" attributeName="transform" type="rotate" values="0;6" dur="60s" repeatCount="indefinite" begin="aS.begin" accumulate="sum" additive="sum" />
      </path>
      <path id="hS" d="M0 0 v-135" stroke-width="4" stroke-linecap="round">
        <animateTransform id="aS" attributeName="transform" type="rotate" values="0;6" keyTimes="0;1" calcMode="discrete" dur="1s" repeatCount="indefinite" accumulate="sum" additive="sum"/>
      </path>
    </g>
    <circle r="10" stroke-width="5">
      <animate attributeName="r" type="scale" dur="73s" calcMode="spline" keySplines=".4 0 .8 1; .2 0 .7 1; .3 0 .6 1" values="10; 33; 5; 10" repeatCount="indefinite" />
      <animate attributeName="stroke-width" dur="97s" calcMode="spline" keySplines=".4 0 .8 1; .2 0 .7 1; .3 0 .6 1; .2 0 .7 1" values="5; 13; 3; 10; 5" repeatCount="indefinite" />
    </circle>
  </g>
  
  <a xlink:href="http://xzed.me" xlink:show="new">
    <use xlink:href="#logo" y="1310" x="1300" width="100" height="100"/>
    <text x="10" y="1390" >xzed.me</text>
  </a>
  
  <use xlink:href="#not-supported" y="700" x="700" text-anchor="middle" font-size="50"/>
</svg>

              
            
!

CSS

              
                * {
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  min-height: 100%;
  overflow: hidden;
}


body {
  background-color: #0cf;
  animation: colors;
  animation-duration: 173s;
  animation-iteration-count: infinite;
  animation-timing-function: linear;
}

#outer {
  max-height: 100vh;
}

a {
  font-family: sans-serif;
  font-size: 26px;
  fill: whitesmoke;
}

@keyframes colors {
  0% {
    background-color: #0cf;
  }
  25% {
    background-color: #f60;
  }
  50% {
    background-color: greenyellow;
  }
  75% {
    background-color: #0c6;
  }
  100% {
    background-color: #0cf;
  }
}

// to set the "not supported" message initially to opacity 0
// prevents it from shortly flare up in browsers that support it
#not-supported {
  font-family: sans-serif;
  font-size: 50px;
  font-weight: bold;
  fill: orangered;
  
  opacity: 0;
  animation: fade-in;
  animation-duration: 30s;
  animation-timing-function: ease-in;
}

@keyframes fade-in {
  2% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}
              
            
!

JS

              
                // JS is only needed for setting the initial time
// animation is done natively via SVG

var secondsHand,
    secondsHandAni,
    minutesHand,
    minutesHandAni,
    hoursHand,
    hoursHandAni;

function init() {
    secondsHand = document.getElementById('hS'),
    secondsHandAni = document.getElementById('aS'),
    minutesHand = document.getElementById('hM'),
    minutesHandAni = document.getElementById('aM'),
    hoursHand = document.getElementById('hH'),
    hoursHandAni = document.getElementById('aH'),
    setTime();
}

function setAndGetSeconds() {
  var seconds = new Date().getSeconds();
  secondsHand.setAttribute('transform', 'rotate(' + (seconds * 6) + ')');
  secondsHandAni.beginElement();
  return seconds;
}

function setTime() {
  var now = new Date(),
      H = now.getHours(),
      M = now.getMinutes(),
      seconds = setAndGetSeconds(),
      h = H + round(M / 60 + seconds / 3600);
  
  minutesHand.setAttribute(
    'transform',
    'rotate(' + (M + round(seconds / 60)) * 6 + ')'
  );
  
  h = (H >= 12) ? h - 12 : h;

  hoursHand.setAttribute('transform', 'rotate(' + (h * 30) + ')');
}

function round(value) {
  var q = 100;
  return Math.round(value * q) / q;
}

window.onload = init;


              
            
!
999px

Console