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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <canvas class="yuki-canvas" width="600" height="400"></canvas>

<script src="https://unpkg.com/zdog@1/dist/zdog.dist.min.js"></script>

              
            
!

CSS

              
                body{
  background: #3c3f86;
}
              
            
!

JS

              
                let yuki = new Zdog.Illustration({
  element: '.yuki-canvas',
  zoom: 1,
  dragRotate: true,
  onDragStart: function() {
    isSpinning = false;
  }
});

let isSpinning = true;
let direction = 1;
const TAU = Zdog.TAU;

// 肩膀
let shoulder = new Zdog.Group({
  addTo: yuki
})
let shoulderMain = new Zdog.Box({
  addTo: shoulder,
  width: 102,
  height: 11.73,
  depth: 11.73,
  stroke: false,
  color: '#c71755',
  leftFace: "#ed1b65",
  rightFace: '#ed1b65',
  topFace: '#c71755',
  bottomFace: '#8c103c',
  translate: { y: 44.135, x: -1, z: 5},
});
let shoulderTop = new Zdog.Cylinder({
  addTo: shoulder,
  diameter: 11.73,
  length: 102,
  stroke: false,
  color: '#c71755',
  backface: '#f11c67',
  rotate: {y: TAU/4},
  translate: { y: 38, x: -1, z: 5},
});
new Zdog.Shape({
  addTo: shoulder,
  visible: false,
  translate: { x: 0, y: 0, z: 200 },
});

let faceBottom = new Zdog.Box({
  addTo: yuki,
  width: 49,
  height: 24,
  depth: 2,
  stroke: false,
  color: '#d39a96',
  leftFace: '#d39a96',
  rightFace: '#d39a96',
  topFace: '#d39a96',
  bottomFace: '#d39a96',
  translate: { y: 20.5, z: 5},  
});

let nose = new Zdog.Box({
  addTo: yuki,
  width: 6.7,
  height: 11,
  depth: 1,
  stroke: false,
  color: '#dfa865',
  leftFace: '#dfa865',
  rightFace: '#dfa865',
  topFace: '#dfa865',
  bottomFace: '#dfa865',
  translate: { y: 10.3, x: 0, z: 8},  
});

//眉毛
let eyebrows = new Zdog.Group({
  addTo: yuki,
})
new Zdog.Shape({
  addTo: eyebrows,
  visible: false,
  translate: { x: 0, y: 0, z: 20 },
});
let eyebrowLeft = new Zdog.Box({
  addTo: eyebrows,
  width: 8.8,
  height: 4.7,
  depth: 1,
  stroke: false,
  color: '#201e1e',
  leftFace: '#201e1e',
  rightFace: '#201e1e',
  topFace: '#201e1e',
  bottomFace: '#201e1e',
  translate: { y: -4.5, x: 6.7, z: 8},  
});

let eyebrowRight = new Zdog.Box({
  addTo: eyebrows,
  width: 8.8,
  height: 4.7,
  depth: 1,
  stroke: false,
  color: '#201e1e',
  leftFace: '#201e1e',
  rightFace: '#201e1e',
  topFace: '#201e1e',
  bottomFace: '#201e1e',
  translate: { y: -4.5, x: -6.7, z: 8},  
});
let eyebrowMiddle = new Zdog.Box({
  addTo: eyebrows,
  width: 4.6,
  height: 4.7,
  depth: 1,
  stroke: false,
  color: '#c71755',
  leftFace: '#c71755',
  rightFace: '#c71755',
  topFace: '#c71755',
  bottomFace: '#c71755',
  translate: { y: -4.5, z: 8},  
});

// 嘴巴
let mouth = new Zdog.Group({
  addTo: yuki,
})
new Zdog.Shape({
  addTo: mouth,
  visible: false,
  translate: { x: 0, y: 0, z: 250 },
});
let mouthMain = new Zdog.Hemisphere({
  addTo: mouth,
  diameter: 17.5,
  rotate: {x: -TAU/4},
  stroke: false,
  color: '#c71755',
  backface: '#c71755',
  translate: { y: 15, x: 0, z: 9},  
});

let faceTop = new Zdog.Cylinder({
  addTo: yuki,
  diameter: 49,
  length: 2,
  stroke: false,
  color: '#d39a96',
  backface: '#d39a96',
  // rotate: {y: TAU/4},
  translate: { y: 8.2, z: 5},
});

