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 frame = new Frame("fit", 1024, 768, blue, 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
	const stage = frame.stage;
	const stageW = frame.width;
	const stageH = frame.height;

	// REFERENCES for ZIM at https://zimjs.com
	// see https://zimjs.com/intro.html for an intro example
	// see https://zimjs.com/learn.html for video and code tutorials
	// see https://zimjs.com/docs.html for documentation
	// see https://codepen.io/topic/zim/ for ZIM on CodePen
	
	// *** NOTE: ZIM Cat defaults to time in seconds
	// All previous versions, examples, videos, etc. have time in milliseconds
	// This can be set back with TIME = "milliseconds" but we suggest you give it a try!
	// There will be a warning in the conslole if your animation is not moving ;-)

	// CODE HERE
	
	// Page is an easy way to get a gradient backdrop
	// or could use GradientColor, RadialColor, BitmapColor for more specific special colors:
	// new Rectangle(stageW, stageH, new GradientColor([blue, green], [0,1], 0,0, 0,stageH)).addTo();
	new Page(stageW, stageH, blue, green).addTo();
		
	// this is the Container that will be moved by Frame.follow() 
	// we put everything we want to move in here 
	// then we say what object in the container we want to keep in the middle (the blob)
	// and the whole container will be moved to feature the object.
	const scene = new Container().addTo();	
	
	// Made the squiggle in a couple minutes at https://zimjs.com/nio/paths.html
	const hose = new Squiggle({
		color:black, 
		points:[[-39.6,21.1,0,0,-55.5,10.6,55.5,-10.6],[46.8,53.9,0,0,-24.6,-7.4,45.8,13.8,"straight"],[85.7,22.8,0,0,28.1,0.8,-28.1,-0.8],[117.8,70,0,0,-49.9,38.8,23,-17.9,"straight"],[148.5,18.6,0,0,-22.3,2.1,20.1,-1.8,"straight"],[178.3,51.3,0,0,-22.8,11.3,20.3,-10.1],[224.4,38.4,0,0,-30.1,-26,30.1,26],[315.9,34.3,0,0,-53.9,-24.7,53.9,24.7]],
		interactive:false
	})
		.sca(8) // make it nice and long!
		// Squiggle and Blobs have a starting bounds 
		// but they do not change as a the objects are moved with bezier handles. 
		// In this case, we want to position objects at their ends (the gas pump and the handle) 
		// so we want proper bounds to easily place these. 
		// We can get good enough bounds with the following method.
		// Usually we do not need to do this.
		// Because we did not provide the Container bounds when we made it, 
	 	// The container will take the dimensions of what we put in it.
		.approximateBounds() 
		.addTo(scene);
	
	const pump = new Rectangle(400,900,black,null,null,[100,100,0,0])
		// pos of 0 at the left would put the left of the gas pump at the left of the hose 
		// so move it over so it is mostly off the hose to the left
		.pos(-350,0,LEFT,CENTER,scene);
	
	const handle = new Rectangle(150,100)
		// pos of 0 to the right would put the right of the handle to the right of the hose 
		// we want to move it more outside the region so that is a negative pos amount 
		// as a positive pos amount would be the distance of the right of the handle from the right of the hose 
		// so... normally when we pos things within a container it is easy - how far from the edge 
		// but if we want to pos something more outside the container - just use negative numbers
		// There are many ways to place things in ZIM - see https://codepen.io/zimjs/pen/VwYWMEv
		.pos(-130,-140,RIGHT,CENTER,scene)
		.rot(30);
	const ring = new Circle(50, clear, black, 20).pos(0,-50,CENTER,BOTTOM,handle);
	const spout = new Rectangle(100,50).pos(-80,-10,RIGHT,CENTER,handle).rot(10);
	
	
	const blob = new Blob({
		color:black, 
		points:[[-59.5,-52.7,0,0,-59.1,28.2,59.1,-28.2,"mirror"],[100,0,0,0,0,-50,0,50,"mirror"],[-51.4,68.8,0,0,56,22.2,-56,-22.2,"mirror"]],
		interactive:false
	})
		.reg(30)
		.center(scene)
		.mov(-300)
		.sca(.2)
		.animate({ // animate the scale at both ends
			props:{scale:.8},
			time:2,
			rewind:true,
			rewindWait:6,
			loopWait:3,
			loop:true			
		})
		.animate({ // make the blob follow the hose
			props:{path:hose},
			time:10,
			loop:true,
			loopWait:3,
			loopWaitCall:()=>{gas.spurt(40);} // spurt the emitter as the loop starts waiting
		});
	
	// wiggle the rotation of the points on the blob
	loop(blob.pointControls, control=>{
		control.wiggle("rotation", 0, 10, 30, .2, 1)	
	});
	// coded changes to Blob and Squiggle need an update() - do this constantly in a Ticker function
	Ticker.add(()=>{
		blob.update();
	});	
	
	// Here is the blob for a smoke puff - made at https://zimjs.com/nio/paths.html
	// based on a cloud that is provided there
	var puff = new Blob({
		color:[white,lighter,moon],
		borderColor:dark,
		borderWidth:5,
		points:[[-70.2,-20.4,0,0,-28.1,-14.9,-21.1,-33.5,"mirror"],[-63,-94.4,0,0,-27.2,15,27.2,-15,"mirror"],[4.6,-64.3,0,0,-1.8,-36,49.2,-33.4,"mirror"],[71.5,-29.2,0,0,6.2,-34.3,33.4,-17.6,"mirror"],[132.3,29.6,0,0,-0.4,-31.4,0.4,31.4,"mirror"],[52.1,60.3,0,0,37.5,46.1,-8.3,45.5,"free"],[-57.7,49.6,0,0,25,94,-27.4,28.2,"free"],[-131.1,29.6,0,0,7,26.8,-7,-26.8,"mirror"]],
		interactive:false
	}).approximateBounds(); // on mobile, emitter will cache blob so make sure bounds are correct
	
	// emit the cloud puff - starting paused (we spurt in the animation call above)
	const gas = new Emitter({
		obj:puff,
		startPaused:true,
		interval:.1,
		animation:{
			set:{scale:0}, 
			props:{scale:{min:.3, max:1}}, 
			time:.3
		},
		gravity:-5,
		random:{
			alpha:{min:.3, max:.7}, // power of ZIM VEE
			rotation:[0,180] // power of ZIM VEE, etc.
		},
		num:2,
		force:2,
		life:3,
		layers:"random",
		angle:{min:-90, max:0}
	}).loc(spout, null, scene).mov(70,130);
	
	// tell the frame to follow the blob (will do so by shifting the blob's container)
 	frame.follow(blob); 

	// FOOTER
	// call remote script to make ZIM icon - you will not need this
	createIcon(); 
	
	// DOCS FOR ITEMS USED
	// 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=Squiggle
	// https://zimjs.com/docs.html?item=Blob
	// https://zimjs.com/docs.html?item=Page
	// https://zimjs.com/docs.html?item=animate
	// https://zimjs.com/docs.html?item=wiggle
	// https://zimjs.com/docs.html?item=loop
	// https://zimjs.com/docs.html?item=pos
	// https://zimjs.com/docs.html?item=loc
	// https://zimjs.com/docs.html?item=mov
	// https://zimjs.com/docs.html?item=rot
	// 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=center
	// https://zimjs.com/docs.html?item=Emitter
	// https://zimjs.com/docs.html?item=GradientColor
	// https://zimjs.com/docs.html?item=zog
	// https://zimjs.com/docs.html?item=Ticker

}); // end of ready


              
            
!
999px

Console