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({scaling:"fit", width:1024, height:768, color:darker, outerColor:dark});
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

	const holder = new Container(stageW, stageH).addTo().noMouse();

	// started off with points:20 and interactive true 
	// then recorded change below in keydown
	const points = [[0,0,0,0,-33.3,0,33.3,0],[69,66.7,0,0,-33.3,0,33.3,0],[137.9,0,0,0,-33.3,0,33.3,0],[206.9,66.7,0,0,-33.3,0,33.3,0],[275.9,0,0,0,-33.3,0,33.3,0],[344.8,66.7,0,0,-33.3,0,33.3,0],[413.8,0,0,0,-33.3,0,33.3,0],[482.8,66.7,0,0,-33.3,0,33.3,0],[551.7,0,0,0,-33.3,0,33.3,0],[620.7,66.7,0,0,-33.3,0,33.3,0],[689.7,0,0,0,-33.3,0,33.3,0],[758.6,66.7,0,0,-33.3,0,33.3,0],[827.6,0,0,0,-33.3,0,33.3,0],[896.6,66.7,0,0,-33.3,0,33.3,0],[978,121.2,0,0,-31.2,-6.5,31.2,6.5],[1057.1,31.3,0,0,4.2,68.4,-4.2,-68.4],[974.4,56.6,0,0,-16.6,-77.3,16.6,77.3],[1172.4,66.7,0,0,-33.3,0,33.3,0],[1241.4,0,0,0,-33.3,0,33.3,0],[1310.3,66.7,0,0,-33.3,0,33.3,0],[1379.3,0,0,0,-33.3,0,33.3,0],[1448.3,66.7,0,0,-33.3,0,33.3,0],[1517.2,0,0,0,-33.3,0,33.3,0],[1586.2,66.7,0,0,-33.3,0,33.3,0],[1655.2,0,0,0,-33.3,0,33.3,0],[1724.1,66.7,0,0,-33.3,0,33.3,0],[1793.1,0,0,0,-33.3,0,33.3,0],[1862.1,66.7,0,0,-33.3,0,33.3,0],[1931,0,0,0,-33.3,0,33.3,0],[2000,66.7,0,0,-33.3,0,33.3,0]];
	const path = new Squiggle({
		interactive:false, 
		points:points,
		thickness:2,
		color:grey,
		length:2000,
		dashed:[2,2]
	}).sca(4,3).center(holder);

	// // if doing this in CodePen 
	// // must set allowDefault:true in Frame parameters
	// frame.on("keydown", ()=>{
	//     car.recordPoints(true);
	// //  side.recordPoints(true);
	//     // below used to calculate when to put emitter on bottom as car loops
	//     // zog(car.percentComplete)
	// });    

	const points2 = [[0,0,0,0,-33.3,0,33.3,0],[69,66.7,0,0,-33.3,0,33.3,0],[137.9,0,0,0,-33.3,0,33.3,0],[206.9,66.7,0,0,-33.3,0,33.3,0],[275.9,0,0,0,-33.3,0,33.3,0],[344.8,66.7,0,0,-33.3,0,33.3,0],[413.8,0,0,0,-33.3,0,33.3,0],[482.8,66.7,0,0,-33.3,0,33.3,0],[551.7,0,0,0,-33.3,0,33.3,0],[620.7,66.7,0,0,-33.3,0,33.3,0],[689.7,0,0,0,-33.3,0,33.3,0],[758.6,66.7,0,0,-33.3,0,33.3,0],[827.6,0,0,0,-33.3,0,33.3,0],[896.6,66.7,0,0,-33.3,0,33.3,0],[978,121.2,0,0,-31.2,-6.5,31.2,6.5],[1051.9,42.3,0,0,0.8,64.3,-0.8,-64.3],[980.2,61.9,0,0,-14.8,-72,14.8,72],[1172.4,66.7,0,0,-33.3,0,33.3,0],[1241.4,0,0,0,-33.3,0,33.3,0],[1310.3,66.7,0,0,-33.3,0,33.3,0],[1379.3,0,0,0,-33.3,0,33.3,0],[1448.3,66.7,0,0,-33.3,0,33.3,0],[1517.2,0,0,0,-33.3,0,33.3,0],[1586.2,66.7,0,0,-33.3,0,33.3,0],[1655.2,0,0,0,-33.3,0,33.3,0],[1724.1,66.7,0,0,-33.3,0,33.3,0],[1793.1,0,0,0,-33.3,0,33.3,0],[1862.1,66.7,0,0,-33.3,0,33.3,0],[1931,0,0,0,-33.3,0,33.3,0],[2000,66.7,0,0,-33.3,0,33.3,0]]

	// you could make this match better 
	// by customizing points here https://zimjs.com/nio/paths.html
	const side = new Squiggle({
		interactive:false, 
		points:points2,
		thickness:10,
		length:2000,
		color:silver
	})
		.sca(4,3)
		.center(holder)
		.mov(0,-20);        

	// using speed to adjust the animation speed based on y position 
	// see https://zimjs.com/nio then EXTRA example for more 
	const car = new Circle(70,clear)
		.centerReg(holder)
		.animate({
			props:{path:path, speed:[.1,4,270,450]},
			time:40,
			ease:"linear",
			rewind:true,
			loop:true
		});
	// add segments to car
	new Tile(new Rectangle(30,100,clear,darker),2,1).center(car);

	side.setMask(car, true);

	// object frame is following must be in a container that holds the scene that will move
	holder.x = 4000;
	frame.follow({
		obj:car, 
		damp:.2, 
		dampY:.01
	});

	const emitter = new Emitter({
		obj:new Circle({min:2,max:10}, [green,red,grey,yellow]),
		force:2,
		random:{regX:{min:-50, max:50}}
	});
	Ticker.add(()=>{   
		let c = car.percentComplete; 
		let upside = (c>25&&c<27)||(c>73&&c<75);
		emitter.loc(car).mov(0,upside?40:-40);
	});
	
	const base = new Rectangle(420,200,darker,green.darken(.5),3).center(holder).loc(370, 480);
	new Label({
		align:CENTER,
		text:"ZIM\ncoaster",
		color:green.darken(.5),
		variant:true
	}).scaleTo(base,50).center(base).mov(0,15);
		

	// DOCS FOR ITEMS USED
	// http://zimjs.com/docs.html?item=frame
	// 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=Label
	// https://zimjs.com/docs.html?item=animate
	// https://zimjs.com/docs.html?item=loc
	// https://zimjs.com/docs.html?item=mov
	// https://zimjs.com/docs.html?item=sca
	// https://zimjs.com/docs.html?item=scaleTo
	// 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=Tile
	// https://zimjs.com/docs.html?item=Emitter
	// https://zimjs.com/docs.html?item=darken
	// https://zimjs.com/docs.html?item=zog
	// https://zimjs.com/docs.html?item=Ticker

	// FOOTER
	// call remote script to make ZIM icon - you will not need this
	createIcon(); 

}); // end of ready
              
            
!
999px

Console