Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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 version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 420 500" xml:space="preserve">
	<defs>
		
		<pattern id="shirtPattern" width="10" height="30" patternUnits="userSpaceOnUse">
			<rect width="10" height="10" class="shirtPattern" />
			<rect y="10" width="10" height="20" class="shirtPattern" />
		</pattern><!-- #shirtPattern -->

		<mask id="mouthShapes" maskUnits="userSpaceOnUse" x="0" y="0" width="420" height="500">
			<path id="mouthOpen" fill="#ffffff" d="M237.41,197.65c0,9.73-2.89,17.61-23.21,17.61S191,207.37,191,197.65h46.42Z" />
		</mask><!-- #mouthShapes -->
		
		<!-- Mouth shapes targets -->
		<path id="mouthO" fill="#ffffff" d="M223,203.83c0,7.06-1.15,12.78-9.25,12.78s-9.25-5.72-9.25-12.78C204.49,193.19,223,193.35,223,203.83Z" />
		
	</defs>

	<!-- Flying coloured balls -->
	<!-- Throw right -->
	<g>
	<ellipse id="ball01" class="gray" cx="220" cy="110" rx="7" ry="7" />
	<ellipse id="ball02" class="green" cx="200" cy="180" rx="5" ry="5" />
	<ellipse id="ball03" class="yellow" cx="220" cy="150" rx="12" ry="12" />
	<ellipse id="ball04" class="red" cx="250" cy="134" rx="7" ry="7" />
	<!-- Throw left -->
	<ellipse id="ball05" class="red" cx="220" cy="174.31" rx="7" ry="7" />
	<ellipse id="ball06" class="gray" cx="200" cy="190" rx="5" ry="5" />
	<ellipse id="ball07" class="green" cx="220" cy="90" rx="12" ry="12" />
	<ellipse id="ball08" class="yellow" cx="250" cy="134" rx="7" ry="7" />
	</g><!-- flying coloured balls -->

	<!-- CROM himself -->
	<g id="legs">
		<path id="crotch" d="M261.2,319.5c0,7.8-20.3,14.1-45.3,14.1s-45.3-6.3-45.3-14.1c0-4.2,0-14.9,0-14.9h90.7 C261.2,304.7,261.2,314.6,261.2,319.5z" />

		<path id="legLeft" d="M166.4,366.3c-10.5-4.3,7-8.5,7-21.7v-25.1h15l-0.9,31.8C187.5,360.5,178.8,371.5,166.4,366.3z" />

		<path id="legRight" d="M265.4,366.3c10.5-4.3-7-8.5-7-21.7v-25.1h-15l0.9,31.8C244.2,360.5,252.9,371.5,265.4,366.3z" />
	</g><!-- #legs -->


	<g id="torso">

		<g id="armRight">
			<path id="armR" class="arms" d="M160.3,250c-1,5.3-7.6,18.6-14.8,24.3c-7.2,5.7-20.6,11.3-30.2,10.4" />

			<path id="sleeveR" d="M169.1,252.7l-15.9-1.6l1.9-19.2c0.2-1.5,1.5-2.6,3-2.5l10.4,1.1c1.5,0.2,2.6,1.5,2.5,3L169.1,252.7z" />

			<path id="handR" class="skin" d="M120.2,284.9c0,3.3-0.4,6-5.3,6s-8.8-0.8-8.8-6c0-5.2,4-6,8.8-6S120.2,281.6,120.2,284.9z" />
		</g><!-- #armRight -->

		<g id="armLeft">
			<path id="armL" class="arms" d="M266.7,250c1,5.3,7.6,18.6,14.8,24.3c7.2,5.7,20.6,11.3,30.2,10.4" />

			<path id="sleeveL" d="M257.8,252.7l15.9-1.6l-1.9-19.2c-0.2-1.5-1.5-2.6-3-2.5l-10.4,1.1c-1.5,0.2-2.6,1.5-2.5,3L257.8,252.7z" />

			<path id="handL" class="skin" d="M306.7,284.9c0,3.3,0.4,6,5.3,6c4.9,0,8.8-0.8,8.8-6c0-5.2-4-6-8.8-6C307.2,279,306.7,281.6,306.7,284.9z" />
		</g><!-- #armLeft -->

			<g id="shirts">
		<path id="shirt01" d="M261.4,228h-94.1c-2.3,0-4.2,1.9-4.2,4.2v88.4h102.5v-88.4C265.6,229.9,263.7,228,261.4,228z" />
		<path id="shirtLapel" class="shirtDecoration" d="M237.62,228c0,4.78-9.25,17.19-9.25,17.19l-12.46-13.25-12.46,13.25s-9.25-12.41-9.25-17.19" />
		<line id="shirtMiddle" class="shirtDecoration" x1="215.91" y1="231.91" x2="215.91" y2="320.63" />
		</g><!-- #shirts -->


		<g id="head">
			<path class="skin" d="M295.4,157.9c-4.5,0-7,1.9-8,7.3c0.9-54.1-33.5-70.9-77.8-70.9c-43,0-80.9,18-77.8,72.4
		c-0.8-6.6-3.3-8.8-8.2-8.8c-6.4,0-11.6,5.4-11.6,15.8c0,10.4,8.9,18.9,15.3,18.9c4.9,0,7-1.5,6.3-9.3c6.3,29.9,29.4,52,76,52
		c45.9,0,69-21.4,75.7-50.6c-0.3,6.6,1.9,8,6.4,8c6.4,0,15.3-8.4,15.3-18.9C307.1,163.3,301.8,157.9,295.4,157.9z" />

			<g id="face">

				<g id="mouth" mask="url(#mouthShapes)">

					<g id="teeth">
						<rect id="backOfMouth" x="180" y="180" width="60" height="30"/>
						
