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("fit", 1024, 768, "#EEE", "#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
	// 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

   // Make 100 stars
	var items = [];
	loop(100, ()=>{ // just like a for() loop but easier - given i in brackets if needed
		items.push(
			new Poly({
				radius:{min:30, max:100}, // ZIM VEE (Pick) values
				sides:[5,6,7,8,9], // will randomly pick (or use series())
				pointSize:{min:.5, max:.7},
				color:[pink, green, blue, yellow]
			})
		);
	});

   // Make a List with the items
	const source = new List(300,600,items).center().mov(-300);

   // Make an empty list to hold picked items
	const target = new List(250,400,[]).center().mov(50);

   // Make a Container to hold the final picked item!
	const final = new Container(200,200).center().mov(350).sha();
	new Rectangle(200,200,dark).addTo(final);



	// When we tap the source List, add the selected item to the target List
	source.tap(()=>{
		source.removeAt(1, source.selectedIndex); // one item
		target.addAt(source.selected, target.length); // add to end
	});

	// When we tap the target List, add the selected item to the final Container
	// and add any final star back to the start of the source List

	let finalShape = null;
	target.tap(()=>{
		let currentShape = target.selected;
        target.removeAt(1, target.selectedIndex);
        if (finalShape) source.addAt(finalShape, 0);
        currentShape.center(final).tap(()=>{
            source.addAt(finalShape, 0);
            finalShape = null;
        });
        finalShape = currentShape;
	});


    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=Container
	// https://zimjs.com/docs.html?item=Rectangle
	// https://zimjs.com/docs.html?item=Poly
	// https://zimjs.com/docs.html?item=List
	// https://zimjs.com/docs.html?item=tap
	// https://zimjs.com/docs.html?item=loop
	// https://zimjs.com/docs.html?item=sha
	// https://zimjs.com/docs.html?item=mov
	// https://zimjs.com/docs.html?item=addTo
	// 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 icon - you will not need this
	createIcon(); 

}); // end of ready
              
            
!
999px

Console