// 头发
let hair = new  Zdog.Group({
  addTo: yuki,
})
let hairTop = new Zdog.Cylinder({
  addTo: hair,
  diameter: 75.7,
  length: 2,
  stroke: false,
  color: '#201e1e',
  backface: '#201e1e',
  // rotate: {y: TAU/4},
  translate: { y: 5.5, z: 3},
});
let hairRight = new Zdog.Box({
  addTo: hair,
  width: 23,
  height: 46,
  depth: 2,
  stroke: false,
  color: '#201e1e',
  rotate: {z: TAU/4/4.587155963},  
  translate: { y: 16, x: -32, z: 3},
});
let hairLeft = new Zdog.Box({
  addTo: hair,
  width: 23,
  height: 46,
  depth: 2,
  stroke: false,
  color: '#201e1e',
  rotate: {z: -TAU/4/4.587155963},  
  translate: { y: 16, x: 32, z: 3},
});
new Zdog.Shape({
  addTo: hair,
  visible: false,
  translate: { x: 0, y: 0, z: -300 },
});

// 眼睛
let eyes = new Zdog.Group({
  addTo: yuki,
})
new Zdog.Shape({
  addTo: eyes,
  visible: false,
  translate: { x: 0, y: 0, z: 20 },
});
let rightEye = new Zdog.Cylinder({
  addTo: eyes,
  diameter: 6.7,
  length: 1,
  stroke: false,
  color: '#201e1e',
  backface: '#201e1e',
  translate: { y: 4.8, x: -6.6, z: 8},
});
let leftEye = new Zdog.Cylinder({
  addTo: eyes,
  diameter: 6.7,
  length: 1,
  stroke: false,
  color: '#201e1e',
  backface: '#201e1e',
  translate: { y: 4.8, x: 6.6, z: 8},
});

// Leon
let leon = new Zdog.Ellipse({
  addTo: yuki,
  width: 40,
  height: 50,
  stroke: 50,
  color: '#c40040', 
  translate: { x: 143, y: 4.8, z: 8},  
});
let leon2 = new Zdog.Ellipse({
  addTo: leon,
  width: 50,
  height: 50,
  stroke: 50,
  color: '#c40040', 
  translate: { y: 22},  
});
let leonMouth = new Zdog.Hemisphere({
  addTo: leon,
  diameter: 52,
  rotate: {x: -TAU/4},
  stroke: false,
  color: '#c40040',
  translate: { y: 18, x: 0, z: 17},  
});
let teethLeft = new Zdog.Cone({
  addTo: leonMouth,
  diameter: 11,
  length: 7,
  stroke: false,
  color: '#fff',
  rotate: {x: TAU/2},  
  translate: { x: 17, y: -10, z: -1},    
});
let teethRight = new Zdog.Cone({
  addTo: leonMouth,
  diameter: 11,
  length: 7,
  stroke: false,
  color: '#fff',
  rotate: {x: TAU/2},  
  translate: { x: -17, y: -10, z: -1},    
});

let hornLeft = new Zdog.Cone({
  addTo: leon,
  diameter: 15,
  length: 10,
  stroke: false,
  color: '#fff',
  rotate: {x: TAU/4},  
  translate: { x: 16, y: -40, z: 10},    
});
let hornRight = new Zdog.Cone({
  addTo: leon,
  diameter: 15,
  length: 10,
  stroke: false,
  color: '#fff',
  rotate: {x: TAU/4},  
  translate: { x: -18, y: -40, z: 10},    
});
let leonLeftEye = new Zdog.Cylinder({
  addTo: leon,
  diameter: 13,
  length: 1,
  stroke: false,
  color: '#fff',
  backface: '#fff',
  translate: { x: 16, y: -10, z: 27},
});
let leonLeftEye2 = new Zdog.Cylinder({
  addTo: leonLeftEye,
  diameter: 19,
  length: 1,
  stroke: false,
  color: '#ab003a',
  backface: '#ab003a',
  translate: { z: -1},
});
let leonRightEye = new Zdog.Cylinder({
  addTo: leon,
  diameter: 13,
  length: 1,
  stroke: false,
  color: '#fff',
  backface: '#fff',
  translate: { x: -18, y: -10, z: 27},
});
let leonRightEye2 = new Zdog.Cylinder({
  addTo: leonRightEye,
  diameter: 19,
  length: 1,
  stroke: false,
  color: '#ab003a',
  backface: '#ab003a',
  translate: { z: -1},
});
let leonEyebrows = new Zdog.Group({
  addTo: leon,
})

