Pen Settings

HTML

CSS

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

JavaScript

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

Packages

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.

Behavior

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.

HTML

              
                
              
            
!

CSS

              
                
              
            
!

JS

              
                const assets = "grapefruit.jpg";
const path = "https://s3-us-west-2.amazonaws.com/s.cdpn.io/1604712/";
const frame = new Frame("fit", 1024, 683, "#000", "#000", assets, 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
	
		const grapefruit = frame.asset("grapefruit.jpg")
					.addTo()
					.animate({
							props:{alpha:0},
							wait:1300,
							time:700,
							rewind:true,
							loop:true,
							rewindWait:400,
							loopWait:400
					});

			const radius = 9;
			const spacing = 6;
			const cols = Math.ceil(stageW/(radius*2+spacing));
			const rows = Math.ceil(stageH/(radius*2+spacing));
			const tiles = new Tile(new Circle(radius,black,black), cols, rows, spacing, spacing)
					.center()
					.alp(0)
					.animate({
							props:{alpha:1},
							wait:1300,
							time:700,
					});
			tiles.loop(tile=>{
					tile.color = grapefruit.getColorAt(tile.x,tile.y)
			});

			stage.on("stagemousedown", ()=>{
					grapefruit.pauseAnimate(!grapefruit.paused);
			});

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

			// DOCS FOR ITEMS USED
			// https://zimjs.com/docs.html?item=Frame
			// https://zimjs.com/docs.html?item=Circle
			// https://zimjs.com/docs.html?item=Tile
			// https://zimjs.com/docs.html?item=animate
			// https://zimjs.com/docs.html?item=pauseAnimate
			// https://zimjs.com/docs.html?item=loop
			// https://zimjs.com/docs.html?item=alp
			// https://zimjs.com/docs.html?item=addTo
			// https://zimjs.com/docs.html?item=center
			// https://zimjs.com/docs.html?item=timeout
			// https://zimjs.com/docs.html?item=zog


			// FOOTER
			// make a greeting - come on in and join us on ZIM Slack!
			timeout(5000, ()=>{
					createGreet(); 
			});	

			// call remote script to make ZIM Foundation for Creative Coding icon
			createIcon(); 

}); // end of ready
              
            
!
999px

Console