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

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

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <canvas class="illo"></canvas>
            
          
!
            
              body {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100vw;
	height: 100vh;
	overflow: hidden;
	background-color: #232323;
	color: #ffd300;
	font-family: 'Space Mono', monospace;
}

canvas {
  background-color: #ffd300;
}

            
          
!
            
              const canvas = document.querySelector('.illo');
const width = 440;
const height = 240;
canvas.setAttribute( 'width', width );
canvas.setAttribute( 'height', height );

let illo = new Zdog.Illustration({
  element: canvas,
  dragRotate: true,
  zoom: 8
});

let head = new Zdog.RoundedRect({
  addTo: illo,
  width: 12,
  height: 10,
  cornerRadius: 2,
  stroke: 8,
  fill: true,
  color: '#000'
});

let maskGroup = new Zdog.Group({
  addTo: head
});

let rect = new Zdog.RoundedRect({
  addTo: maskGroup,
  translate: { x: 0, y: -1, z: 1 },
  width: 14,
  height: 8,
  stroke: 0.4,
  cornerRadius: 1.9,
  fill: true,
  color: '#ffd300',
  backface: false,
});

let eye = new Zdog.Ellipse({
  addTo: maskGroup,
  diameter: 1.5,
  translate: { x: -3, y: -1, z: 2.2 },
  // rotate semi-circle to point up
  rotate: { z: -Zdog.TAU / 4 },
  color: 'black',
  stroke: 1,
  fill: true,
  // hide when front-side is facing back
  backface: false,
});

eye.copy({
  translate: { x: 3, y: -1, z: 2.2 },
});

let eyebrow = new Zdog.Shape({
  addTo: maskGroup,
  path: [ { x: -1.5 }, { x: 1 } ],
  stroke: 0.9,
  translate: { x: -3.2, y: -3.1, z: 2.2 },
  rotate: { z: -Zdog.TAU / 2.09 },
  color: 'black',
  backface: false,
});

eyebrow.copy({
  rotate: { z: Zdog.TAU / 2.09 },
  translate: { x: 2.7, y: -3.0, z: 2.2 },
});

let maskRight = new Zdog.Shape({
  addTo: maskGroup,
  translate: { x: 0, y: -1, z: 2.2 },
  path: [
    { x: 0, y: 2 },   // start
    { bezier: [
      { x:  2, y: 2 }, // start control point
      { x:  2, y:  5 }, // end control point
      { x:  6, y:  5 }, // end point
    ]},
    { x: 0, y: 5 },   // start
  ],
  closed: true,
  fill: true,
  stroke: 0.5,
  color: '#000',
  backface: false,
});

let maskLeft = new Zdog.Shape({
  addTo: maskGroup,
  translate: { x: 0, y: -1, z: 2.2 },
  path: [
    { x: 0, y: 2 },   // start
    { bezier: [
      { x:  -2, y: 2 }, // start control point
      { x:  -2, y:  5 }, // end control point
      { x:  -6, y:  5 }, // end point
    ]},
    { x: 0, y: 5 },
  ],
  closed: true,
  fill: true,
  stroke: 0.5,
  color: '#000',
  backface: false,
});

const line = new Zdog.Shape({
  addTo: head,
  translate: { x: 0, y: -5, z: 0 },
  rotate: { z: Zdog.TAU / 1.04 },
  path: [
    { x: -13 }, // start at 1st point
    { x:  -8 }, // line to 2nd point
  ],
  stroke: 1.3,
  color: '#000',
});

line.copy({
  translate: { x: 0, y: -1, z: 0 },
  rotate: { z: Zdog.TAU / 0.96 }
});

let ticker = 0;
let cycleCount = 150;

// ease rotate from zDog docs
function animate() {
  let progress = ticker / cycleCount;
  let tween = Zdog.easeInOut( progress % 1, 3 );
  illo.rotate.y = tween * Zdog.TAU;
  ticker++;

  illo.updateRenderGraph();
  requestAnimationFrame( animate );
}
function render() {
  illo.updateRenderGraph();
  requestAnimationFrame( render );
}
// animate();
render();
            
          
!
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.

Console