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("fit", 1024, 768, darker, dark);
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
    // see for video and code tutorials
    // see for documentation
    // see for INTRO to ZIM
    // see for INTRO to CODE

    // CODE HERE
	  // ~~~~~~~~~~~~~~~~~
    // create the coils:
    const coil = new Container().center().mov(-150).drag({all:true});

    const top = new Rectangle({width:100, height:40, corner:20}).centerReg(coil);
    // [colors],[ratios], x0,y0, x1,y1 - x and y are for a line the gradient will follow
    top.linearGradient([dark,grey,light,grey,dark],[0,.2,.5,.8,1], 0,0, 0,40);

    const peg = new Rectangle(20,40).center(coil).mov(0,40);
    peg.linearGradient([light,darker],[.5,1], 0,0, 20,0);

    const slat = new Rectangle(60,16,null,grey,2).ske(20); // why not!
    slat.linearGradient([grey,light,dark],[0,.3,.7], 0,0, 60,0);

    const post = new Tile(slat, 1, 55).center(coil).loc(null, peg.y+peg.height).mov(-2);
    const coil2 = coil.clone().loc(coil).mov(400,-100).drag({all:true});
    const top2 = coil2.getChildAt(0); // top of cloned coil

    // ~~~~~~~~~~~~~
    // create cabinet and Dial

    let energy = 50;
    const cabinet = new Rectangle(200,250,null,tin,5,[80,80,0,0])
    // colors,ratios, x0,y0,radius0, x1,y1,radius1
    cabinet.radialGradient([grey,dark],[0,.8], 100,150,150, 200,0,0);
    var dial = new Dial({
        min:0, max:150, step:5,
        tickColor:silver, backgroundColor:light,
        .change(()=>{energy = dial.currentValue});
    dial.currentValue = energy;

    // ~~~~~~~~~~~~~
    // create and animate the electricity!

    var zaps = new Container()
        .sha(blue,0,0,20).addTo().bot().alp(0).animate({alpha:1}, 500);

    loop(2, i=>{
        new Squiggle({color:pink, points:6, controlType:"none", interactive:false}).addTo(zaps);

        zaps.loop(zap=>{ // loop through children in zaps container
            loop(zap.pointControls, (control, i, total)=>{ // loop squiggle points
                if (i==0) control.loc(top);
                else if (i==total-1) control.loc(top2);
                else {
                    // x and y of top are inside coil so use localToGlobal
                    var point = top.parent.localToGlobal(0,0);
                    var point2 = top2.parent.localToGlobal(0,0);
                    // find the x and y along a line between tops
                    var x = point.x+(point2.x-point.x)*i/(total-1);
                    var y = point.y+(point2.y-point.y)*i/(total-1);
                    // randomize location of point based on energy
                    control.loc(x+rand(-energy/2,energy/2), y+rand(-energy,energy));
            zap.update(); // update the squiggle when manually changing points
        }); // end point loop
    }); // end squiggle loop

		// make a greeting - come on in and join us on ZIM Slack!

		// call remote script to make ZIM Foundation for Creative Coding icon

}); // end of ready