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

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

              
                <svg class="zdog-svg" width="200" height="200"></svg>
              
            
!

CSS

              
                .zdog-svg {
  background: #d7edff;
  cursor: move;
}
              
            
!

JS

              
                // Made with Zdog
const TAU = Zdog.TAU;
var isSpinning = true;
var delta = TAU * 2/32;
let illo = new Zdog.Illustration({
  element: '.zdog-svg',

});
let p0 = new Zdog.Vector({ x: 0, y: 0 });
let cp0 = new Zdog.Vector({ x: 0, y: 10 });
let cp11 = new Zdog.Vector({ x: 0, y: 40 });
let cp12 = new Zdog.Vector({ x: 0, y: 40 });
let cp21 = new Zdog.Vector({ x: 0, y: 60 });
let cp22 = new Zdog.Vector({ x: 0, y: 60 });

let torso = new Zdog.Shape({
  addTo: illo,
  translate: { x: 0, y: -40 },
  stroke: 58,
  color: '#ffffff',
});
let eye = new Zdog.Shape({
  addTo: torso,
  translate: {x: 32, y: 0, z: 10 },  
  path: [
    { x: 0, y: -5 }, // start at 1st point
    { x: 0, y:  5 }, // line to 2nd point
  ],
  stroke: 10,
  color: '#000000',
});

eye.copy({
  addTo: torso,
 translate: {x: 32, y: 0, z: -10 },  

  stroke: 10,
  color: '#000000',
  });
let leg = new Zdog.Shape({
  addTo: torso,
  translate: {x: 0, y: 32, z: 24 },                
  path: [
    p0,   // start
    { bezier: [
      cp0, // start control point
      cp11, // end control point
      cp21, // end point
    ]},
  ],
  closed: false,
  stroke: 12,
  color: '#aaaaaa',
  
});

let arm = new Zdog.Shape({
  addTo: torso,
  translate: {x: 0, y: 0, z: 40 },                
  path: [
    p0,   // start
    { bezier: [
      cp0, // start control point
      cp12, // end control point
      cp22, // end point
    ]},
  ],
  closed: false,
  stroke: 12,
  color: '#424242',
  
});
let arm2 = new Zdog.Shape({
  addTo: torso,
  translate: {x: 0, y: 0, z: -40 },                
  path: [
    p0,   // start
    { bezier: [
      cp0, // start control point
      cp11, // end control point
      cp21, // end point
    ]},
  ],
  closed: false,
  stroke: 12,
  color: '#424242',
  
});
let leg2 = new Zdog.Shape({
  addTo: torso,
  translate: {x: 0, y: 32, z: -24 },                
  path: [
    p0,   // start
    { bezier: [
      cp0, // start control point
      cp12, // end control point
      cp22, // end point
    ]},
  ],
  closed: false,
  stroke: 12,
  color: '#aaaaaa',
  
});
let torso2 = new Zdog.Shape({
  addTo: illo,
  translate: { x: 0, y: -40, z: -80},
  stroke: 64,
  color: '#000000',
});

leg.copy({
  addTo: torso2,
  translate: {x: 0, y: 32, z: 24 },
  stroke: 18,
  color: '#000000'
});
arm.copy({
  addTo: torso2,
  translate: {x: 0, y: 0, z: 40 },
  stroke: 18,
  color: '#000000'
});
arm2.copy({
  addTo: torso2,
  translate: {x: 0, y: 0, z: -40 },
  stroke: 18,
  color: '#000000'
});
leg2.copy({
  addTo: torso2,
  translate: {x: 0, y: 32, z: -24 },
  stroke: 18,
  color: '#000000'
});


let viewRotation = new Zdog.Vector();
let dragStartRX, dragStartRY;

new Zdog.Dragger({
  startElement: '.zdog-svg',
  onDragStart: function() {
    dragStartRX = viewRotation.x;
    dragStartRY = viewRotation.y;
    isAnimating = true;
    animate();
  },
  onDragMove: function( pointer, moveX, moveY ) {
    let moveRX = moveY / illo.width * TAU;
    let moveRY = moveX / illo.width * TAU;
    viewRotation.x = dragStartRX - moveRX;
    viewRotation.y = dragStartRY - moveRY;
  },
  onDragEnd: function() {
    isAnimating = true;
  },
});

function animate() {
  torso.rotate.set( viewRotation );
  torso2.rotate.set( viewRotation );

  illo.updateRenderGraph();
  requestAnimationFrame( animate );
}

animate();




var t = 1;
var tSpeed = 1/60;

function animate2() {
  // update
  if ( isSpinning ) {
    t += tSpeed;
    var theta = Zdog.easeInOut( t % 1 ) * TAU;
    var delta = TAU * 2/32;

cp11.x = -10 * (Math.cos( theta ) + Math.sin(theta));
cp12.x = 10 * (Math.cos( theta ) + Math.sin(theta));
    cp21.x = 20 * (Math.cos( theta ) - Math.sin(theta));
cp22.x = -20 * (Math.cos( theta ) - Math.sin(theta));
    

  }

  illo.updateRenderGraph();
  requestAnimationFrame( animate2 );
}

animate2();

function animate1() {
  torso.rotate.y += isSpinning ? 0.01 : 0;
  torso2.rotate.y += isSpinning ? 0.01 : 0;

 illo.updateRenderGraph();
 requestAnimationFrame( animate1 );
}

animate1();

              
            
!
999px

Console