123

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              const frame = new Frame("fit", 800, 600, "#555", "#555");
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

	// CODE HERE
	
	// THE ONE STATEMENT WOULD LOOK LIKE THIS:
	// new Pen({
	// 	damp:.8, 
	// 	draggable:false,
	//		color:series("#FCEEB5", "#EE786E")
	// })
	// 	.center()
	// 	.animate({
	// 		props:{path:new Squiggle().sca(2).center({add:false})}, 
	// 		time:2000, 
	// 		ease:"linear"
	// 	}).animate({
	// 		props:{size:50}, 
	// 		rewind:true,
	// 		time:1000
	// 	});
	
	// a series returns a function - so colors will be a function
	// every time the function is run, it gets the next thing in the series 
	// and wraps to the first thing again forever!
	var colors = series("#FCEEB5", "#EE786E", "#A2CCB6");

	const path = new Squiggle()
		.sca(2)
		.center({add:false})
		.mov(0,40);

	var pen = new Pen({damp:.8, draggable:false}).center();
	
	new Label({
		text:"ONE\nSTATEMENT", 
		font:"courier", 
		lineHeight:40, 
		align:"center"
	}).center().mov(0,-130).alp(.7);
	
	const again = new Button({
		label:"AGAIN",
		width:180,
		height:180,
		corner:90,
		color:dark,
		rollColor:light,
		backgroundColor:white,
		rollBackgroundColor:dark,
		shadowColor:-1
	}).sca(.5).center().alp(0).mov(0, 140).tap(()=>{
		make();
	});
	
	function make() {
		again.alp(0);
		pen.clear();	
		pen.loc(path.pointControls[0]); // move pen to beginning of path
		pen.immediate(pen.x, pen.y); // go there without drawing to there
		colors(); // cycle colors
		frame.color = colors();
		pen.color = series(colors(), colors());
		pen.animate({ // animate position
			props:{path:path},
			ease:"linear",
			time:2000
		})
		.animate({ // animate size
			props:{size:50},
			rewind:true,
			time:1000,
			call:()=>{
				again.animate({ // animate in the button
					props:{alpha:.8}, 
					time:500,
					wait:500
				});
			}
		});
	}
	make();


	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=Squiggle
	// https://zimjs.com/docs.html?item=Label
	// https://zimjs.com/docs.html?item=Button
	// https://zimjs.com/docs.html?item=tap
	// https://zimjs.com/docs.html?item=animate
	// https://zimjs.com/docs.html?item=mov
	// https://zimjs.com/docs.html?item=alp
	// https://zimjs.com/docs.html?item=sca
	// https://zimjs.com/docs.html?item=center
	// https://zimjs.com/docs.html?item=series
	// https://zimjs.com/docs.html?item=zog

	// FOOTER
	// call remote script to make ZIM Foundation for Creative Coding icon
	createIcon(frame); 

}); // end of ready
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console