<path id="tooth0" class="tooth" d="M196.38,211.85c0.06,2.4,0,4.76,0,4.76H189v-4.76c0-2.58,1.65-4.67,3.69-4.67S196.38,209.28,196.38,211.85Z"/>
  <path id="tooth1" class="tooth" d="M203.32,211.85v4.76h-7.94v-4.76c0-2.58,1.78-4.67,4-4.67S203.32,209.28,203.32,211.85Z"/>
  <path id="tooth2" class="tooth" d="M213.74,211.85v4.76H203.32v-4.76A5.21,5.21,0,1,1,213.74,211.85Z"/>
  <path id="tooth3" class="tooth" d="M224.15,211.85v4.69l-10.42.07v-4.76A5.21,5.21,0,1,1,224.15,211.85Z"/>
  <path id="tooth4" class="tooth" d="M231.53,211.85v4.69h-7.37v-4.69c0-2.58,1.65-4.67,3.69-4.67S231.53,209.28,231.53,211.85Z"/>
  <path id="tooth6" class="tooth" d="M237.9,211.85v4.69h-7.37v-4.69c0-2.58,1.65-4.67,3.69-4.67S237.9,209.28,237.9,211.85Z"/>
					</g><!-- #teeth -->

				</g><!-- #mouth -->
				
				<g id="eyeRight">
					<ellipse id="eyeRightOpen" class="open" cx="255.2" cy="174.3" rx="7.5" ry="12.6" />
					<path id="eyeRightClosed" class="closed" d="M262.5,170.1c0.5,16.8-11.1,21.6-16.1,3.8" />
					<polyline id="eyeRightBlink" class="blink" points="259.5,182.7 246.3,173.8 262.5,165.4 	" />
				</g><!-- #eyeRight -->

				<g id="eyeLeft">
					<ellipse id="eyeLeftOpen" class="open" cx="174.09" cy="174.31" rx="7.5" ry="12.64" />
					<path id="eyeLeftClosed" class="closed" d="M167.44,170.06c-0.5,16.84,11.13,21.63,16.13,3.75" />
					<path id="eyeLeftBlink" class="blink" d="M170.44,182.69s13.13-7.25,13.13-8.88-16.14-8.46-16.14-8.46" />
				</g><!-- #eyeLeft -->
			
			</g><!-- #face -->

			<g id="hair">
				<path d="M131.8,166.7c-16.5-31.6-7.9-74.8,11.2-66.1c2-1.4,13.5-41.2,66.5-41.2s73.3,46.8,74,52.4
		c4.3-3.8,8.1,2.3,10.5,9.2c1.8,5.3,10.8,29.6-6.5,44.1c-4.5-9.3-31.4-17.6-26.7-33.1c-7.6,8.7-25.5,4.9-16.8,13.9
		c-54.9,12.1-87.2-8.7-91.9-13.9C152,145.2,126.9,148.1,131.8,166.7z" />
			</g><!-- #hair -->

			<g id="accesories">
				<path id="glasses" d="M230.5,155.9l-3,5.8h-21.9l-3-5.8h-74.9v16.4h13.8c0,0,5.8,27.5,33.7,27.5c24.9,0,31.4-19.9,31.4-19.9h19.7
		c0,0,6.5,19.9,31.4,19.9c27.9,0,33.7-27.5,33.7-27.5h13.8v-16.4H230.5z M199.8,179.1c0,0-5.8,15-24.6,15c-25,0-27.6-21.8-27.6-21.8
		v-8.2h52.1V179.1z M285.5,172.3c0,0-2.5,21.8-27.6,21.8c-18.8,0-24.6-15-24.6-15v-15h52.1V172.3z" />
			</g><!-- #accessories -->
		</g><!-- #head -->
	
	</g><!-- #torso -->

	<text transform="matrix(1 0 0 1 115 472)" id="crom">CROM</text>
	
