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", 1024, 768, "#ccc", "#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
    const content = new Container(stageW, stageH).addTo();
    const layers = new Container(stageW, stageH-50).loc(0,50); // keep the layer titleBars under the top bar

    // styles are optional - any DisplayObject parameters can be used as a style
    // these styles are applied to a type of object
    // styles can also be applied in general (put them outside type:{}) or to a group id (like a class in CSS)
    STYLE = {
                // titleBarHeight:30,
                // titleBarWidth:70,
                // size:14,
                titleBarX:0, // this will start the titleBars docked to the left edge (optional)
                titleBarY:series(50, 100, 150, 200), // each title bar made gets the next in the series
                titleBarContainer:layers // this requires layers to exist - which it does above
                // use a series to apply the color and radius in order of Blob creation
                color:series(blue, blue, darker, darker, red, convertColor(dark, "rgba", .3)),
                radius:series(50,50,30,30,50,30), onTop:false, showControls:false
            CheckBox:{size:22, startChecked:true, color:light}

    const head = new Layer(500, 500, "HEAD").center(content);
    new Circle(250, brown).center(head); // or we could apply transform to scale head independently of Layer scale
    new Circle(200, white).alp(.2).center(head).mov(0,20).transform({onTop:false, visible:false});

    const eyes = new Layer(300,100,"EYES").center(head).mov(0,-60);
    new Blob().center(eyes).mov(-100);
    new Blob().center(eyes).mov(100);
    new Blob().center(eyes).mov(-100);
    new Blob().center(eyes).mov(100);

    const nose = new Layer(350,220,"NOSE").center(head).mov(0,50);
    new Triangle(70,150,150,dark).alp(.3).center(nose).pos(null,0).transform({onTop:false, visible:false});
    new Squiggle({color:dark, thickness:5, points:3, showControls:false})
        .transformPoints("scaleY", .5)

    const mouth = new Layer(250,120,"MOUTH").center(head).mov(0,160);
    new Blob().center(mouth);
    new Blob().center(mouth);

    // TOP BAR
    new Rectangle(stageW, 50, dark).addTo();
    new Label({text:"ZIM Head", color:white}).sca(.7).alp(.7).pos(20,14);
    new CheckBox({label:"LAYERS"}).pos(20, 12, true).change((e)=>{
        layers.visible = e.target.checked;
        // the code below would hide the ghosts when the layers are hidden
        // layers.loop(function (titleBar) {
        //     if (!layers.visible || ghosts.checked) titleBar.layer.transformControls.toggleGhost(layers.visible);
        // });
    const ghosts = new CheckBox({label:"GHOSTS"}).pos(150, 12, true).change(function (e){
    let docked = true;
    new CheckBox({label:"DOCK"}).pos(300, 12, true).change(function (e) {
        docked = !docked;
            var layer = titleBar.layer;
            if (docked) layer.titleBarPos(layer.titleBarStartX, layer.titleBarStartY);
            else layer.resetTitleBar();
            layer.titleBarDraggable = !docked;

    stage.update(); // this is needed to show any changes


    stage.update(); // this is needed to show any changes
    // https://zimjs.com/docs.html?item=Frame
    // https://zimjs.com/docs.html?item=Container
    // https://zimjs.com/docs.html?item=Circle
    // https://zimjs.com/docs.html?item=Rectangle
    // https://zimjs.com/docs.html?item=Triangle
    // https://zimjs.com/docs.html?item=Squiggle
    // https://zimjs.com/docs.html?item=Blob
    // https://zimjs.com/docs.html?item=Label
    // https://zimjs.com/docs.html?item=CheckBox
    // https://zimjs.com/docs.html?item=Layer
    // https://zimjs.com/docs.html?item=change
    // https://zimjs.com/docs.html?item=transform
    // https://zimjs.com/docs.html?item=loop
    // https://zimjs.com/docs.html?item=pos
    // https://zimjs.com/docs.html?item=mov
    // https://zimjs.com/docs.html?item=alp
    // https://zimjs.com/docs.html?item=rot
    // https://zimjs.com/docs.html?item=sca
    // https://zimjs.com/docs.html?item=addTo
    // https://zimjs.com/docs.html?item=center
    // https://zimjs.com/docs.html?item=loop
    // https://zimjs.com/docs.html?item=convertColor
    // https://zimjs.com/docs.html?item=transformPoints
    // https://zimjs.com/docs.html?item=zog
    // https://zimjs.com/docs.html?item=STYLE
    // FOOTER
    // call remote script to make ZIM Foundation for Creative Coding icon
    createIcon(frame, 780, 600); 

}); // end of ready
🕑 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.