123

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              const frame = new Frame("fit", 800, 600, "#000", "#555");
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;

    // REFERENCES for ZIM at http://zimjs.com
    // see http://zimjs.com/learn.html for video and code tutorials
    // see http://zimjs.com/docs.html for documentation
    // see https://www.youtube.com/watch?v=pUjHFptXspM for INTRO to ZIM
    // see https://www.youtube.com/watch?v=v7OT0YrDWiY for INTRO to CODE

    // CODE HERE
   
    // we will make a bunch of circles and each time we want to get the next color in this array
    // so we can use a ZIM series which is a function that returns the next item in an array
    var colors = makeSeries([blue, pink, green, yellow]);

    // make a new parallax object
    var parallax = new Parallax();

    // a zim loop - just an easier format than a traditional for loop
    loop(7, (i)=>{

        // make circles from big to small
        // note we use the series for the color
        var circle = new Circle((i+2)*(i+2)*3, colors()).center(stage, 0);

        // add the circle to the parallax
        // set property, change of property and input (default is mouseX)
        parallax.addLayer({
            obj:circle,
            prop:"x",
            propChange:i*40
        });
        parallax.addLayer({
            obj:circle,
            prop:"y",
            input:"mouseY",
            split:true,
            propChange:i*10
        });
        parallax.addLayer({
            obj:circle,
            prop:"scale",
            propChange:2,
            input:"mouseY"
        });

        // mask the last one - really need to nest circles too - but this will do
        // the true parameter is for dynamic masks
        // it defaults to false except when using drag() and animate()
        if (i>0) stage.getChildAt(1).setMask(stage.getChildAt(0), true);
    });    

    stage.update(); // this is needed to show any changes
  
    // DOCS FOR ITEMS USED
    // http://zimjs.com/docs.html?item=parallax
    // http://zimjs.com/docs.html?item=loop
    // http://zimjs.com/docs.html?item=makeSeries
    // http://zimjs.com/docs.html?item=Circle
    // http://zimjs.com/docs.html?item=setMask
    // http://zimjs.com/docs.html?item=frame
  
    new Label({text:"Detail View", color:light, rollColor:white})
      .pos(620, 30, stage)
      .cur()
      .alp(.9)
      .sca(.8)
      .on("click", ()=>{zgo("https://codepen.io/zimjs/details/ajRNVM", "_blank");});
  
    // FOOTER
    // call remote script to make ZIM Foundation for Creative Coding icon
    createIcon(frame); 

}); // end of ready
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console