//Leon 眉毛
new Zdog.Shape({
  addTo: leonEyebrows,
  path: [
    { x: 10, y: -25, z:27},
    { x: 20, y: -30, z:27},
  ],
  stroke: 6,
  color: '#333',
});
new Zdog.Shape({
  addTo: leonEyebrows,
  path: [
    { x: -10, y: -25, z:27},
    { x: -20, y: -30, z:27},
  ],
  stroke: 6,
  color: '#333',
});
new Zdog.Shape({
  addTo: leonEyebrows,
  visible: false,
  translate: { x: 0, y: -40, z: 120 },
});

// Leon 腿
new Zdog.Shape({//左腿
  addTo: leon,
  path: [
    { x: 30, y: 64, z:0},
    { x: 30, y: 80, z:0},
    { x: 36, y: 85, z:10},    
  ],
  stroke: 10,
  closed: false,
  color: '#ac003b',
});
new Zdog.Shape({//右腿
  addTo: leon,
  closed: false,
  path: [
    { x: -30, y: 64, z:0},
    { x: -30, y: 80, z:0},
    { x: -36, y: 85, z:10},  
  ],
  stroke: 10,
  color: '#ac003b',
});
let leonLeftHand = new Zdog.Group({
  addTo: leon,
})
new Zdog.Shape({ //左手
  addTo: leonLeftHand,
  path: [
    { x: 40, y: 20, z: 0}, 
    { bezier: [
      { x: 50, y: 15, z: 20},
      { x: 20, y: 65, z: 30},
      { x:  20, y:  20, z: 50 }, 
    ]},
  ],
  closed: false,
  stroke: 10,
  color: '#ac003b'
});
new Zdog.Shape({
  addTo: leonLeftHand,
  visible: false,
  translate: { x: 145, y: 0 },
});

let leonRightHand = new Zdog.Group({
  addTo: leon,
})

new Zdog.Shape({ //右手
  addTo: leonRightHand,
  path: [
    { x: -40, y: 20, z: 0}, 
    { bezier: [
      { x: -50, y: 25, z: 20},
      { x: -30, y: 50, z: 40},
      { x:  -20, y:  50, z: 50 }, 
    ]},
  ],
  closed: false,
  stroke: 10,
  color: '#ac003b'
});
new Zdog.Shape({
  addTo: leonRightHand,
  visible: false,
  translate: { x: -145, y: 0 },
});

new Zdog.Shape({ //嘴勾线
  addTo: leon,
  path: [
    { x: -26, y: 17, z: 20}, 
    { bezier: [
      { x: -26, y: 17, z: 51},
      { x: 26, y: 17, z: 51},
      { x:  26, y:  17, z: 20 }, 
    ]},
  ],
  fill: true,
  stroke: 2,
  color: '#ac003b'
});

let tail = new Zdog.Group({
  addTo: leon,
});

new Zdog.Shape({ //尾巴
  addTo: tail,
  path: [
    { x: 0, y: 50, z: -30}, 
    { bezier: [
      { x: 0, y: 85, z: -90},
      { x: 60, y: 10, z: 0},
      { x:  80, y:  20, z: -20 }, 
    ]},
  ],
  closed: false,
  stroke: 10,
  color: '#ac003b'
});

let tailTip = new Zdog.Polygon({
  addTo: tail,
  radius: 10,
  sides: 3,
  stroke: 10,
  color: '#ac003b',
  rotate: {z: TAU/4},  
  translate: {x: 80, y: 20, z: -20}
});

new Zdog.Shape({
  addTo: tail,
  visible: false,
  translate: { x: 0, y: 0, z: -100 },
});

// update & render
yuki.updateRenderGraph();

function animate() {
  if ( isSpinning ) {
    yuki.rotate.y += 0.02 * direction;
    // yuki.rotate.x -= 0.01;
    // yuki.rotate.z += 0.01;
  }
  yuki.updateRenderGraph();
  requestAnimationFrame( animate );
}
animate();


              
            
!
999px

Console