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", 1280, 840, black, black);
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;
	
	// The creation of this code was recorded live in a two part ZIM Explore:
	// https://www.youtube.com/watch?v=4ZbbhkEI35c
	// https://www.youtube.com/watch?v=FXm1PxAlT1o

	// 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

	// We are updating many Dial and Sliders at .1 second interval 
	// These would automatically update the stage for EACH ONE! 
	// This slows down the animation of the electricity, etc.
	// So set OPTIMIZE to true which tells components not to update the stage 
	// as we are already updating the stage in a single Ticker function
	OPTIMIZE = true;

	// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// TILES
	
	// obj, cols, rows, spacingH, spacingV
	const tile = new Tile(new Rectangle(200,200,dark,null,null,15), 6, 4, 10, 10)
		.center();

	STYLE = {
		interactive:false, // for blobs to not be interactive
		sound:true, // special style for sliders and dials to look like sound tools
		useTicks:true,
		innerColor:red,        
		delayPick:true,
		accentColor:red,
		accentBackgroundColor:black,
		barLength:150,
		type:{
			Dial:{backgroundColor:darker} // specific to Dial otherwise slider button gets it
		}
	}

	const parts = new Tile({
		obj:[new Dial(), new Slider()], // ZIM VEE to pick randomly
		cols:6, 
		rows:4, 
		spacingH:10, 
		spacingV:10,
		colSize:210,
		rowSize:210,
		align:CENTER,
		valign:CENTER
	}).center().noMouse(); // make them not interactive


	// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// FRANKIE

	// backing
	new Rectangle(410, 410, grey, null, null, 10).center();

	// bolt
	new Rectangle(150,20,silver).loc(565, 574);
	new Rectangle(20,40,silver).loc(558, 563);
	new Rectangle(20,40,silver).loc(558+140, 563);

	// neck
	const neck = new Rectangle(80,100,purple.darken(.8))
	.center()
	.mov(0,156);

	// head
	const head = new Rectangle(180,300,purple.darken(.3), purple.darken(.8), 5, 60)
	.center()
	.mov(0,-20);

	// eyes
	new Rectangle(40,60,black).loc(583, 364);
	new Rectangle(40,60,black).loc(583+70, 364);    
	const leftEye = new Rectangle(60,30,dark,black,3).loc(573, 381);
	const rightEye = new Rectangle(60,30,dark,black,3).loc(573+70, 381);

	// hair
	// recorded at https://zimjs.com/nio/paths.html (PIZZAZZ 04)
	const hairPoints = [[-91.9,-123.9,0,0,-83.6,1.8,33,-0.7,"mirror"],[140.8,-88.4,0,0,-35.7,-17.6,35.7,17.6],[168.5,91.5,0,0,-0.4,-55.4,-38.6,-55.5,"free"],[68.1,83.9,0,0,28.6,-67.4,-20.8,-63,"free"],[-38.5,76.7,0,0,22.7,-40.5,-11.5,-82.9,"free"],[-144,78.5,0,0,27.9,-37.2,0.3,-62.8,"free"]];
	new Blob(black, null,null, hairPoints)
		.sca(.65)
		.loc(633, 301);

	// teeth    
	const teeth = new Tile(new Rectangle(10,20,series(dark,grey)), 9,2).center().ske(15).mov(5,60)


	// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// ELECTRICITY

	// recorded at https://zimjs.com/nio/paths.html (PIZZAZZ 04)
	const electricPoints = [[-85,2.7,0,0,0,0,0,0,"none"],[-10.2,-15.2,0,0,0,0,0,0,"none"],[112.6,18.5,0,0,0,0,0,0,"none"],[205.7,2.1,0,0,0,0,0,0,"none"],[128.7,38.3,0,0,0,0,0,0,"none"],[8.9,3.7,0,0,0,0,0,0,"none"],[-105.9,23.3,0,0,0,0,0,0,"none"],[-198.6,-1.6,0,0,0,0,0,0,"none"]];
	const electric = new Blob({
		color:white,
		points:electricPoints
	}).sca(4).ble("difference").center();
	const electric2 = electric.clone().ble("difference").center();

	// loop through points and wiggle them
	loop(electric.pointControls, point=>{
		point.wiggle("y", point.y, 20, 100, .2, .8);
	});    
	loop(electric2.pointControls, point=>{
		point.wiggle("y", point.y, 20, 100, .2, .8);
	});
	// Blob (and Squiggle) needs to be updated if changed with code
	Ticker.add(() => {
		electric.update();
		electric2.update();
		stage.update();
	});

	// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// LOADING 

	const total = 10;
	interval(.1, obj=>{
		parts.loop(part=>{
			part.currentValue = obj.count*.1;
		}); 
		if (obj.count == obj.total) {
			loaded();
		}      
	}, total/.1);

	function loaded() {
		stopAnimate();
		parts.removeFrom();
		tile.removeFrom();		
		electric.removeFrom();
		electric2.removeFrom();
		head.color = green.darken(.3);
		neck.color = green.darken(.7);
		leftEye.color = orange.lighten(.1);
		rightEye.color = orange.darken(.1);
		interval({min:.05,max:.3}, obj=>{
			if (obj.count%2==0) {
				leftEye.color = orange.lighten(.1);
				rightEye.color = orange.darken(.1);
			} else {
				leftEye.color = orange.darken(.1);
				rightEye.color = orange.lighten(.1);
			}
		});
		const toothColor = series(white,light);
		teeth.loop(tooth=>{
			tooth.color=toothColor();
		});
		teeth.alp(.8);
		new Label({
			text:"I'M LOADED!",
			size:70,
			color:yellow,
			italic:true 
		}).pos(0,100,CENTER);
		emitter.spurt(50);
	}

	const emitter = new Emitter({
		// radius, sides, pointSize, color
		num:5,
		// ZIM VEE values (Pick) for dynamic parameters 
		// types: {range}, [random], series(), function(){return}
		obj:new Poly({min:50,max:200}, [6,7,8], {min:.6, max:.9}, [white, white, white, yellow, orange]),
		force:{min:5, max:20},
		startPaused:true,
		random:{
			// make them start all over rather than all at center
			regX:{min:-100,max:100},
			regY:{min:-50,max:50},
		}
	}).center();	

	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=Rectangle
	// https://zimjs.com/docs.html?item=Poly
	// https://zimjs.com/docs.html?item=Blob
	// https://zimjs.com/docs.html?item=Label
	// https://zimjs.com/docs.html?item=Slider
	// https://zimjs.com/docs.html?item=Dial
	// https://zimjs.com/docs.html?item=noMouse
	// https://zimjs.com/docs.html?item=stopAnimate
	// 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=ble
	// https://zimjs.com/docs.html?item=ske
	// https://zimjs.com/docs.html?item=sca
	// https://zimjs.com/docs.html?item=removeFrom
	// https://zimjs.com/docs.html?item=center
	// https://zimjs.com/docs.html?item=Tile
	// https://zimjs.com/docs.html?item=Emitter
	// https://zimjs.com/docs.html?item=interval
	// https://zimjs.com/docs.html?item=series
	// https://zimjs.com/docs.html?item=lighten
	// https://zimjs.com/docs.html?item=darken
	// https://zimjs.com/docs.html?item=zog
	// https://zimjs.com/docs.html?item=STYLE
	// https://zimjs.com/docs.html?item=OPTIMIZE
	// 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