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.






                const frame = new Frame();
frame.on("ready", ()=>{ // ES6 Arrow Function - similar to function(){}
    zog("ready from ZIM Frame"); // logs in console (F12 - choose console)

    // often need below - so consider it part of the template
    let stage = frame.stage;
    let stageW = frame.width;
    let stageH = frame.height;
    frame.color = frame.dark;

    // REFERENCES for ZIM at
    // see for video and code tutorials
    // see for documentation
    // see for INTRO to ZIM
    // see for INTRO to CODE

    // CODE HERE
		// ZIM VR
		// Takes content and displays it in left and right channels with position shift to look 3D.
		// This example is to be viewed in a VR headset that uses a mobile phone.
		// Have a good read over the docs at
		// On the PC, the content can be swiped for testing
		// but the visual effect is obviously not the same.
		// You can turn on the VR adjuster to help you bring the images closer together
		// so that you can use the cross-eyed technique to get a 3D effect.

		// PROPORTION - not really part of VR - just using to set depths and scales to circles
		// we will have six circles indexed 0 - 5
		// the 0 circle is the big orange one and the 5 circle is the small dark grey one
		// 0 circle will animate to 20 depth which is positive coming out of the screen (which is at 0)
		// 5 circle will animate to 5 depth so much less out of the screen
		// we will also animate the scale up to 2.1 for the outer circle and 1.2 for the inner circle
		// the rest of the circles animate proportionally between these bounds for both depth and scale
		// Proportion lets us do this without thinking:
		// baseMin, baseMax, targetMin, targetMax, factor, targetRound
   	const depth = new Proportion(0, 5, 20, 5);
   	const size = new Proportion(0, 5, 2.1, 1.2);

    // Prepare content
		// put inside one container with everything as if there is no depth shifting
		// keep content regX at 0 - which is the default - so do not centerReg() for instance
   	const content = new Container(stageW/2, stageH); // although it is okay to go outside these bounds
		// outer radius and true means to make the circles individual Circle objects rather than one shape
		// makeCircles is just a little function ZIM added for promotional purposes 
		// the circles are also used to show broken images ;-)
   	const circles = frame.makeCircles(50, true) 
    const label = new Label({
        text:"ZIM VIRTUAL REALITY",
        .centerReg(content, 0)
        .pos(null, stageH*.2)
        .dep(0); // screen depth

    // loop through the circles and give them depths
    // we can start them off in 3D already by giving them different starting depths
    // but we will start them at 0 and animate their depths
    loop(circles, function(circle, i, total) {
        // circle.dep((total-i)*3);

    // content, angle, distance, parallax, parallaxAngle, damp, parallaxDamp, 
		// startAngle, negativeParallax, boundaryMarkers, swiper, holder
    var vr = new VR({

    // optionally animate the circles - the text is child 0
    loop(vr.contentLeft.getChildAt(1), animateCircle);
    loop(vr.contentRight.getChildAt(1), animateCircle);
    function animateCircle(circle, i) {
            obj:{depth:depth.convert(i), scale:size.convert(i)},

    frame.on("resize", ()=>{

    // timeout(1000, function() {vr.remove(label)});
    // timeout(1000, function() {vr.position(circles.getChildAt(2), 50);});

    // stage.on("stagemousedown", ()=>{
    //     vr.showAdjuster();
    // });

    vr.on("boundaryout", e=>{
			frame.color = frame.yellow;

    vr.on("boundaryin", e=>{
        frame.color = frame.dark;
    // FOOTER
    // call remote script to make ZIM Foundation for Creative Coding icon
    createIcon(frame, 780, 600); 

}); // end of ready