Normalize and Ratio - what are they?

Not sure if you noticed that when we animate a Tile using sequence, the items in the tile start animating at the top left and go across the columns and then down the rows or if we sequenceReverse then from the bottom right to the top left. What if we want to animate from the center out! Here is an example of what that can look like and it is very cool! ZIM 016 - Normalize and Ratio - Code Creativity

The new normalize() method of a Container lets you give each child of the container a ratio (0-1) as to how popular it is compared to the other children relative to a starting, ending or central point. Ya... a little confusing sounding! An example will help:

const item = new Rectangle(70,70,white,black).reg(CENTER);
const tile = new Tile(item, 9, 1, 20)
	.normalize("x", CENTER)


// scale the items based on the distance from the center
	zogy(decimals(item.ratio)); // 0, .3, .5, .8, 1, .8, .5, .3, 0 + item.ratio*2);


// optionally, adjust the spacing by re-tiling the scaled items
const final = new Tile({
	unique:true, // avoid ZIM VEE picking from array

tile.dispose(); // get rid of old empty tile
tile.sortBy("ratio"); // make more central objects come to front


Or with a spacingH of -10 above:


The animation works in a similar manner but we normalize the reg property:

tile.normalize("reg", CENTER)

and use the ratio to adjust the rate parameter of the animate(). We also set sequence to 0 to animate each child of the container independently.

		rate:target=>{return 1 + target.ratio*4},
		sequence:0 // turn on per item animation

The rate of the outer tile items is slower than the rate of the central tile items. Also, when we normalize the reg property it actually sets the registration point of each child to the center of the tile! This way we get the neat effects.