Pen Settings

HTML

CSS

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

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

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.

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 frame = new Frame("fit", 1024, 768, darker, darker);
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
	
	// Thanks Natasya Hopkins for the original post: Proximity Effect with GSAP
	// it is well coded at https://codepen.io/natasya/pen/OJRXKja
	// This code is 2637 characters using HTML, CSS, JS and GreenSock GSAP

	// The ZIM code is 582 characters (782 with the ZIM template)
	// Which is 22% the size the developer would code - and we think more readable

    // CODE HERE
	const colors = [orange, red, purple, pink, blue, green];
	const scales = [.8,1.7,.8,1.5,.8,1.5];
	const locs = [{x:175,y:476},{x:287,y:209},{x:648,y:209},{x:796,y:295},{x:731,y:524},{x:344,y:564}];
	const rectangles = new Container().addTo();
	loop(6, i=>{
		let rect = new Rectangle(176,98,colors[i])
			.centerReg(rectangles) // so they scale from the center
			.loc(locs[i])
			.sca(scales[i])
			// .place(); // used place to position and look at console for x,y
		rect.pd = new ProportionDamp(0,400,1.25,1); // baseMin, baseMax, targetMin, targetMax
		// to stop the boxes animating at start 
		// an immediate value would need to be added to pd
		// as currently they damp to 0,0 of mouse starting position
		// but I liked the initial animation
		// rect.pd.immediate(dist(rect.x, rect.y, 0, 0));
	});
	Ticker.add(()=>{
		rectangles.loop((rect,i)=>{
			let d = dist(rect.x, rect.y, frame.mouseX, frame.mouseY);
			// the objects are scaled already 
			// so multiply the conversion by the original scale
			rect.scale = scales[i]*rect.pd.convert(d);
		});
	});   
  
    // DOCS FOR ITEMS USED
	// https://zimjs.com/docs.html?item=Frame
	// https://zimjs.com/docs.html?item=Container
	// https://zimjs.com/docs.html?item=Rectangle
	// https://zimjs.com/docs.html?item=loop
	// https://zimjs.com/docs.html?item=loc
	// 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=place
	// https://zimjs.com/docs.html?item=dist
	// https://zimjs.com/docs.html?item=ProportionDamp
	// https://zimjs.com/docs.html?item=zog
	// https://zimjs.com/docs.html?item=Ticker
  
    // FOOTER
    // call remote script to make ZIM Foundation for Creative Coding icon
    createIcon(); 
	createGreet();

}); // end of ready
              
            
!
999px

Console