</svg>
              
            
!

CSS

              
                $skinColor: #f6d0a7;
$shirtColor: #3fa4d5;

svg {
	height: 90vh;
	width: 100%;
}

text {
	font-family: "league-gothic",sans-serif;
	font-size: 120px;
	fill: grey;
}

.skin {
	fill: $skinColor;	
}

#shirt01, #sleeveL, #sleeveR {
/*	fill: $shirtColor; */
	fill: url(#shirtPattern);
}

.shirtPattern {
	fill: #2f97ca;
	stroke: #56bdf0;
}

.arms {
	fill: none;
	stroke: $skinColor;
	stroke-width: 10;
	stroke-miterlimit: 10;
}

#legs {
	fill: #c49548;
}

#hair {
	fill: #000032;
}

.closed, .blink {
	visibility: hidden;
	stroke: black;
	stroke-width:4;
	stroke-miterlimit:10;
	fill: none;
}

.shirtDecoration {
	stroke: #476f82;
	stroke-width:2;
	stroke-miterlimit:10;
	fill: none;	
}

.gray {
	fill: #666666;
}

.red {
	fill: #ff3200;
}

.yellow {
	fill: #ffff00;
}

.green {
	fill: #5fff00;
}

.tooth {
	fill: #fff;
}

.morphTarget {
	visibility: hidden;
}
              
            
!

JS

              
                'use strict';

var tl = new TimelineMax({repeat: -1,repeatDelay: 1}), 
				dur = 0.2;

tl
	.add("Start")
	.add(bounceTorsoUpwards("#torso"), "Start")
	.add(bounceHeadUpwards("#head"), "Start")
	.add(raiseArms(["#armRight", "#armLeft"], 90), "Start")
	.add(cycleFillColor("#crom", ["#666666", "#ff3200", "#ffff00", "#5fff00"]), "Start+=" + dur)
	.add(eyeBlink(), "Start")
 .add(say(), "Start")
	.add(lowerArms(["#armRight", "#armLeft"]), "Start+=" + (dur * 3))
	.add(throwBalls(["#ball01", "#ball02", "#ball03", "#ball04"], 100, 1, 1), "Start+=" + (dur * 1.2))
	.add(throwBalls(["#ball05", "#ball06", "#ball07", "#ball08"], 100, 1, -1), "Start+=" + (dur * 1.2))

function throwBalls(els, distance, curviness, direction) {
	// Change these to be a bunch of tweens, not a timeline
	var tweens = [],
					ttl = els.length;

	for (var i = 0; i < ttl; i++) {
		var dlay = 0.05 * i;
		var amplitude = (curviness * Math.random()) * 100;
		
		var tween1 = TweenMax.to(els[i], dur * 3, {
			bezier: [{
				cx: "+=" + (distance * direction),
				cy: "-=" + amplitude
			}, {
				cx: "+=" + (distance * direction * 2),
				cy: "-=" + amplitude
			}],
			ease: Linear.easeNone,
			delay: dlay
		});
		
		var tween2 = TweenMax.to(els[i], 0.1, {
			autoAlpha: 0,
			delay: dur * 3
		});

		tweens.push(tween1, tween2);
	}

	return tweens;
}

