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 asset = "pattern.jpg";
const path = "https://s3-us-west-2.amazonaws.com/s.cdpn.io/2104200/";

const frame = new Frame("fit", 960, 960, "#000", "#333", asset, path);
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
		// the backings zoom in and out according to these boundaries
		let backingScale = 1;
		const backingMin = .45;
		const backingMax = 2;
		// the rotation speeds
		const rotationAmount = .05; // holder
		const innerRotationAmount = .15; // triangles
		// the edge length of a triangle in the hexagon
		const length = 200;
		const height = length/2*Math.sqrt(3); // grade 9

    // Hexagon class made with Triangle objects
    class Hexagon extends Container {
        constructor() {
            let angle = 0;
            let lastScale = 1;
            loop(6, i=>{
                let tc = new Container().addTo(this);
                let triangle = new Triangle(length, length, length)
                    .reg(null, 0);
                lastScale *= -1; // mirror adjacent triangles
										.sca(lastScale, 1)
                tc.rotation = angle;
                angle += 60;

    // overall holder
    const holder = new Container().center();

    // container to hold image pattern so we can rotate and scale image inside
    const pattern = new Container();
		const backing = frame.asset("pattern.jpg")
        .loc(0, height/2)

    // make the hexagons with triangles that mask the backings
    const patterns = []; // this will hold all pattern containers made
    const across = Math.ceil(stageW/length);
    const down = Math.ceil(stageH/height)+7; // fudge for rotation
    loop(across, i=>{
        loop(down, j=>{
            new Hexagon().addTo(holder)
                // obviously set the loc as follows:
                .loc(i*length*3+j%2*length*1.5, j*height);
    // write this code based on numbers in your dream
    holder.reg(holder.width/2-length*1.5, holder.height/2-height*2);

    // make backgrounds zoom in and out
    // and rotate and also rotate the overall holder
    let zoom = true;
        if (zoom) {
            backingScale *= 1.002;
            if (backingScale > backingMax) {
                zoom = false;
                backingScale = backingMax;
        } else {
            backingScale *= .998;
            if (backingScale < backingMin) {
                zoom = true;
                backingScale = backingMin;
        loop(patterns, pattern=>{
            let backing = pattern.getChildAt(0).sca(backingScale);
            backing.rotation += innerRotationAmount;
        holder.rotation += rotationAmount;
		// https://zimjs.com/docs.html?item=Frame
		// https://zimjs.com/docs.html?item=Container
		// https://zimjs.com/docs.html?item=Triangle
		// https://zimjs.com/docs.html?item=loop
		// https://zimjs.com/docs.html?item=reg
		// https://zimjs.com/docs.html?item=sca
		// https://zimjs.com/docs.html?item=addTo
		// https://zimjs.com/docs.html?item=centerReg
		// https://zimjs.com/docs.html?item=center
		// https://zimjs.com/docs.html?item=setMask
		// https://zimjs.com/docs.html?item=loop
		// https://zimjs.com/docs.html?item=zog
		// https://zimjs.com/docs.html?item=Ticker

}); // 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.