Best Python code snippet using fMBT_python
mep-feature-backlight.js
Source:mep-feature-backlight.js  
1(function($) {2	$.extend(mejs.MepDefaults, {3		backlightBackground: [0,0,0],4		backlightHorizontalLights: 5,5		backlightVerticalLights: 5,6		backlightSize: 50,7		backlightTimeout: 2008	});9	$.extend(MediaElementPlayer.prototype, {10		buildbacklight : function(player, controls, layers, media) {11			if (!player.isVideo)12				return;13			//http://www.splashnology.com/blog/html5/382.html14			var 15				mediaContainer = player.container.find('.mejs-mediaelement').parent(),16				border = $('<div class="mejs-border"></div>')17					.prependTo(mediaContainer)18					.css('position','absolute')19					.css('top','-10px')20					.css('left','-10px')21					.css('border','solid 10px #010101')22					.width(player.width).height(player.height),23				glowBase = $('<div class="mejs-backlight-glow"></div>')24					.prependTo(mediaContainer)25					.css('position','absolute')26					.css('display','none')27					.css('top',0)28					.css('left',0)29					.width(player.width).height(player.height),30				base = $('<div class="mejs-backlight"></div>')31					.prependTo(mediaContainer)32					.css('position','absolute')33					.css('top',0)34					.css('left',0)35					.width(player.width).height(player.height),36				i,37				copyCanvas = document.createElement('canvas'),38				copyContext = copyCanvas.getContext('2d'),39				pixels,40				keepUpdating = true,41				isActive = true,42				timer = null,43				glowCanvas = document.createElement('canvas'),44				glowContext = glowCanvas.getContext('2d'),45				size = player.options.backlightSize,46				backgroundColor = player.options.backlightBackground,47				gradient,48				width = player.width,49				height = player.height;50			// set sizes51			copyCanvas.width = width;52			copyCanvas.height = height;53			glowCanvas.width = width + size + size;54			glowCanvas.height = height + size + size;55			// draw glow overlay56			// top57			gradient = addGlow(backgroundColor,glowContext.createLinearGradient(size, size, size, 0));58			glowContext.fillStyle = gradient; 59			glowContext.fillRect(size, size, width, -size); 60			// tr61			gradient = addGlow(backgroundColor,glowContext.createRadialGradient(width+size, size, 0, width+size, size, size));62			glowContext.fillStyle = gradient; 63			glowContext.fillRect(width+size, size, size, -size); 64			// right65			gradient = addGlow(backgroundColor,glowContext.createLinearGradient(width+size, size, width+size+size, size));66			glowContext.fillStyle = gradient; 67			glowContext.fillRect(width+size, size, size, height); 68			// br69			gradient = addGlow(backgroundColor,glowContext.createRadialGradient(width+size, height+size, 0, width+size, height+size, size));70			glowContext.fillStyle = gradient; 71			glowContext.fillRect(width+size, height+size, size, size); 72			// bottom73			var gradient = addGlow(backgroundColor,glowContext.createLinearGradient(size, size+height, size, size+height+size));74			glowContext.fillStyle = gradient; 75			glowContext.fillRect(size, size+height, width, size); 76			// bl77			gradient = addGlow(backgroundColor,glowContext.createRadialGradient(size, height+size, 0, size, height+size, size));78			glowContext.fillStyle = gradient; 79			glowContext.fillRect(0, height+size, size, size); 80			// left81			gradient = addGlow(backgroundColor,glowContext.createLinearGradient(size, size, 0, size));82			glowContext.fillStyle = gradient; 83			glowContext.fillRect(size, size, -size, height); 84			// tl85			gradient = addGlow(backgroundColor,glowContext.createRadialGradient(size, size, 0, size, size, size));86			glowContext.fillStyle = gradient; 87			glowContext.fillRect(0, 0, size, size); 88			$(glowCanvas)89				.css('position','absolute')90				.css('top',-size)91				.css('left',-size)92				.appendTo(glowBase);93			// add toggle control94			$('<div class="mejs-backlight-button mejs-backlight-active"><span></span></div>')95				.appendTo(controls)96				.click(function() {97					if (isActive) {98						delete timer;99						timer = null;100						base.hide();101						glowBase.hide();102						$(this)103							.removeClass('mejs-backlight-active')104							.addClass('mejs-backlight-inactive')105					} else {106						updateLights();107						base.show();108						glowBase.show();109						$(this)110							.removeClass('mejs-backlight-inactive')111							.addClass('mejs-backlight-active')112					}113					isActive = !isActive;114				});115			// http://www.splashnology.com/blog/html5/382.html116			function updateLights() {117				// get a copy of video118				copyContext.drawImage(media, 0, 0, media.width, media.height);119				// create the gradient lights120				addLights(base, copyCanvas, copyContext, 121					player.options.backlightVerticalLights, 122					player.options.backlightHorizontalLights, 123					player.options.backlightSize, 124					30);125				if (keepUpdating && isActive) {126					timer = setTimeout(updateLights, player.options.backlightTimeout);127				}128			}129			//setTimeout(updateLights, timeOut);130			media.addEventListener('play',function() {131				if (isActive) {132					keepUpdating = true;133					updateLights();134					glowBase.css('display','');135				}136			}, false);137			media.addEventListener('pause',function() {138				keepUpdating = false;139			}, false);140			media.addEventListener('ended',function() {141				keepUpdating = false;142			}, false);143		}144	});145	function addLights(base, canvas, context, vBlocks, hBlocks, size, depth) {146		base.empty();147		var 148			lightsCanvas = document.createElement('canvas'),149			lightsContext = lightsCanvas.getContext('2d'),150			width = canvas.width,151			height = canvas.height,152			g,153			topLights = getMidColors(canvas, context, hBlocks, depth, 'top'),154			bottomLights = getMidColors(canvas, context, hBlocks, depth, 'bottom'),155			leftLights = getMidColors(canvas, context, vBlocks, depth, 'left'),156			rightLights = getMidColors(canvas, context, vBlocks, depth, 'right'),157			corners = [],158			stopSize = 0;159		lightsCanvas.width = width + size + size;160		lightsCanvas.height = height + size + size;161		lightsContext.globalCompositeOperation = 'xor'; //'darker'; //'lighter';162		// draw four gradients163		// create corners164		corners.push(averageColor(topLights[topLights.length-1], rightLights[0]) );165		corners.push(averageColor(bottomLights[bottomLights.length-1], rightLights[rightLights.length-1]) );166		corners.push(averageColor(bottomLights[0], leftLights[leftLights.length-1]) );167		corners.push(averageColor(topLights[0], leftLights[0]) );168		// top169		stopSize = 1 / topLights.length;170		gradient = context.createLinearGradient(size, size, width+size, size);171		gradient.addColorStop(0, 'rgb(' + adjustColor(corners[3]).join(',') + ')');172		for (var i = 0, il = topLights.length; i < il; i++) {173			gradient.addColorStop(i * stopSize + stopSize/2, 'rgb(' + adjustColor(topLights[i]).join(',') + ')');174		}175		gradient.addColorStop(1.0, 'rgb(' + adjustColor(corners[0]).join(',') + ')');176		lightsContext.fillStyle = gradient;177		lightsContext.fillRect(size, 0, width, size);178		// right179		gradient = context.createLinearGradient(size+width, size, size+width, size+height);180		gradient.addColorStop(0, 'rgb(' + adjustColor(corners[0]).join(',') + ')');181		for (var i = 0, il = rightLights.length; i < il; i++) {182			gradient.addColorStop(i * stopSize + stopSize/2, 'rgb(' + adjustColor(rightLights[i]).join(',') + ')');183		}184		gradient.addColorStop(1.0, 'rgb(' + adjustColor(corners[1]).join(',') + ')');185		lightsContext.fillStyle = gradient;186		lightsContext.fillRect(size+width, size, size+width+size, height);187		// bottom188		gradient = context.createLinearGradient(size, size+height, size+width, size+height);189		gradient.addColorStop(0, 'rgb(' + adjustColor(corners[2]).join(',') + ')');190		for (var i = 0, il = bottomLights.length; i < il; i++) {191			gradient.addColorStop(i * stopSize + stopSize/2, 'rgb(' + adjustColor(bottomLights[i]).join(',') + ')');192		}193		gradient.addColorStop(1.0, 'rgb(' + adjustColor(corners[1]).join(',') + ')');194		lightsContext.fillStyle = gradient;195		lightsContext.fillRect(size, size+height, width, size);196		// left197		gradient = context.createLinearGradient(size, size, size, size+height);198		gradient.addColorStop(0, 'rgb(' + adjustColor(corners[3]).join(',') + ')');199		for (var i = 0, il = leftLights.length; i < il; i++) {200			gradient.addColorStop(i * stopSize + stopSize/2, 'rgb(' + adjustColor(leftLights[i]).join(',') + ')');201		}202		gradient.addColorStop(1.0, 'rgb(' + adjustColor(corners[2]).join(',') + ')');203		lightsContext.fillStyle = gradient;204		lightsContext.fillRect(0, size, size, height);205		// corners206		// top right207		lightsContext.fillStyle = 'rgb(' + adjustColor(corners[0]).join(',') + ')';208		lightsContext.fillRect(width+size, 0, size+width+size, size);209		// bottom right210		lightsContext.fillStyle = 'rgb(' + adjustColor(corners[1]).join(',') + ')';211		lightsContext.fillRect(width+size, size+height, size+width+size, size+height+size);212		// bottom left213		lightsContext.fillStyle = 'rgb(' + adjustColor(corners[2]).join(',') + ')';214		lightsContext.fillRect(0, size+height, size, size+height+size);215		// top left216		lightsContext.fillStyle = 'rgb(' + adjustColor(corners[3]).join(',') + ')';217		lightsContext.fillRect(0, 0, size, size);218		$(lightsCanvas)219			.css('position','absolute')220			.css('top',-size)221			.css('left',-size)222			.appendTo(base);223	}224	function addGlow(color, g) {225		g.addColorStop(0.0, 'rgba(' + color.join(',') + ',0)');226		g.addColorStop(1.0, 'rgba(' + color.join(',') + ',1)');227		return g;228	}229	function getMidColors(canvas, context, blocks, blockDepth, side) {230		var width = canvas.width,231			height = canvas.height,232			blockHeight = (side == 'top' || side == 'bottom') ? blockDepth : Math.ceil(height / blocks), // height of the analyzed block233			blockWidth = (side == 'top' || side == 'bottom') ? Math.ceil(width / blocks) : blockDepth,234			result = [],235			imgdata,236			i;237		if (side == 'top' || side == 'bottom') {238			for (i = 0; i < blocks; i++) {239				try {240					imgdata = context.getImageData(i*blockWidth, (side == 'top') ? 0 : height - blockHeight , blockWidth, blockHeight);241					result.push( 242						calcMidColor(imgdata.data)243					);244				} catch (e) {245					console.log(e);246				}247			}248		} else {249			for (i = 0; i < blocks; i++) {250				try {251					imgdata = context.getImageData( (side == 'right') ? width - blockWidth : 0, i*blockHeight, blockWidth, blockHeight);252					result.push( 253						calcMidColor(imgdata.data)254					);255				} catch (e) {256					console.log(e);257				}258			}259		}260		return result;261	}262	function averageColor(c1,c2) {263		var result = 264			[(c1[0] + c2[0]) / 2, 265			 (c1[1] + c2[1]) / 2,  266			 (c1[2] + c2[2]) / 2];267			 268		return result;269	}270	// average color for a block271	function calcMidColorVertical(data, from, to) {272		var result = [0, 0, 0];273		var totalPixels = (to - from) / 4;274		for (var i = from; i <= to; i += 4) {275			result[0] += data[i];276			result[1] += data[i + 1];277			result[2] += data[i + 2];278		}279		result[0] = Math.round(result[0] / totalPixels);280		result[1] = Math.round(result[1] / totalPixels);281		result[2] = Math.round(result[2] / totalPixels);282		return result;283	}284	// average color for a block285	function calcMidColor(data) {286		var result = [0, 0, 0];287		var totalPixels = data.length;288		for (var i = 0; i < totalPixels; i += 4) {289			result[0] += data[i];290			result[1] += data[i + 1];291			result[2] += data[i + 2];292		}293		result[0] = Math.round(result[0] / totalPixels);294		result[1] = Math.round(result[1] / totalPixels);295		result[2] = Math.round(result[2] / totalPixels);296		return result;297	}298	function adjustColor(color) {299		//if (color[0] <= 2 && color[2] <= 2 && color[3] <= 2)300		//	return color;301		color = rgb2hsv(color);302		color[1] = Math.min(100, color[1] * 1.2); //1.4); // saturation303		color[2] = 80; //Math.min(100, color[2] * 2.7); //2.7); // brightness304		return hsv2rgb(color);305	}306	function rgb2hsv(color) {307		var r = color[0] / 255,308			g = color[1] / 255,309			b = color[2] / 255,310			x, val, d1, d2, hue, sat, val;311		x = Math.min(Math.min(r, g), b);312		val = Math.max(Math.max(r, g), b);313		//if (x == val)314		//	throw Error('h is undefined');315		d1 = (r == x) ? g-b : ((g == x) ? b-r : r-g);316		d2 = (r == x) ? 3 : ((g == x) ? 5 : 1);317		hue = Math.floor((d2 - d1 / (val - x)) * 60) % 360;318		sat = Math.floor(((val - x) / val) * 100);319		val = Math.floor(val * 100);320		return [hue, sat, val];321	}322	/**323	 * Convers HSV color to RGB model324	 * @param {Number[]} RGB color325	 * @return {Number[]} HSV color326	 */327	function hsv2rgb(color) {328		var h = color[0],329			s = color[1],330			v = color[2];331		var r, g, a, b, c, s = s / 100, v = v / 100, h = h / 360;332		if (s > 0) {333			if (h >= 1) h=0;334			h = 6 * h;335			var f = h - Math.floor(h);336			a = Math.round(255 * v * (1 - s));337			b = Math.round(255 * v * (1 - (s * f)));338			c = Math.round(255 * v * (1 - (s * (1 - f))));339			v = Math.round(255 * v);340			switch (Math.floor(h)) {341				case 0: r = v; g = c; b = a; break;342				case 1: r = b; g = v; b = a; break;343				case 2: r = a; g = v; b = c; break;344				case 3: r = a; g = b; b = v; break;345				case 4: r = c; g = a; b = v; break;346				case 5: r = v; g = a; b = b; break;347			}348			return [r || 0, g || 0, b || 0];349		} else {350			v = Math.round(v * 255);351			return [v, v, v];352		}353	}...MarkSize.js
Source:MarkSize.js  
1"use strict;"2function MarkSize( main , TargetObj ){3	var Box 		= new THREE.Box3();4	var objCenter  	= new THREE.Vector3();5	var objSize		= new THREE.Vector3();6	var FuniBox 	= new THREE.Box3();7	var FuniCenter	= new THREE.Vector3();8	var group		= new THREE.Group();9	main.scene.add(group);10	//detect the funiture component11	for(var i = main.furnitures.length - 1; i > -1; i -- ){ 12		var object =  main.furnitures[i].getFurniture();13		14		if(object.isObject3D){15			group.add(object.clone());16		}17	}18	for(var i = main.Sceneobjects.length - 1; i > -1; i -- ){19		var object =  main.Sceneobjects[i];20		group.add(object.clone());21	}22	//set funiture bounding box , box center23	FuniBox.setFromObject( group );24	FuniBox.getCenter( FuniCenter );25	main.scene.remove( group );26	//get object center27	Box.setFromObject(TargetObj);28	Box.getCenter(objCenter);29	Box.getSize(objSize);30	// face to the user31	if( objCenter.z >= FuniCenter.z ){32		//show size number33		loadText( 	main , 34					objSize.x ,35					new THREE.Vector3(objCenter.x ,36									  objCenter.y - objSize.y/2 ,37									  objCenter.z + objSize.z/2 + 1), 38					0 );39		//show line40		loadLine( 	main , 41					new THREE.Vector3(objCenter.x - objSize.x/2 ,42									  objCenter.y - objSize.y/2 ,43									  objCenter.z + objSize.z/2 + 1) , 44					new THREE.Vector3(objCenter.x + objSize.x/2 ,45									  objCenter.y - objSize.y/2 ,46									  objCenter.z + objSize.z/2 + 1) );47		loadLine( 	main , 48					new THREE.Vector3(objCenter.x - objSize.x/2 ,49									  objCenter.y - objSize.y/2 ,50									  objCenter.z + objSize.z/2 + 0.5) , 51					new THREE.Vector3(objCenter.x - objSize.x/2 ,52									  objCenter.y - objSize.y/2 ,53									  objCenter.z + objSize.z/2 + 1.5) );54		loadLine( 	main , 55					new THREE.Vector3(objCenter.x + objSize.x/2 ,56									  objCenter.y - objSize.y/2 ,57									  objCenter.z + objSize.z/2 + 0.5) , 58					new THREE.Vector3(objCenter.x + objSize.x/2 ,59									  objCenter.y - objSize.y/2 ,60									  objCenter.z + objSize.z/2 + 1.5) );61		//right to the user62		if ( objCenter.x > FuniCenter.x ){63			//show high64			loadText( 	main , 65						objSize.y ,66						new THREE.Vector3(objCenter.x + objSize.x/2 +1,67										  objCenter.y ,68										  objCenter.z + objSize.z/2 +1, ), 69						45 );70			//show line71			loadLine( 	main , 72						new THREE.Vector3(objCenter.x + objSize.x/2 +1,73										  objCenter.y - objSize.y/2 ,74										  objCenter.z + objSize.z/2 +1) , 75						new THREE.Vector3(objCenter.x + objSize.x/2 +1,76										  objCenter.y + objSize.y/2 ,77										  objCenter.z + objSize.z/2 +1) );78			//show line79			loadLine( 	main , 80						new THREE.Vector3(objCenter.x + objSize.x/2 +0.5,81										  objCenter.y - objSize.y/2 ,82										  objCenter.z + objSize.z/2 +0.5) , 83						new THREE.Vector3(objCenter.x + objSize.x/2 +1.5,84										  objCenter.y - objSize.y/2 ,85										  objCenter.z + objSize.z/2 +1.5) );86			//show line87			loadLine( 	main , 88						new THREE.Vector3(objCenter.x + objSize.x/2 +0.5,89										  objCenter.y + objSize.y/2 ,90										  objCenter.z + objSize.z/2 +0.5) , 91						new THREE.Vector3(objCenter.x + objSize.x/2 +1.5,92										  objCenter.y + objSize.y/2 ,93										  objCenter.z + objSize.z/2 +1.5) );94		}95		else{//left to the user96			//show high97			loadText( 	main , 98						objSize.y ,99						new THREE.Vector3(objCenter.x - objSize.x/2 -1,100										  objCenter.y ,101										  objCenter.z + objSize.z/2 +1, ), 102						-45 );103			//show line104			loadLine( 	main , 105						new THREE.Vector3(objCenter.x - objSize.x/2 -1,106										  objCenter.y - objSize.y/2 ,107										  objCenter.z + objSize.z/2 +1) , 108						new THREE.Vector3(objCenter.x - objSize.x/2 -1,109										  objCenter.y + objSize.y/2 ,110										  objCenter.z + objSize.z/2 +1) );111			loadLine( 	main , 112						new THREE.Vector3(objCenter.x - objSize.x/2 -0.5,113										  objCenter.y - objSize.y/2 ,114										  objCenter.z + objSize.z/2 +0.5) , 115						new THREE.Vector3(objCenter.x - objSize.x/2 -1.5,116										  objCenter.y - objSize.y/2 ,117										  objCenter.z + objSize.z/2 +1.5) );118			loadLine( 	main , 119						new THREE.Vector3(objCenter.x - objSize.x/2 -0.5,120										  objCenter.y + objSize.y/2 ,121										  objCenter.z + objSize.z/2 +0.5) , 122						new THREE.Vector3(objCenter.x - objSize.x/2 -1.5,123										  objCenter.y + objSize.y/2 ,124										  objCenter.z + objSize.z/2 +1.5) );125		}126	}127	else{// back to the user128		//show size number129		loadText( 	main , 130					objSize.x ,131					new THREE.Vector3(objCenter.x ,132									  objCenter.y - objSize.y/2 ,133									  objCenter.z - objSize.z/2 - 1), 134					180 );135		//show line136		loadLine( 	main , 137					new THREE.Vector3(objCenter.x - objSize.x/2,138									  objCenter.y - objSize.y/2 ,139									  objCenter.z - objSize.z/2 - 1) , 140					new THREE.Vector3(objCenter.x + objSize.x/2,141									  objCenter.y - objSize.y/2 ,142									  objCenter.z - objSize.z/2 - 1) );143		loadLine( 	main , 144					new THREE.Vector3(objCenter.x - objSize.x/2,145									  objCenter.y - objSize.y/2 ,146									  objCenter.z - objSize.z/2 - 0.5) , 147					new THREE.Vector3(objCenter.x - objSize.x/2,148									  objCenter.y - objSize.y/2 ,149									  objCenter.z - objSize.z/2 - 1.5) );150		loadLine( 	main , 151					new THREE.Vector3(objCenter.x + objSize.x/2,152									  objCenter.y - objSize.y/2 ,153									  objCenter.z - objSize.z/2 - 0.5) , 154					new THREE.Vector3(objCenter.x + objSize.x/2,155									  objCenter.y - objSize.y/2 ,156									  objCenter.z - objSize.z/2 - 1.5) );157		//right to the user158		if ( objCenter.x > FuniCenter.x ){159			//show high160			loadText( 	main , 161						objSize.y ,162						new THREE.Vector3(objCenter.x + objSize.x/2 +1,163										  objCenter.y ,164										  objCenter.z - objSize.z/2 -1 ), 165						135 );166			//show line167			loadLine( 	main , 168						new THREE.Vector3(objCenter.x + objSize.x/2 +1,169										  objCenter.y - objSize.y/2 ,170										  objCenter.z - objSize.z/2 -1) , 171						new THREE.Vector3(objCenter.x + objSize.x/2 +1,172										  objCenter.y + objSize.y/2 ,173										  objCenter.z - objSize.z/2 -1) );174			loadLine( 	main , 175						new THREE.Vector3(objCenter.x + objSize.x/2 +0.5,176										  objCenter.y - objSize.y/2 ,177										  objCenter.z - objSize.z/2 -0.5) , 178						new THREE.Vector3(objCenter.x + objSize.x/2 +1.5,179										  objCenter.y - objSize.y/2 ,180										  objCenter.z - objSize.z/2 -1.5) );181			loadLine( 	main , 182						new THREE.Vector3(objCenter.x + objSize.x/2 +0.5,183										  objCenter.y + objSize.y/2 ,184										  objCenter.z - objSize.z/2 -0.5) , 185						new THREE.Vector3(objCenter.x + objSize.x/2 +1.5,186										  objCenter.y + objSize.y/2 ,187										  objCenter.z - objSize.z/2 -1.5) );188		}189		else{//left to the user190			//show high191			loadText( 	main , 192						objSize.y ,193						new THREE.Vector3(objCenter.x - objSize.x/2 -1,194										  objCenter.y ,195										  objCenter.z - objSize.z/2 -1, ), 196						225 );197			//show line198			loadLine( 	main , 199						new THREE.Vector3(objCenter.x - objSize.x/2 -1,200										  objCenter.y - objSize.y/2 ,201										  objCenter.z - objSize.z/2 -1) , 202						new THREE.Vector3(objCenter.x - objSize.x/2 -1,203										  objCenter.y + objSize.y/2 ,204										  objCenter.z - objSize.z/2 -1) );205			loadLine( 	main , 206						new THREE.Vector3(objCenter.x - objSize.x/2 -0.5,207										  objCenter.y - objSize.y/2 ,208										  objCenter.z - objSize.z/2 -0.5) , 209						new THREE.Vector3(objCenter.x - objSize.x/2 -1.5,210										  objCenter.y - objSize.y/2 ,211										  objCenter.z - objSize.z/2 -1.5) );212			loadLine( 	main , 213						new THREE.Vector3(objCenter.x - objSize.x/2 -0.5,214										  objCenter.y + objSize.y/2 ,215										  objCenter.z - objSize.z/2 -0.5) , 216						new THREE.Vector3(objCenter.x - objSize.x/2 -1.5,217										  objCenter.y + objSize.y/2 ,218										  objCenter.z - objSize.z/2 -1.5) );219		}220	}221	//right to the user222	if ( objCenter.x > FuniCenter.x ){223		//show size number224		loadText( 	main , 225					objSize.z ,226					new THREE.Vector3(objCenter.x + objSize.x/2 +1,227									  objCenter.y - objSize.y/2 ,228									  objCenter.z ), 229					90 );230		//show line231		loadLine( 	main , 232					new THREE.Vector3(objCenter.x + objSize.x/2 +1,233									  objCenter.y - objSize.y/2 ,234									  objCenter.z - objSize.z/2) , 235					new THREE.Vector3(objCenter.x + objSize.x/2 +1,236									  objCenter.y - objSize.y/2 ,237									  objCenter.z + objSize.z/2) );238		loadLine( 	main , 239					new THREE.Vector3(objCenter.x + objSize.x/2 +0.5,240									  objCenter.y - objSize.y/2 ,241									  objCenter.z - objSize.z/2) , 242					new THREE.Vector3(objCenter.x + objSize.x/2 +1.5,243									  objCenter.y - objSize.y/2 ,244									  objCenter.z - objSize.z/2) );245		loadLine( 	main , 246					new THREE.Vector3(objCenter.x + objSize.x/2 +0.5,247									  objCenter.y - objSize.y/2 ,248									  objCenter.z + objSize.z/2) , 249					new THREE.Vector3(objCenter.x + objSize.x/2 +1.5,250									  objCenter.y - objSize.y/2 ,251									  objCenter.z + objSize.z/2) );252	}253	else{//left to the user254		//show size number255		loadText( 	main , 256					objSize.z ,257					new THREE.Vector3(objCenter.x - objSize.x/2 -1,258									  objCenter.y - objSize.y/2 ,259									  objCenter.z ), 260					270 );261		//show line262		loadLine( 	main , 263					new THREE.Vector3(objCenter.x - objSize.x/2 -1,264									  objCenter.y - objSize.y/2 ,265									  objCenter.z - objSize.z/2) , 266					new THREE.Vector3(objCenter.x - objSize.x/2 -1,267									  objCenter.y - objSize.y/2 ,268									  objCenter.z + objSize.z/2) );269		loadLine( 	main , 270					new THREE.Vector3(objCenter.x - objSize.x/2 -0.5,271									  objCenter.y - objSize.y/2 ,272									  objCenter.z - objSize.z/2) , 273					new THREE.Vector3(objCenter.x - objSize.x/2 -1.5,274									  objCenter.y - objSize.y/2 ,275									  objCenter.z - objSize.z/2) );276		loadLine( 	main , 277					new THREE.Vector3(objCenter.x - objSize.x/2 -0.5,278									  objCenter.y - objSize.y/2 ,279									  objCenter.z + objSize.z/2) , 280					new THREE.Vector3(objCenter.x - objSize.x/2 -1.5,281									  objCenter.y - objSize.y/2 ,282									  objCenter.z + objSize.z/2) );283	}284}285function loadText(main , num , position , rotat){286	var text = (Math.round(num*10)/100).toString();287	var loader = new THREE.FontLoader();288	var font = loader.load(289		// resource URL290		'three.js-master/examples/fonts/helvetiker_regular.typeface.json',291		// onLoad callback292		function ( font ) {293			var geometry = new THREE.TextGeometry( text , {294				font: font ,295				size: 0.3,296				height: 0.05,297				curveSegments: 12,298				bevelEnabled: false,299				bevelThickness: 5,300				bevelSize: 4,301				bevelSegments: 1302			} );303			var material = new THREE.MeshBasicMaterial( { color: 0x000000 } );304			var mesh = new THREE.Mesh( geometry, material );305			mesh.position.set( position.x , position.y +0.5 , position.z );306			mesh.rotateOnWorldAxis(new THREE.Vector3(0,1,0) , rotat * Math.PI/180);307			main.scene.add( mesh );308			main.SizeObj.push( mesh );309		}310	);311}312function loadLine( main , point1 , point2){313		var material = new THREE.LineBasicMaterial({314			color: 0x000000,315			linewidth: 10,316			linecap: 'round', //ignored by WebGLRenderer317			linejoin:  'round' //ignored by WebGLRenderer318		});319		var geometry = new THREE.Geometry();320		geometry.vertices.push(321			new THREE.Vector3( point1.x , point1.y , point1.z ),322			new THREE.Vector3( point2.x , point2.y , point2.z )323		);324		var line = new THREE.Line( geometry, material );325		main.scene.add( line );326		main.SizeObj.push(line);327}...Stage_8.js
Source:Stage_8.js  
1var data; // bucket for the notification data2//each social media notifications count is listed3//value ranges between 0-20 ââ â circles -->map values?4var instagram, snapchat, messenger, facebook, email, instagramCol, snapchatCol, messengerCol, facebookCol, emailCol;5var whichHour=0; //for iterating through data6// this will make the circles bigger7var sizeMultiplier = 5; 8var time, size;9var daycounter= 1;10function preload (){11  data =loadJSON("Sunday.json");12}13function setup() {14 15   createCanvas (windowWidth, windowHeight);16   background (255);17  18   instagramCol = color (142, 68, 173, 90);19   messengerCol = color (133, 193, 233, 90);20   snapchatCol = color (247, 220, 111, 90);21   facebookCol = color (118, 215, 196, 90);22   emailCol = color (178, 186, 187, 90); 23   frameRate(0.5);24 25   26 //textSize (70);27 //fill (0);28 // textFont ("Futura");29 // text ('Sunday',600,600);30 // textSize (20);31 // text ('Press any key', 150, 380);32 // text ('click anywhere on screen',1100, 380);33 // textSize(40);34 // text ('II',200,350);35 // text ('â¥', 1200, 350);36 // var yplay;37 // angleMode (DEGREES);38   }39  40 41   42function draw () {43  for (whichHour=0; whichHour<data.hours.length; whichHour++){44    //if (frameCount > 100 * whichHour) {45    //  if (mouseX<200) {46    //    yplay = int(random(100,5));}47    //    else {yplay=1;}48    //translate (200, 200);49    //rotate(angle);50    //ellipseMode (CENTER);51    52    // Sunday53    fill (instagramCol);54    size = data.hours[whichHour].instagram*sizeMultiplier;55    //ellipse (data[whichHour], whichHour*yplay, whichHour*20, size, size);56    ellipse (random(100, 150), random (150, 500), size, size);57    //angle++;58    59    60    fill (messengerCol);61    size = data.hours[whichHour].messenger*sizeMultiplier; 62    ellipse(random(100, 150), random(150, 500), size, size);63   64    65    fill (snapchatCol);66    size = data.hours[whichHour].snapchat*sizeMultiplier; 67    rect(random(100, 150), random(150, 500), size, size);68    69    fill (facebookCol);70    size = data.hours[whichHour].facebook*sizeMultiplier; 71    square (random(100, 150), random(150, 500), size, size);72    73    fill (emailCol);74    size = data.hours[whichHour].email*sizeMultiplier; 75    ellipse(random(100, 150), random(150, 500), size, size);76    77// Monday78fill (instagramCol);79    size = data.hours[whichHour].instagram*sizeMultiplier;80    //ellipse (data[whichHour], whichHour*yplay, whichHour*20, size, size);81    ellipse (random(270, 320), random (150, 500), size, size);82    //angle++;83    84    85    fill (messengerCol);86    size = data.hours[whichHour].messenger*sizeMultiplier; 87    ellipse(random(270, 320), random(150, 500), size, size);88   89    90    fill (snapchatCol);91    size = data.hours[whichHour].snapchat*sizeMultiplier; 92    rect(random(270, 320), random(150, 500), size, size);93    94    fill (facebookCol);95    size = data.hours[whichHour].facebook*sizeMultiplier; 96    square (random(270, 320), random(150, 500), size, size);97    98    fill (emailCol);99    size = data.hours[whichHour].email*sizeMultiplier; 100    ellipse(random(270, 320), random(150, 500), size, size);101    102    //Tuesday103    fill (instagramCol);104    size = data.hours[whichHour].instagram*sizeMultiplier;105    //ellipse (data[whichHour], whichHour*yplay, whichHour*20, size, size);106    ellipse (random(440, 490), random (150, 500), size, size);107    //angle++;108    109    fill (messengerCol);110    size = data.hours[whichHour].messenger*sizeMultiplier; 111    ellipse(random(440, 490), random(150, 500), size, size);112   113    114    fill (snapchatCol);115    size = data.hours[whichHour].snapchat*sizeMultiplier; 116    rect(random(440, 490), random(150, 500), size, size);117    118    fill (facebookCol);119    size = data.hours[whichHour].facebook*sizeMultiplier; 120    square (random(440, 490), random(150, 500), size, size);121    122    fill (emailCol);123    size = data.hours[whichHour].email*sizeMultiplier; 124    ellipse(random(440, 490), random(150, 500), size, size);125    126    //Wednesday127    fill (instagramCol);128    size = data.hours[whichHour].instagram*sizeMultiplier;129    //ellipse (data[whichHour], whichHour*yplay, whichHour*20, size, size);130    ellipse (random(610, 660), random (150, 500), size, size);131    //angle++;132    133    fill (messengerCol);134    size = data.hours[whichHour].messenger*sizeMultiplier; 135    ellipse(random(610, 660), random(150, 500), size, size);136   137    138    fill (snapchatCol);139    size = data.hours[whichHour].snapchat*sizeMultiplier; 140    rect(random(610, 660), random(150, 500), size, size);141    142    fill (facebookCol);143    size = data.hours[whichHour].facebook*sizeMultiplier; 144    square (random(610, 660), random(150, 500), size, size);145    146    fill (emailCol);147    size = data.hours[whichHour].email*sizeMultiplier; 148    ellipse(random(610, 660), random(150, 500), size, size);149    150    //Thursday151    fill (instagramCol);152    size = data.hours[whichHour].instagram*sizeMultiplier;153    //ellipse (data[whichHour], whichHour*yplay, whichHour*20, size, size);154    ellipse (random(780, 830), random (150, 500), size, size);155    //angle++;156    157    fill (messengerCol);158    size = data.hours[whichHour].messenger*sizeMultiplier; 159    ellipse(random(780, 830), random(150, 500), size, size);160   161    162    fill (snapchatCol);163    size = data.hours[whichHour].snapchat*sizeMultiplier; 164    rect(random(780, 830), random(150, 500), size, size);165    166    fill (facebookCol);167    size = data.hours[whichHour].facebook*sizeMultiplier; 168    square (random(780, 830), random(150, 500), size, size);169    170    fill (emailCol);171    size = data.hours[whichHour].email*sizeMultiplier; 172    ellipse(random(780, 830), random(150, 500), size, size);173    174    //Friday175    fill (instagramCol);176    size = data.hours[whichHour].instagram*sizeMultiplier;177    //ellipse (data[whichHour], whichHour*yplay, whichHour*20, size, size);178    ellipse (random(950, 1000), random (150, 500), size, size);179    //angle++;180    181    fill (messengerCol);182    size = data.hours[whichHour].messenger*sizeMultiplier; 183    ellipse(random(950, 1000), random(150, 500), size, size);184   185    186    fill (snapchatCol);187    size = data.hours[whichHour].snapchat*sizeMultiplier; 188    rect(random(950, 1000), random(150, 500), size, size);189    190    fill (facebookCol);191    size = data.hours[whichHour].facebook*sizeMultiplier; 192    square (random(950, 1000), random(150, 500), size, size);193    194    fill (emailCol);195    size = data.hours[whichHour].email*sizeMultiplier; 196    ellipse(random(950, 1000), random(150, 500), size, size);197    198    //Saturday199    fill (instagramCol);200    size = data.hours[whichHour].instagram*sizeMultiplier;201    //ellipse (data[whichHour], whichHour*yplay, whichHour*20, size, size);202    ellipse (random(1120, 1170), random (150, 500), size, size);203    //angle++;204    205    fill (messengerCol);206    size = data.hours[whichHour].messenger*sizeMultiplier; 207    ellipse(random(1120, 1170), random(150, 500), size, size);208   209    210    fill (snapchatCol);211    size = data.hours[whichHour].snapchat*sizeMultiplier; 212    rect(random(1120, 1170), random(150, 500), size, size);213    214    fill (facebookCol);215    size = data.hours[whichHour].facebook*sizeMultiplier; 216    square (random(1120, 1170), random(150, 500), size, size);217    218    fill (emailCol);219    size = data.hours[whichHour].email*sizeMultiplier; 220    ellipse(random(1120, 1170), random(150, 500), size, size);221    }222}223//this allows you to pause the sketch with just pressing any key on the keyboard. 224function keyPressed (){225  noLoop();226}227function keyReleased (){228  loop();229}230function mousePressed (){231  background (255);232 // fill (0);233 //   textSize (70);234 //   textFont ("Futura");235    236 //   // changing the title days everytime mouse is pressed237 // if (mousePressed) {238 //   daycounter = daycounter +1;239 // }240 // if (daycounter > 7) {241 //   daycounter = 1;242 // }243  244 // if (daycounter ==2) {245 //   text ("Monday", 600, 600);246 //   }247 //if (daycounter ==3) {248 //   text ("Tuesday", 600,600);249 //   }250    251    252 // if (daycounter ==4) {253 //   text ("Wednesday", 540,600);254 //   }  255    256 //   if (daycounter ==5) {257 //   text ("Thursday", 600,600);258 //   }259    260 //   if (daycounter ==6) {261 //   text ("Friday", 620,600);262 //   }263    264 //   if (daycounter ==7) {265 //   text ("Saturday", 600,600);266 //   }267    268    269 //   textSize (20);270 // text ('Press any key', 150, 380);271 // text ('click anywhere on screen',1100, 380);272 // textSize(40);273 // text ('II',200,350);274 // text ('â¥', 1200, 350);275    276  ...Zoomify.js
Source:Zoomify.js  
1/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for2 * full list of contributors). Published under the 2-clause BSD license.3 * See license.txt in the OpenLayers distribution or repository for the4 * full text of the license. */5/*6 * Development supported by a R&D grant DC08P02OUK006 - Old Maps Online7 * (www.oldmapsonline.org) from Ministry of Culture of the Czech Republic.8 */9/**10 * @requires OpenLayers/Layer/Grid.js11 */12/**13 * Class: OpenLayers.Layer.Zoomify14 *15 * Inherits from:16 *  - <OpenLayers.Layer.Grid>17 */18OpenLayers.Layer.Zoomify = OpenLayers.Class(OpenLayers.Layer.Grid, {19    /**20     * Property: size21     * {<OpenLayers.Size>} The Zoomify image size in pixels.22     */23    size: null,24    /**25     * APIProperty: isBaseLayer26     * {Boolean}27     */28    isBaseLayer: true,29    /**30     * Property: standardTileSize31     * {Integer} The size of a standard (non-border) square tile in pixels.32     */33    standardTileSize: 256,34    /** 35     * Property: tileOriginCorner36     * {String} This layer uses top-left as tile origin37     **/38    tileOriginCorner: "tl",39    /**40     * Property: numberOfTiers41     * {Integer} Depth of the Zoomify pyramid, number of tiers (zoom levels)42     *                          - filled during Zoomify pyramid initialization.43     */44    numberOfTiers: 0,45    /**46     * Property: tileCountUpToTier47     * {Array(Integer)} Number of tiles up to the given tier of pyramid.48     *                          - filled during Zoomify pyramid initialization.49     */50    tileCountUpToTier: null,51    /**52     * Property: tierSizeInTiles53     * {Array(<OpenLayers.Size>)} Size (in tiles) for each tier of pyramid.54     *                          - filled during Zoomify pyramid initialization.55     */56    tierSizeInTiles: null,57    /**58     * Property: tierImageSize59     * {Array(<OpenLayers.Size>)} Image size in pixels for each pyramid tier.60     *                          - filled during Zoomify pyramid initialization.61     */62    tierImageSize: null,63    /**64     * Constructor: OpenLayers.Layer.Zoomify65     *66     * Parameters:67     * name - {String} A name for the layer.68     * url - {String} - Relative or absolute path to the image or more69     *        precisly to the TileGroup[X] directories root.70     *        Flash plugin use the variable name "zoomifyImagePath" for this.71     * size - {<OpenLayers.Size>} The size (in pixels) of the image.72     * options - {Object} Hashtable of extra options to tag onto the layer73     */74    initialize: function(name, url, size, options) {75        // initilize the Zoomify pyramid for given size76        this.initializeZoomify(size);77        OpenLayers.Layer.Grid.prototype.initialize.apply(this, [78            name, url, size, {}, options79        ]);80    },81    /**82     * Method: initializeZoomify83     * It generates constants for all tiers of the Zoomify pyramid84     *85     * Parameters:86     * size - {<OpenLayers.Size>} The size of the image in pixels87     *88     */89    initializeZoomify: function( size ) {90        var imageSize = size.clone();91        this.size = size.clone();92        var tiles = new OpenLayers.Size(93            Math.ceil( imageSize.w / this.standardTileSize ),94            Math.ceil( imageSize.h / this.standardTileSize )95            );96        this.tierSizeInTiles = [tiles];97        this.tierImageSize = [imageSize];98        while (imageSize.w > this.standardTileSize ||99               imageSize.h > this.standardTileSize ) {100            imageSize = new OpenLayers.Size(101                Math.floor( imageSize.w / 2 ),102                Math.floor( imageSize.h / 2 )103                );104            tiles = new OpenLayers.Size(105                Math.ceil( imageSize.w / this.standardTileSize ),106                Math.ceil( imageSize.h / this.standardTileSize )107                );108            this.tierSizeInTiles.push( tiles );109            this.tierImageSize.push( imageSize );110        }111        this.tierSizeInTiles.reverse();112        this.tierImageSize.reverse();113        this.numberOfTiers = this.tierSizeInTiles.length;114        var resolutions = [1];115        this.tileCountUpToTier = [0];116        for (var i = 1; i < this.numberOfTiers; i++) {117            resolutions.unshift(Math.pow(2, i));118            this.tileCountUpToTier.push(119                this.tierSizeInTiles[i-1].w * this.tierSizeInTiles[i-1].h +120                this.tileCountUpToTier[i-1]121                );122        }123        if (!this.serverResolutions) {124            this.serverResolutions = resolutions;125        }126    },127    /**128     * APIMethod:destroy129     */130    destroy: function() {131        // for now, nothing special to do here.132        OpenLayers.Layer.Grid.prototype.destroy.apply(this, arguments);133        // Remove from memory the Zoomify pyramid - is that enough?134        this.tileCountUpToTier.length = 0;135        this.tierSizeInTiles.length = 0;136        this.tierImageSize.length = 0;137    },138    /**139     * APIMethod: clone140     *141     * Parameters:142     * obj - {Object}143     *144     * Returns:145     * {<OpenLayers.Layer.Zoomify>} An exact clone of this <OpenLayers.Layer.Zoomify>146     */147    clone: function (obj) {148        if (obj == null) {149            obj = new OpenLayers.Layer.Zoomify(this.name,150                                           this.url,151                                           this.size,152                                           this.options);153        }154        //get all additions from superclasses155        obj = OpenLayers.Layer.Grid.prototype.clone.apply(this, [obj]);156        // copy/set any non-init, non-simple values here157        return obj;158    },159    /**160     * Method: getURL161     *162     * Parameters:163     * bounds - {<OpenLayers.Bounds>}164     *165     * Returns:166     * {String} A string with the layer's url and parameters and also the167     *          passed-in bounds and appropriate tile size specified as168     *          parameters169     */170    getURL: function (bounds) {171        bounds = this.adjustBounds(bounds);172        var res = this.getServerResolution();173        var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w));174        var y = Math.round((this.tileOrigin.lat - bounds.top) / (res * this.tileSize.h));175        var z = this.getZoomForResolution( res );176        var tileIndex = x + y * this.tierSizeInTiles[z].w + this.tileCountUpToTier[z];177        var path = "TileGroup" + Math.floor( (tileIndex) / 256 ) +178            "/" + z + "-" + x + "-" + y + ".jpg";179        var url = this.url;180        if (OpenLayers.Util.isArray(url)) {181            url = this.selectUrl(path, url);182        }183        return url + path;184    },185    /**186     * Method: getImageSize187     * getImageSize returns size for a particular tile. If bounds are given as188     * first argument, size is calculated (bottom-right tiles are non square).189     *190     */191    getImageSize: function() {192        if (arguments.length > 0) {193            var bounds = this.adjustBounds(arguments[0]);194            var res = this.getServerResolution();195            var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w));196            var y = Math.round((this.tileOrigin.lat - bounds.top) / (res * this.tileSize.h));197            var z = this.getZoomForResolution( res );198            var w = this.standardTileSize;199            var h = this.standardTileSize;200            if (x == this.tierSizeInTiles[z].w -1 ) {201                var w = this.tierImageSize[z].w % this.standardTileSize;202            }203            if (y == this.tierSizeInTiles[z].h -1 ) {204                var h = this.tierImageSize[z].h % this.standardTileSize;205            }206            return (new OpenLayers.Size(w, h));207        } else {208            return this.tileSize;209        }210    },211    /**212     * APIMethod: setMap213     * When the layer is added to a map, then we can fetch our origin214     *    (if we don't have one.)215     *216     * Parameters:217     * map - {<OpenLayers.Map>}218     */219    setMap: function(map) {220        OpenLayers.Layer.Grid.prototype.setMap.apply(this, arguments);221        this.tileOrigin = new OpenLayers.LonLat(this.map.maxExtent.left,222                                                this.map.maxExtent.top);223    },224    CLASS_NAME: "OpenLayers.Layer.Zoomify"...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