function say(els) {
	var tl = new TimelineMax();
	
	tl
		.to("#mouthOpen", dur*0.25, {morphSVG:"#mouthO"})
		.to("#mouthOpen", dur*0.25, {morphSVG:"#mouthOpen"}, "+=0.25")
	
	return tl;
}

function lowerArms(els) {
	var tl = new TimelineMax();

	tl
		.set(els[0], {
			transformOrigin: "90% 10%"
		})
		.set(els[1], {
			transformOrigin: "10% 10%"
		})
		// Swing arms down
		.add("Down")
		.to(els[0], dur * 3, {
			rotation: 0,
			ease: Back.easeOut
		}, "Down")
		.to(els[1], dur * 3, {
			rotation: 0,
			ease: Back.easeOut
		}, "Down")

	return tl;
}

function raiseArms(els, amount) {
	var tl = new TimelineMax();

	tl
		.set(els[0], {
			transformOrigin: "90% 10%"
		})
		.set(els[1], {
			transformOrigin: "10% 10%"
		})
		// Swing arms down
		.add("Down")
		.to(els[0], dur, {
			rotation: "-" + (amount * 0.2)
		}, "Down")
		.to(els[1], dur, {
			rotation: "+" + (amount * 0.2)
		}, "Down")
		// Swing arms up
		.add("Up")
		.to(els[0], dur * 2, {
			rotation: "+" + amount,
			ease: Power3.easeOut
		}, "Up")
		.to(els[1], dur * 2, {
			rotation: "-" + amount,
			ease: Power3.easeOut
		}, "Up");

	return tl;
}

function bounceHeadUpwards(el) {
	var tl = new TimelineMax();

	tl
		.add("Start")
		.to(el, dur, {
			y: "+=5"
		}, "Start")
		.to(el, dur, {
			y: 0
		})
		// 	Check if he is wearing glasses
	if (checkElement("glasses")) {
		tl.add(bounceGlassesUpwards("#glasses"), "Start+=0.15")
	}

	return tl;
}

function bounceGlassesUpwards(el) {
	var tl = new TimelineMax();

	tl
		.to("#glasses", dur, {
			y: "+=5"
		}, "Start")
		.to("#glasses", dur, {
			y: "-=10",
			ease: Power3.easeOut
		})
		.to("#glasses", dur * 2, {
			y: 0,
			ease: Bounce.easeOut
		});

	return tl;
}

function bounceTorsoUpwards(el) {
	var tl = new TimelineMax();

	tl
		.to(el, dur, {
			y: "+=5"
		})
		.to(el, dur, {
			y: "-=7",
			ease: Power3.easeOut
		})
		.to(el, dur, {
			y: 0,
			ease: Power3.easeInOut
		})

	return tl;
}

function eyeBlink() {
	var tl = new TimelineMax(),
		thisDur = 0.01;

	tl
		.add("Start")
		.to(".blink", thisDur, {
			autoAlpha: 1
		}, "Start")
		.to([".open", ".closed"], thisDur, {
			autoAlpha: 0
		}, "Start")
		.add("Open", "+=0.3")
		.to(".blink", thisDur, {
			autoAlpha: 0
		}, "Open")
		.to(".open", thisDur, {
			autoAlpha: 1
		}, "Open")

	return tl;
}

function cycleFillColor(el, colors) {
		var tl = new TimelineMax({
				onComplete: function() {
					tl.seek(0);
				}
			}),
			ttl = colors.length;

		for (var i = 0; i < ttl; i++) {
			tl.to(el, dur, {
				fill: colors[i]
			});
		}

		return tl;
	}
	/* ***
	Helper Methods
	*** */
function checkElement(idString) {
	var thisElement = document.getElementById(idString);
	return thisElement;
}
              
            
!
999px

Console