Pen Settings



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


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


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.


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.


                <div id="canvasStage"></div>


                body {background-color:black; color:#FFF;}
#canvasStage {
#canvasStage canvas{


var log = console.log.bind(console)

var canvasElement = "myCanvas";
var canvasHolder = "canvasStage";
var holder1 = $("#"+canvasHolder);//

var resolution = window.devicePixelRatio || 1;
var requestId = null;

for (var i = 0; i < 8; i++) {
	var myEl = (canvasElement+"_"+i);
	// var myC = '<canvas id="' + myEl + '" width="106" height="106"></canvas>';
  var canvas = document.createElement("canvas");
  var context = canvas.getContext("2d");
  // Scale canvas to match pixel ratio for HiDPI screens = myEl;
  canvas.width  = 106 * resolution;
  canvas.height = 106 * resolution;  = 106 + "px"; = 106 + "px";  
  context.scale(resolution, resolution); 
	// holder1.append($(myC));
	// var element1 = document.querySelector("#"+myEl);
	// var context = element1.getContext("2d");
	context.moveTo(51, 3);
	context.lineTo(3, 103);
	context.lineTo(103, 103);
	// the outline
	context.lineWidth = 5;
	context.strokeStyle = '#444';
	// the fill color
	context.fillStyle = "#00F";
This animation by
Made possible by GreenSock Animation Platform (GSAP) v12 beta.

This effect works great in modern browsers: Chrome, Safari, and FireFox.

IE does not support transform-style:preserve3d, so the 3D may look a little flat. 
Once again IE proves its ability to hinder progress and inflict pain on developers.

var tl = new TimelineMax({ onStart: updateCube, repeat:-1, smoothChildTiming:true})

var triangles = $("#canvasStage canvas");
	myHolder = $("#canvasStage"),
    // tl = new TimelineMax({onUpdate:updateCube, repeat:-1, smoothChildTiming:true}),
	stageW = ($(window).width())/2,
	stageH = ($(window).height())/2,
	stageX = (stageW-(106/2)),
	stageY = (stageH-(106/2));
//transformPerspective gives the element its own vanishing point
//perspective allows all the child elements (orange boxes) to share the same vanishing point with each other
//transformStyle:"preserve3d" allows the child elements to maintain their 3D position (noticeable only when their parent div is rotated in 3D space)
TweenMax.set(myHolder, {css:{transformPerspective:4000, transformStyle:"preserve-3d", transformOrigin:"52px 52px 52px"}});
// TweenLite.set(myHolder, {rotationY:0, rotationX:0, x:0, y:0, transformOrigin:"52px 52px 52px"});

tl.set(triangles[0], {rotationX:30.5, rotationY:0, rotationZ:0, x:0, y:2, z:52, opacity:0.85, transformOrigin:"50% 100%"})
  .set(triangles[1], {rotationX:30.5, rotationY:0, rotationZ:180, x:0, y:-2, z:52, opacity:0.85, transformOrigin:"50% 100%"})
  .set(triangles[2], {rotationX:30.5, rotationY:90, rotationZ:0, x:52, y:2, z:0, opacity:0.85, transformOrigin:"50% 100%"})
  .set(triangles[3], {rotationX:30.5, rotationY:270, rotationZ:180, x:52, y:-2, z:0, opacity:0.85, transformOrigin:"50% 100%"})
  .set(triangles[4], {rotationX:30.5, rotationY:-90, rotationZ:0, x:-52, y:2, z:0, opacity:0.85, transformOrigin:"50% 100%"})
  .set(triangles[5], {rotationX:30.5, rotationY:-270, rotationZ:180, x:-52, y:-2, z:0, opacity:0.85, transformOrigin:"50% 100%"})
  .set(triangles[6], {rotationX:30.5, rotationY:180, rotationZ:0, x:0, y:2, z:-52, opacity:0.85, transformOrigin:"50% 100%"})
  .set(triangles[7], {rotationX:30.5, rotationY:180, rotationZ:180, x:0, y:-2, z:-52, opacity:0.85, transformOrigin:"50% 100%"})
  // .set(myHolder, {rotationY:0, rotationX:0, x:0, y:0, transformOrigin:"52px 52px 52px"});

triangles.each(function (index, element) {
  var hoverTween =, 0.15, {opacity:0.33, paused: true });
			$(element).hover(over, out);
			function over(){;
				//, 0.15, {opacity:0.33});
			function out(){
				//, 0.15, {opacity:0.85});
//, 15, {css:{rotationY:720, rotationX:360, rotationZ:-360, transformOrigin:"52px 52px 52px"}, ease:Power0.easeNone});
for (var i = 0; i < 8; i++) {[i], 2, {rotationX:-24, transformOrigin:"50% 100%", repeat:-1, yoyo:true, repeatDelay:2,  ease:Power0.easeNone,});

$(window).resize(function() {
  // If there's not a pending request, create one
  if (!requestId) {
    requestId = requestAnimationFrame(updateCube);

function updateCube(){
	stageW = ($(window).width())/2;
	stageH = ($(window).height())/2;
	stageX = (stageW-(106/2));
	stageY = (stageH-(106/2));, 3, {css:{x:stageX, y:stageY}});
  // Clear request
  requestId = null;