const frame = new Frame("fit", 1024, 768, light, darker);
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
	// 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
	
	// we will save to png everything in the ornament container
	const ornament = new Container(600, 600).center().mov(0,-40);
	
	// make it so the ball will change colors when clicked on
	const colors = series(yellow, yellow.darken(.5),moon,green,green.darken(.5),red,red.darken(.5),pink,purple,brown, brown.darken(.5),black,blue.darken(.5),blue);
	const ball = new Circle(200, blue).center(ornament).mov(0,50).tap(()=>{
		ball.color = colors();
		stage.update();
	});
	
	// a container to hold all our draggable stripes
	const stripes = new Container(stageW, stageH).center(ornament);
	
	// an array of the stripes
	const patterns = [
		new Rectangle(stageW+10, 20, red),
		new Rectangle(stageW+10, 30, green),
		new Rectangle(stageW+10, 10, yellow),
		new Rectangle(stageW+10, 50, dark),
		new Rectangle(stageW+10, 70, dark),
		new Rectangle(stageW+10, 40, white),
		// type, colors, size, cols, rows, spacingH, spacingV, interval, startPaused, backgroundColor, gradient, cache
		pizzazz.makePattern("slants", series(green,red), 30, 100, 1, 0, 0, null, null, red).reg(0,0),
		pizzazz.makePattern("bling", silver, 60, 100, 1, 10).reg(0,0),
		pizzazz.makePattern("noise", series(purple,pink), 20, 200, 1, 0, 0).reg(0,0),
		pizzazz.makePattern("slants", series(green,red), 30, 100, 1, 0, 0, null, null, red).sca(-1,1).reg(0,0),
		pizzazz.makePattern("dots", series(green,red), 20, 100, 1, 5, 0, null, null, red).reg(0,0),
		new Squiggle({
			color:lighter, 
			thickness:10, 
			points:40, 
			length:stageW+10,
			interactive:false
		}).expand(0),
		new Squiggle({
			color:red, 
			thickness:8, 
			points:30, 
			length:(stageW+10)/2,
			interactive:false
		}).sca(2,1).expand(0)
	];
	
	// loop through, randomly place and drag the stripes 
	loop(patterns, stripe=>{
		loop(2, i=>{ // make two of each
			stripe
				.clone()
				.pos(0, rand(stageH-stripe.height), CENTER, TOP, stripes)
				.drag(new Boundary(-10,0,0,stageH-stripe.height));
			if (stripe.type != "Squiggle") stripe.cache();
		})		
	})
	
	// The ring will offset the ornament
	const ring = new Circle(270, clear, darker, 140).loc(ball, null, ornament)
	
	const gradient = new Circle(200, new RadialColor([grey, white],[1,.3], 0,0,0, 50,-50,200))
		.alp(.2)
		.loc(ball, null, ornament);
	
	const hoop = new Circle(40, clear, silver, 2).pos(0,-230, CENTER, CENTER, ornament).noMouse();
	const top = new Rectangle(80,70,new GradientColor([grey,silver,grey],[0,.65,1],0,0,80,0))
		.pos(0,-180, CENTER, CENTER, ornament).noMouse();
	
	// prepare the save steps
	const loader = new Loader();
	const madeWith = frame.madeWith();
	madeWith.icon.alp(1); // usually this a little rollover thing so its start alpha is down
	
	new Button({
		label:"SAVE",
		backgroundColor:red.darken(.3),
		rollBackgroundColor:green.darken(.3),
		corner:10
	}).sca(.7).pos(0,280,CENTER,CENTER).tap(()=>{
		// remove the things we do not want and add a logo
		ring.visible = false;
		stripes.setMask(ball);
		madeWith.pos(20,20,RIGHT,BOTTOM,ornament);
		// save with the Loader
		loader.save(ornament, "ornament"); // could save as a jpg too
		// add the things back
		madeWith.removeFrom();
		stripes.setMask(null);
		ring.visible = true;
	});
	

	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=Squiggle
	// https://zimjs.com/docs.html?item=Button
	// https://zimjs.com/docs.html?item=Loader
	// https://zimjs.com/docs.html?item=tap
	// https://zimjs.com/docs.html?item=drag
	// https://zimjs.com/docs.html?item=noMouse
	// 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=reg
	// https://zimjs.com/docs.html?item=sca
	// https://zimjs.com/docs.html?item=removeFrom
	// https://zimjs.com/docs.html?item=center
	// https://zimjs.com/docs.html?item=expand
	// https://zimjs.com/docs.html?item=setMask
	// https://zimjs.com/docs.html?item=rand
	// https://zimjs.com/docs.html?item=Boundary
	// https://zimjs.com/docs.html?item=GradientColor
	// https://zimjs.com/docs.html?item=RadialColor
	// https://zimjs.com/docs.html?item=series
	// https://zimjs.com/docs.html?item=darken
	// https://zimjs.com/docs.html?item=zog

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

}); // end of ready
View Compiled
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://zimjs.org/cdn/1.3.2/createjs.js
  2. https://zimjs.org/cdn/cat/02/zim.js
  3. https://zimjs.org/cdn/pizzazz_03.js
  4. https://zimjs.org/cdn/icon6.js