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


Add 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 or require. We'll also process your JavaScript with Babel.

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


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.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

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("full", null, null, grey, grey, "twitter.jpg", "");
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
    // see for video and code tutorials
    // see for documentation
    // see for INTRO to ZIM
    // see for INTRO to CODE

    // CODE HERE
		// A simple app to load a screenshot of your tweet
		// change the numbers of the messages, retweets and likes
		// crop and save the new pic!

		// This type of edit picture app has countless possibilities
		// The core construction can be made in FIVE minutes with ZIM
		// SEE:
		// SEE:
		// Note: any time there is a lot of interface, the code gets longer 
		// but have a look... the steps we take are all very similar 
		// ZIM is a coding language without an IDE (aside from Adobe Animate) 
		// so we need to make our components, etc. with code - yay!

		// We will add anything that we want to save out as a picture to a Container
		// So holder will have the pic and the panel with the numbers in it
		// We can use loader to save the holder with the cropped dimension
		// and the pic and numbers will be saved as a new image
		// We would put just the numbers in the holder
		// but then the pic goes behind the panel and the numbers go on top of the panel
		// and this cannot be done as the pic and panel would be in the same container
		// so just put the whole panel in holder
		const holder = new Container(stageW, stageH).addTo();

		// Here we start with a sample screen shot
		// let the user drag the picture
		// but set it so it does not come to the top automatically
		// otherwise it would go over the numbers
		let pic = frame.asset("twitter.jpg")
			.animate({props:{alpha:1}, wait:1500, time:700});

		// Create an interface panel
		// Use a Container - this means we could drag the whole thing
		// or hide the whole thing later if we wanted too
		// We put an empty event on the background
		// so the dragging of the pic does not happen with mousedown on panel
		const panel = new Container().loc(30,30,holder);
		new Rectangle(200, 600, dark).addTo(panel).sha("rgba(0,0,0,.2)", 7,7,7).on("mousedown", ()=>{});

		// the Tile and Labels we will want to be centered so set a style
		STYLE = {align:"center"}

		new Label({text:"TWEET\nDOCTOR", color:pink})

		const loader = new Loader({

		loader.on("loaded", e => {
			pic.noDrag(); // clear drag events to be safe
			// load in new pic and add to bottom of holder
			pic ={onTop:false});

		new Label({

		// create and place three draggable labels tiled in three columns one row
		const nums = new Tile(
			new Label({text:"0", color:"#777777", backgroundColor:white}).centerReg({add:false}), 3, 1, 20
		).sca(.6).center(panel).mov(0, -75).drag({onTop:false}); // keep index order for stepper event

		// create a ColorPicker which will handle background and text color
		// as Twitter may have different colors
		const picker = new ColorPicker({alphaPicker:false});
		// set is when the color is changed in the Picker
		// this will show a preview of the color
		// if x is then selected the color is not used
		// if ok is selected then the color is used
		// so this is a more complicated system - but user friendly
		// Since we are using the same ColorPicker we need to know which we are setting
		// so we store which one in a custom target property
		// when we open the ColorPicker - see the Rectangle events
		picker.on("set", ()=>{
			if ( == "backgroundColor") {
				nums.loop(num=>{zog(num.type); num.backgroundColor = picker.selectedColor;})
				backgroundColor.color = picker.selectedColor; // set the rectangle too
			} else {
				nums.loop(num=>{zog(num.type); num.color = picker.selectedColor;})
				color.color = picker.selectedColor; // set the rectangle too
		picker.on("change", ()=>{
			picker.hide(); // already set so nothing to do but close picker
		picker.on("close", ()=>{
			// color is canceled so reset colors to colors before picker
			if ( == "backgroundColor") {
				// loop through numbers and apply color
				nums.loop(num=>{num.background.color = picker.lastColor;})
				backgroundColor.color = picker.lastColor;
			} else {
				nums.loop(num=>{num.color = picker.lastColor;})
				color.color = picker.lastColor;
		const backgroundColor = new Rectangle(30,30,white,light).center(panel).mov(-50,-25).tap(()=>{ = "backgroundColor"; // set custom property of which type
			// store the color before picking and set the colorPicker current color
			picker.lastColor = picker.selectedColor = backgroundColor.color;;
		const color = new Rectangle(30,30,"#666666",light).center(panel).mov(0,-25).tap(()=>{ = "color"; // set custom property of which type
			// store the color before picking and set the colorPicker current color
			picker.lastColor = picker.selectedColor = color.color;;

		// handle scaling of the labels as the screenshot may be at different sizes
		const dial = new Dial({backgroundColor:white, useTicks:false, min:30, max:70})
		.change(e => {
			// loop through numbers and apply height
			// width will change too unless heightOnly property is used
			nums.loop(num=>{num.height = dial.currentValue;});
		// start the dial at the right value
		dial.currentValue = nums.getChildAt(0).height;

		new Label({

		// create three steppers in a tile of one column and three rows
		const steppers = new Tile(
			new Stepper({stepperType:"number", max:999}).sca(.5), 1, 3, 0, 20
			stepper.on("change", e =>{
				let stepper =;
				// match the label to the index of the stepper being changed
				let label = nums.getChildAt(stepper.tileNum);
				label.text = stepper.currentValue;

		// Create buttons for cropping and saving
		// we will make a rectangle with a transform for the cropper
		// transform needs the object to be on the stage
		// but we want to initially hide the cropper
		// so make it the first time the crop button is pressed
		// the buttons will have these styles
		// we can target only buttons or even a group of objects
		// but this is faster to type if we don't have to worry about it...
		STYLE = {backgroundColor:pink, rollBackgroundColor:blue, corner:10}
		let cropper = null;
		new Button({label:"CROP", toggle:"HIDE"})
			.tap(() => {
			// here we make the cropper if it is not already made
			if (!cropper) {
				cropper = new Rectangle(500,500,null,pink,10,0,true,{ignoreScale:true})
					.transform({allowToggle:false, rotate:false, showReg:false});
			} else {
				// hide or show the cropper depending on if it is already showing
				if (cropper.parent) {
				} else {

		// don't save unless the cropper is showing... so make a warning pane
		var pane = new Pane(350, 100, "Please set crop", null, white);
		new Button({label:"SAVE"})
			.tap(() => {
			if (!cropper || !cropper.parent) {;
			// use the loader save() to save the cropped dimensions, "tweet.jpg", cropper.x, cropper.y, cropper.width, cropper.height);
		});; // bring numbers up above everything in the holder
    stage.update(); // this is needed to show any changes
    // FOOTER
    // call remote script to make ZIM Foundation for Creative Coding icon
		// a little more complicated in full mode as we position it on frame resize
			frame.on("resize", ()=>{
}); // end of ready