Pen Settings



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


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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


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.






                const assets = "star.png";
const path = "";
const frame = new Frame("fit", 1024, 768, black, black, 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;

	// see for video and code tutorials
	// see for documentation
	// see for INTRO to ZIM
	// see for INTRO to CODE


	const stars = new Container(stageW, stageH).addTo();
	loop(6, ()=>{		
		// create the starts from the start.png spritesheet asset that is 5 cols and 6 rows
		new Sprite(asset("star.png"), 5, 6).centerReg(stars).run({loop:true});

	// this is where we draw the noise image
	const shape = new Shape(stageW, stageH).addTo();

	// this will hold a copy of the image as we fade out
	const bmp = new Bitmap().addTo();

	// here is our Noise object
	const noise = new Noise();

	const lines = stars.numChildren+1; // how many lines we will draw
	const height = 300; // how far up or down the end of the line is allowed to be
	const step = .006; // the step we will increase for the second parameter of simplex2D
	let j = 0; // the value for the second parameter of simplex2D
	let count = 0; // ticker count used to keep track of how many lines we have made (so we can clear when too many)

	// animate the noise and patterns made from the noise
	Ticker.add(function() {
		j += step; // increase second parameter by just a little to animate the line
		// if we are writing the Shape to a Bitmap we need to put the alpha differences in the Shape itself
		// if we JUST want to see the shape, we can set the alpha of the shape
		// but we are writing it to a Bitmap as well to fade it out...
		// It is no big deal, we just draw with lower alpha right in the Shape
		shape.s("rgba(255,255,255,.15)").ss(2).mt(0, stageH/2);
		loop(lines-1, i=>{ // last line we will draw to middle of stageH
			let x = (i+1)*stageW/lines;
			// ask for the noise at position i that is animated in time by the small amount j
			let y = stageH/2 + noise.simplex2D(i,j)*height;, y);
			// place a star at the y pos
			stars.getChildAt(i).loc(x, y);
		});, stageH/2); // last line
		// we have drawn enough pattern, so cache the shape and make the Bitmap hold the cacheCanvas
		// and then uncache the shape and fade the Bitmap out - also clear the Shape
		if (count%200==0) {
			bmp.image = shape.cacheCanvas;
			bmp.alpha = 1;
			bmp.animate({alpha:0}, 2000);
	new Label("Happy Holidays from ZIM!", 24, null, white)

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


	// call remote script to make ZIM Foundation for Creative Coding icon
	greet = createGreet().animate({wait:1000, props:{alpha:0}, time:500});
}); // end of ready