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

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

	// CODE HERE
	
	STYLE = {
		type:{
			Label:{backgroundColor:"rgba(0,0,0,.05)"}
		}
	};
	
	// default registration point is top left for rectangular objects 
	// like Rectangle, Bitmap, Button, Window, etc.	
	// scale and rotation will happen around registration point
	// Note: outline() shows registration point as round circle
	
	// the registration point is where the object gets placed
	// so if it is top left corner then the top left corner will placed 
	// at 100, 150 in the x and y - note that loc() sets x and y
	
	const r1 = new Rectangle(100, 100, blue)
		.loc(100,150) // places the registration point (top left corner) at x = 100, y = 150
		// .pos(100,150) // would be the same in this case as default is distance from top left of container (stage)
		.animate({
			props:{scale:2},
			rewind:true,
			loop:true
		}).outline();
	new Label("default registration top left").sca(.6).alp(.6).loc(r1).mov(0,-50);
	
	// here the animation will animate from the center (usually desired - especially for rotation)
	const r2 = new Rectangle(100, 100, green)
		.centerReg() // changes the registration point to center of object (and centers and adds to stage)
		.pos(150,150,LEFT,BOTTOM) // pos() places edges specified distance from specified sides of container
		.animate({
			props:{scale:2},
			rewind:true,
			loop:true
		}).outline();
	new Label("use centerReg() to center reg").sca(.6).alp(.6).loc(r2).mov(-100,-150);
	
	// default registration point is center for circular objects 
	// such as Circle, Dial, RadialMenu, etc.	
	const c1 = new Circle(50,pink).center().outline(); 
	new Label("Circle's reg defaults to middle").sca(.6).alp(.6).center().mov(0,-100);
	
	// use reg(x,y) to move the registration point to the right hand side of the rectangle
	// or could have set the regX property to 100 (there is a regY property as well) 
	const r3 = new Rectangle(100, 100, orange).reg(100).pos(150,150,RIGHT).animate({
		props:{rotation:360},
		ease:"linear",
		time:4000,
		loop:true
	}).outline();
	new Label("use reg() to customize reg").sca(.6).alp(.6).loc(r3).mov(-400,-50);
	
	// increase the regX and the rotation a little each time - and it spirals!
	const spiral = new Container(0,0).pos(200,200,RIGHT,BOTTOM);
	loop(100, i=>{
		new Circle(1+i/12,purple).addTo(spiral).reg(i*1.2).rot(i*10);
	});		
	new Label("changing regX and rotation").sca(.6).alp(.6).loc(spiral).mov(-380,-50);
	
	
	new Label({text:"ZIM - Registration Point", style:false}).loc(30,30).alp(.7);
	
	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=Circle
	// https://zimjs.com/docs.html?item=Rectangle
	// https://zimjs.com/docs.html?item=Label
	// https://zimjs.com/docs.html?item=animate
	// 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=alp
	// https://zimjs.com/docs.html?item=rot
	// https://zimjs.com/docs.html?item=reg
	// https://zimjs.com/docs.html?item=sca
	// https://zimjs.com/docs.html?item=outline
	// 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=zog

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

}); // end of ready
              
            
!
999px

Console