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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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="zdog-canvas" width="450" height="450"></canvas>

<div class="copyright">
    <p>MADE BY CHAEHEE FROM <a href="https://studio-jt.co.kr" target=_blank"">STUDIO-JT</a></p>
    <figure>
        <img src="https://studio-jt.co.kr/wp-content/uploads/2018/07/chaehee-1.jpg" alt="">
    </figure>    
</div>
              
            
!

CSS

              
                body {
  margin: 0; 
  padding: 0;
  background: #e9e9e9;
}

.zdog-canvas {
  cursor: move;
  margin: 0 auto;
  display: block;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%)
}

.copyright {
    display: block;
    position: absolute;
    bottom: 0;
    right: 0;
    font-size: 0;
}

.copyright > * {
    display: inline-block;
    vertical-align: middle;
}

.copyright figure {
    width: 70px;
    margin: 0;
}

.copyright figure img {
    max-width: 100%;
    vertical-align: top;
}

.copyright p {
    letter-spacing: 0.06em;
    color: #666;
    font-size: 12px;
    margin: 0;
    margin-right: 16px;
    background: #fff;
    padding: 7px 14px;
    border-radius: 40px;
    position: relative;
}

.copyright p:before {
    content: '';
    border: 4px solid transparent;
    position: absolute;
    right: -12px;
    top: 50%;
    transform: translateY(-50%);
    border-left-color: #fff;
    border-left-width: 10px;
}

.copyright p a {
    color: #0b21ee;
}
              
            
!

JS

              
                anpanman();
  
