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", 1200, 675, darker, black);
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
   
		// made at https://zimjs.com/nio/paths.html
		const points = [[-7,-149.4,0,0,-15.1,33.1,12.4,30.9,"free"],[48.5,-73.4,0,0,0,0,0,0,"none"],[19.8,-75.2,0,0,17.6,6.4,12,30.7,"free"],[81.6,-5.4,0,0,0,0,0,0,"none"],[40,-11.2,0,0,21.2,7.8,10.1,32.2,"free"],[112,57.8,0,0,0,0,0,0,"none"],[57.5,56.2,0,0,31.5,7.5,20.5,38.9,"free"],[133.4,119.6,0,0,0,0,0,0,"mirror"],[18.2,120.8,0,0,39.9,15.4,-0.9,0.9,"free"],[19.5,153.9,0,0,0,0,0,0,"none"],[-25.6,153.7,0,0,0,0,0,0,"none"],[-24.4,123,0,0,0,-0.9,-40.8,10.9,"free"],[-132.7,122,0,0,0,0,0,0,"mirror"],[-67.2,57.5,0,0,-24.6,44.4,-35.2,10.9,"free"],[-122.7,57.8,0,0,0,0,0,0,"none"],[-50.7,-8.3,0,0,-12.7,36.8,-20.6,9.7,"free"],[-102.1,-2.7,0,0,0,0,0,0,"none"],[-33.1,-76.5,0,0,-14.5,32.4,-15.6,7.8,"free"],[-67.2,-69.3,0,0,0,0,0,0,"none"]];

		// a function to make and animate a light
		const colors = [red, green, blue, pink, yellow];
		function makeLight() {
			let light = new Container();
			new Circle(5, colors)
				.addTo(light);
			new Circle(rand(5,30), clear, colors)
				.alp(.1)
				.animate({
				wait:rand(5000),
				time:rand(500,1500),
				props:{alpha:1},
				rewind:true,
				loop:true,
				loopWait:rand(2000,5000)
			})
				.addTo(light);
			return light;
		}

		// the shape for the lights to follow
		const tree = new Blob({
			color:"#000800",
			points:points,
		}).transformPoints("scale", 4); // make it bigger than the original size

		// we are going to parallax the left and right tree - including the Beads, Dial and LabelOnArc objects in each
		const leftTree = new Container(stageW, stageH).addTo();

		// use the Beads object to set lights around tree path
		const lights1 = new Beads({
			path:tree,
			obj:makeLight,
			count:170,
			startPercent:54, // not on the trunk of the tree
			endPercent:45, // wrap back around to 45 (path start is at top)
			clone:false, // to keep animate on each object
			interactive:false
		}).center(leftTree).mov(-130, -310);

		// clone the second lights
		const rightTree = new Container(stageW, stageH).addTo().bot();
		const lights2 = lights1.clone().centerReg(rightTree).sca(-.8,.8).mov(220, -180)

		// add a Parallax object to control the motion of the trees based on mouseX and mouseY
		// y gets a factor of -1 as usually, a lower y lifts the view
		// but here we need to interact with the dials at top so make cursor at top, move scene upwards
		new Parallax([
			{obj:leftTree, prop:"x", propChange:150},
			{obj:leftTree, prop:"y", input:"mouseY", propChange:1000, factor:-1}, 
			{obj:rightTree, prop:"x", propChange:100},
			{obj:rightTree, prop:"y", input:"mouseY", propChange:800, factor:-1},
		], .02);

		// We will scale specific letters based on the Dial
		// a space in the front lets Dial at top set all letters back to scale
		const greet1 = new LabelOnArc(" HAPPY HOLIDAYS", 24, null, white, 70)
			.loc(lights1.path.pointCircles[0], null, leftTree)
			.mov(0,5)
			.rot(-5)

		const greet2 = new LabelOnArc(" DAN ZEN AND ZIM", 20, null, white, 60)
			.loc(lights2.path.pointCircles[0], null, rightTree)
			.mov(0,5)
			.rot(-5)

		STYLE = {
			type:{
				Dial:{
					backgroundColor:series(green, red), // alternate dial colors
					width:series(100,80), // alternate dial widths, etc.
					limit:false,
					min:0,
					max:series(greet1.numLetters-1, greet2.numLetters-1),
					useTicks:true,
					tickColor:light
				}
			}
		}
		const dial1 = new Dial()
			.loc(greet1, null, leftTree)
			.change(()=>{
				lastLetter1.sca(1); // set the last letter back to scale of 1
				// scale the letter that matches the Dial index
				// the labelLetter labels are held in labels array
				lastLetter1 = greet1.labels[dial1.currentValue].sca(2); 
			})
		// start off with the first label as the lastLetter
		let lastLetter1 = greet1.labels[0];

		const dial2 = new Dial()
		.loc(greet2, null, rightTree)
		.change(()=>{
			lastLetter2.sca(1);
			lastLetter2 = greet2.labels[dial2.currentValue].sca(2)
		})
		let lastLetter2 = greet2.labels[0];

    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=Blob
		// https://zimjs.com/docs.html?item=LabelOnArc
		// https://zimjs.com/docs.html?item=Dial
		// https://zimjs.com/docs.html?item=Beads
		// https://zimjs.com/docs.html?item=change
		// https://zimjs.com/docs.html?item=animate
		// https://zimjs.com/docs.html?item=loc
		// https://zimjs.com/docs.html?item=mov
		// https://zimjs.com/docs.html?item=bot
		// https://zimjs.com/docs.html?item=alp
		// https://zimjs.com/docs.html?item=rot
		// https://zimjs.com/docs.html?item=sca
		// 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=Parallax
		// https://zimjs.com/docs.html?item=transformPoints
		// https://zimjs.com/docs.html?item=zog
		// https://zimjs.com/docs.html?item=STYLE
  
    // FOOTER
    // call remote script to make ZIM Foundation for Creative Coding icon
    createIcon(10,10); 

}); // end of ready
              
            
!
999px

Console