cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

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.

            
              <button id="reset">Reset</button>

<svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg">
  <title>HTML5 Logo</title>
  <g id="target" class="transition">
    <polygon fill="#E44D26" points="107.644,470.877 74.633,100.62 437.367,100.62 404.321,470.819 255.778,512 			"/>
    <polygon fill="#F16529" points="256,480.523 376.03,447.246 404.27,130.894 256,130.894 			"/>
    <polygon fill="#EBEBEB" points="256,268.217 195.91,268.217 191.76,221.716 256,221.716 256,176.305 255.843,176.305 142.132,176.305 143.219,188.488 154.38,313.627 256,313.627"/>
    <polygon fill="#EBEBEB" points="256,386.153 255.801,386.206 205.227,372.55 201.994,336.333 177.419,336.333 156.409,336.333 162.771,407.634 255.791,433.457 256,433.399"/>
    <path d="M108.382,0h23.077v22.8h21.11V0h23.078v69.044H152.57v-23.12h-21.11v23.12h-23.077V0z"/>
    <path d="M205.994,22.896h-20.316V0h63.72v22.896h-20.325v46.148h-23.078V22.896z"/>
    <path d="M259.511,0h24.063l14.802,24.26L313.163,0h24.072v69.044h-22.982V34.822l-15.877,24.549h-0.397l-15.888-24.549v34.222h-22.58V0z"/>
    <path d="M348.72,0h23.084v46.222h32.453v22.822H348.72V0z"/>
    <polygon fill="#FFFFFF" points="255.843,268.217 255.843,313.627 311.761,313.627 306.49,372.521 255.843,386.191 255.843,433.435 348.937,407.634 349.62,399.962 360.291,280.411 361.399,268.217 349.162,268.217"/>
    <polygon fill="#FFFFFF" points="255.843,176.305 255.843,204.509 255.843,221.605 255.843,221.716 365.385,221.716 365.385,221.716 365.531,221.716 366.442,211.509 368.511,188.488 369.597,176.305"/>
  </g>
</svg>
            
          
!
            
              svg {
  position: absolute;
  top:0;
  bottom:0;
  left:0;
  right:0;
  z-index: -1;
}

button {
  padding: 10px;
  font-size: 16px;
}
            
          
!
            
              // included script
// https://jfsiii.github.io/XCSSMatrix/dist/browserify/XCSSMatrix.js
var targetEl = document.getElementById('target'),
  resetButton = document.getElementById('reset'),
  transformPropertyJS = 'webkitTransform',
  matrixString = targetEl.style[transformPropertyJS] || '',
  transformedMatrix = new XCSSMatrix(matrixString),
  identityMatrixString = new XCSSMatrix().toString(),
  positionX = 0, 
  positionY = 0,
  direction = 'right';

resetButton.addEventListener('click', function(){ 
  transformedMatrix = new XCSSMatrix();
  targetEl.style[transformPropertyJS] = identityMatrixString;
});

requestAnimationFrame(drawNewMatrix);

function drawNewMatrix() {
  requestAnimationFrame(drawNewMatrix);
  
  // get the transformation from the element
  // var transformedMatrixString = targetEl.style[transformPropertyJS];

  // create a matrix object with the state from the element
  // transformedMatrix.setMatrixValue(transformedMatrixString);
  
  // update the matrix however you wish
  if (positionX > 200) {
    direction = 'left';
  }
  
  if (positionX < 0) {
    direction = 'right';
  }
  
  transformedMatrix = transformedMatrix.rotate(5, 2);
  
  if (direction == 'right') {
    transformedMatrix = transformedMatrix.translate(1, 5);
    positionX += 1;
  } else {
    transformedMatrix = transformedMatrix.translate(-1,-5);
    positionX -= 1;
  }
  
  // apply your changes to the element
  targetEl.style[transformPropertyJS] = transformedMatrix.toString();
}
            
          
!
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.
Loading ..................

Console