function anpanman(){

	const TAU = Zdog.TAU;
	// accept degrees, return radians
	
	function deg(degress) {
	  return degress / 180 * Math.PI
	}

	const apman = new Zdog.Illustration({
		element: '.zdog-canvas',
		dragRotate: true,
		zoom: 4,
		rotate: {x: -TAU/24, y: -TAU/12},
	});

	const animationObject = {
		LeftEyeHeight: 3,
		RightEyeHeight: 3,
		headRotationY: 0,
	};

	// ---- model ----//
	var hipX = 4;
	// hips
	var hips = new Zdog.Shape({
		addTo: apman,
		path: [ { x: -hipX }, { x: hipX } ],
		translate: { y: 20 },
		stroke: 6,
		color: 'red',
	});

	// ---- legs ----- //
	var legSize = 10;
	
	//leftLeg
	
	var leftLegGroup = new Zdog.Group({
		addTo: hips,
		translate: { x: -hipX },
		rotate: { z: TAU/24, y: TAU/24}
	})

	var leftUppperLeg =new Zdog.Shape({
		addTo: leftLegGroup,
		path: [ { y: 0 }, { y: legSize } ],
		color: 'red',
		stroke: 6,
	});

	var leftForeLeg = new Zdog.Shape({
		addTo: leftUppperLeg,
		path: [ { y: 0 }, { y: legSize - 6 } ],
		translate: { y: legSize },
		color: 'red',
		stroke: 6
	});

	var leftLegShoe = new Zdog.Cylinder({
		addTo: leftForeLeg,
		diameter: 6,
		length: 9,
		color: '#EA0',
		stroke: false,
		rotate: {x: TAU/4},
		translate: {y: legSize - 10},
		frontFace: 'red',
		backface: 'red',
	});

	// rightLeg
	var rightLegGroup = new Zdog.Group({
		addTo: hips,
		translate: { x: hipX },
		rotate: { z: -TAU/24, y: TAU/24}
	})

	var rightUpperLeg =new Zdog.Shape({
		addTo: rightLegGroup,
		path: [ { y: 0 }, { y: legSize } ],
		color: 'red',
		stroke: 6
	});

	var rightForeLeg = new Zdog.Shape({
		addTo: rightUpperLeg,
		path: [ { y: 0 }, { y: legSize - 6 } ],
		translate: { y: legSize },
		color: 'red',
		stroke: 6
	});

	var rightLegShoe = new Zdog.Cylinder({
		addTo: rightForeLeg,
		diameter: 6,
		length: 9,
		color: '#EA0',
		stroke: false,
		rotate: {x: TAU/4},
		translate: {y: legSize - 10},
		frontFace: 'red',
		backface: 'red',
	});

	// foots
	new Zdog.Shape({
		addTo: leftForeLeg,
		translate: { y: legSize - 5, z: .5 },
		stroke: 7,
		color: '#EA0',
	});

	new Zdog.Shape({
		addTo: rightForeLeg,
		translate: { y: legSize - 5, z : .5 },
		stroke: 7,
		color: '#EA0',
	});

	// ----- upper body ----- //
	var spine = new Zdog.Anchor({
		addTo: hips
	});

	var chest = new Zdog.Rect({
		addTo: spine,
		width: 1,
		height: 7,
		stroke: 16,
		translate: {y: -8},
		color: 'red',
	});

	// ---- arms ---- //
	var armSize = 7;

	//leftArm
	var leftArmGroup = new Zdog.Group({
		addTo: chest,
		translate: {x: -9, y: -7},
		rotate: {z: TAU/6}
	})
	
	var leftUpperArm = new Zdog.Shape({
		addTo: leftArmGroup,
		path: [{y: 0}, {y: armSize}],
		stroke: 6,
		color: 'red'	,
	});

	var leftForeArm = new Zdog.Shape({
		addTo: leftUpperArm,
		path: [ { y: 0 }, { y: armSize - 1 } ],
		translate: { y: armSize },
		color: 'red',
		stroke: 6,
		rotate: {z: -TAU/4}
	});

	var leftArmGlove = new Zdog.Cylinder({
		addTo: leftForeArm,
		diameter: 6,
		length: 3,
		color: '#EA0',
		stroke: false,
		rotate: {x: TAU/4},
		translate: {y: armSize - 3}
	});

	//rightArm
	var rightArmGroup = new Zdog.Group({
		addTo: chest,
		translate: {x: 9, y: -7},
		rotate: {z: -TAU/6}
	})

	var rightUpperArm = new Zdog.Shape({
		addTo: rightArmGroup,
		path: [{y: 0}, {y: armSize}],
		stroke: 6,
		color: 'red'
	});

	var rightForeArm = new Zdog.Shape({
		addTo: rightUpperArm,
		path: [ { y: 0 }, { y: armSize - 1 } ],
		translate: { y: armSize },
		color: 'red',
		stroke: 6,
		rotate: {z: TAU/4}
	});

	var rightArmGlove = new Zdog.Cylinder({
		addTo: rightForeArm,
		diameter: 6,
		length: 3,
		color: '#EA0',
		stroke: false,
		rotate: {x: TAU/4},
		translate: {y: armSize - 3}
	});

	// hand
	new Zdog.Shape({
		addTo: leftForeArm,
		translate: { y: armSize - 1, z: .5 },
		stroke: 7,
		color: '#EA0',
	});

	new Zdog.Shape({
		addTo: rightForeArm,
		translate: { y: armSize - 1, z: .5 },
		stroke: 7,
		color: '#EA0',
	});

	// ---- head ----//

	var head = new Zdog.Shape({
		addTo: chest,
		stroke: 40,
		translate: {y: -29},
		color: '#FDB',
		rotate: {z: 0}
	});
		
	var cheek = new Zdog.Hemisphere({
		addTo: head,
		stroke: false,
		diameter: 11,
		color: 'red',
		translate: {z: 19}
	});

	cheek.copy({
		color: 'orangered',
		translate: {x: -10, z: 17},
		rotate: {y: TAU/12}
	});

	cheek.copy({
		color: 'orangered',
		translate: {x: 10, z: 17},
		rotate: {y: -TAU/12}
	});

	//eye
	var left_eye = new Zdog.Ellipse({
		addTo: head,
		width: .5,
		height: 3,		
		fill: true,
		color: 'black',
		translate: {x: 5, y: -6, z: 18}
	});

	var right_eye = new Zdog.Ellipse({
		addTo: head,
		width: .5,
		height: 3,		
		fill: true,
		color: 'black',
		translate: {x: -5, y: -6, z: 18}
	});

	//eyebrow
	var eyebrow = new Zdog.Ellipse({
		addTo: head,
		diameter: 6,
		quarters: 2,
		color: 'black',
		translate: {x: -5, y: -10, z: 18},
		rotate: {z: -TAU/4},
		stroke: .5
	});

	eyebrow.copy({
		translate: {x: 5, y: -10, z: 18},
	});

	//mouth
	var mouth = new Zdog.Ellipse({
		addTo: head,
		diameter: 8,
		quarters: 2,
		closed: true,
		fill: true,
		color: 'brown',
		translate: {y: 8, z: 18},
		rotate: {z: TAU/4, x: -TAU/12},
		backface: false,
	});

	

	// ---- GSAP ---- //
	const tlEyes = new TimelineMax({repeat: -1, repeatDelay: 2});

	tlEyes.to(animationObject, .1, {
		LeftEyeHeight: .1,
		RightEyeHeight: .1
	})
	.to(animationObject, .1,{
		LeftEyeHeight: 3,
		RightEyeHeight: 3
	})
	.to(animationObject, .1, {
		LeftEyeHeight: .1,
		RightEyeHeight: .1
	})
	.to(animationObject, .1,{
		LeftEyeHeight: 3,
		RightEyeHeight: 3
	})

	const tlHead = new TimelineMax({repeat: -1});

	tlHead.to(animationObject, 0.4, {
	  headRotationY: deg(-20),
	})
	  .to(animationObject, 2, {
	  headRotationY: deg(-20),
	})
	  .to(animationObject, 0.4, {
	  headRotationY: deg(0),
	})
	  .to(animationObject, 2, {
	  headRotationY: deg(0),
	})
	  .to(animationObject, 0.4, {
	  headRotationY: deg(20),
	})
	  .to(animationObject, 2, {
	  headRotationY: deg(20),
	})
	  .to(animationObject, 0.4, {
	  headRotationY: deg(0),
	})
	  .to(animationObject, 2, {
	  headRotationY: deg(0),
	})
  
	function render(){
		head.rotate.y = animationObject.headRotationY;
		left_eye.height = animationObject.LeftEyeHeight;
		right_eye.height = animationObject.RightEyeHeight;

		left_eye.updatePath();
		right_eye.updatePath();
		apman.updateRenderGraph();
	}

	const tlMaster = new TimelineMax({onUpdate: render});
	tlMaster.addLabel("beginning")
	tlMaster.add(tlEyes)           
	tlMaster.add(tlHead, "beginning+=1")

}
              
            
!
999px

Console