How to use size method in navalia

Best JavaScript code snippet using navalia

mep-feature-backlight.js

Source:mep-feature-backlight.js Github

copy

Full Screen

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 }...

Full Screen

Full Screen

MarkSize.js

Source:MarkSize.js Github

copy

Full Screen

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}...

Full Screen

Full Screen

Stage_8.js

Source:Stage_8.js Github

copy

Full Screen

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 ...

Full Screen

Full Screen

Zoomify.js

Source:Zoomify.js Github

copy

Full Screen

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"...

Full Screen

Full Screen

intersection-tooltip-venn.js

Source:intersection-tooltip-venn.js Github

copy

Full Screen

1/*=========================================================================================2 File Name: intersection-tooltip-venn.js3 Description: D3 intersection tooltip venn diagram4 ----------------------------------------------------------------------------------------5 Item Name: Modern Admin - Clean Bootstrap 4 Dashboard HTML Template6 Version: 3.07 Author: PIXINVENT8 Author URL: http://www.themeforest.net/user/pixinvent9==========================================================================================*/10// Intersection tooltip venn diagram11// ----------------------------------12$(window).on("load", function(){13 var sets = [14 {"sets": [0], "label": "Radiohead", "size": 77348},15 {"sets": [1], "label": "Thom Yorke", "size": 5621},16 {"sets": [2], "label": "John Lennon", "size": 7773},17 {"sets": [3], "label": "Kanye West", "size": 27053},18 {"sets": [4], "label": "Eminem", "size": 19056},19 {"sets": [5], "label": "Elvis Presley", "size": 15839},20 {"sets": [6], "label": "Explosions in the Sky", "size": 10813},21 {"sets": [7], "label": "Bach", "size": 9264},22 {"sets": [8], "label": "Mozart", "size": 3959},23 {"sets": [9], "label": "Philip Glass", "size": 4793},24 {"sets": [10], "label": "St. Germain", "size": 4136},25 {"sets": [11], "label": "Morrissey", "size": 10945},26 {"sets": [12], "label": "Outkast", "size": 8444},27 {"sets": [0, 1], "size": 4832},28 {"sets": [0, 2], "size": 2602},29 {"sets": [0, 3], "size": 6141},30 {"sets": [0, 4], "size": 2723},31 {"sets": [0, 5], "size": 3177},32 {"sets": [0, 6], "size": 5384},33 {"sets": [0, 7], "size": 2252},34 {"sets": [0, 8], "size": 877},35 {"sets": [0, 9], "size": 1663},36 {"sets": [0, 10], "size": 899},37 {"sets": [0, 11], "size": 4557},38 {"sets": [0, 12], "size": 2332},39 {"sets": [1, 2], "size": 162},40 {"sets": [1, 3], "size": 396},41 {"sets": [1, 4], "size": 133},42 {"sets": [1, 5], "size": 135},43 {"sets": [1, 6], "size": 511},44 {"sets": [1, 7], "size": 159},45 {"sets": [1, 8], "size": 47},46 {"sets": [1, 9], "size": 168},47 {"sets": [1, 10], "size": 68},48 {"sets": [1, 11], "size": 336},49 {"sets": [1, 12], "size": 172},50 {"sets": [2, 3], "size": 406},51 {"sets": [2, 4], "size": 350},52 {"sets": [2, 5], "size": 1335},53 {"sets": [2, 6], "size": 145},54 {"sets": [2, 7], "size": 347},55 {"sets": [2, 8], "size": 176},56 {"sets": [2, 9], "size": 119},57 {"sets": [2, 10], "size": 46},58 {"sets": [2, 11], "size": 418},59 {"sets": [2, 12], "size": 146},60 {"sets": [3, 4], "size": 5465},61 {"sets": [3, 5], "size": 849},62 {"sets": [3, 6], "size": 724},63 {"sets": [3, 7], "size": 273},64 {"sets": [3, 8], "size": 143},65 {"sets": [3, 9], "size": 180},66 {"sets": [3, 10], "size": 218},67 {"sets": [3, 11], "size": 599},68 {"sets": [3, 12], "size": 3453},69 {"sets": [4, 5], "size": 977},70 {"sets": [4, 6], "size": 232},71 {"sets": [4, 7], "size": 250},72 {"sets": [4, 8], "size": 166},73 {"sets": [4, 9], "size": 97},74 {"sets": [4, 10], "size": 106},75 {"sets": [4, 11], "size": 225},76 {"sets": [4, 12], "size": 1807},77 {"sets": [5, 6], "size": 196},78 {"sets": [5, 7], "size": 642},79 {"sets": [5, 8], "size": 336},80 {"sets": [5, 9], "size": 165},81 {"sets": [5, 10], "size": 143},82 {"sets": [5, 11], "size": 782},83 {"sets": [5, 12], "size": 332},84 {"sets": [6, 7], "size": 262},85 {"sets": [6, 8], "size": 85},86 {"sets": [6, 9], "size": 284},87 {"sets": [6, 10], "size": 68},88 {"sets": [6, 11], "size": 363},89 {"sets": [6, 12], "size": 218},90 {"sets": [7, 8], "size": 1581},91 {"sets": [7, 9], "size": 716},92 {"sets": [7, 10], "size": 133},93 {"sets": [7, 11], "size": 254},94 {"sets": [7, 12], "size": 132},95 {"sets": [8, 9], "size": 280},96 {"sets": [8, 10], "size": 53},97 {"sets": [8, 11], "size": 117},98 {"sets": [8, 12], "size": 67},99 {"sets": [9, 10], "size": 57},100 {"sets": [9, 11], "size": 184},101 {"sets": [9, 12], "size": 89},102 {"sets": [10, 11], "size": 51},103 {"sets": [10, 12], "size": 115},104 {"sets": [11, 12], "size": 162},105 {"sets": [0, 1, 6], "size": 480},106 {"sets": [0, 1, 9], "size": 152},107 {"sets": [0, 2, 7], "size": 112},108 {"sets": [0, 3, 4], "size": 715},109 {"sets": [0, 3, 12], "size": 822},110 {"sets": [0, 4, 5], "size": 160},111 {"sets": [0, 5, 11], "size": 292},112 {"sets": [0, 6, 12], "size": 122},113 {"sets": [0, 7, 11], "size": 118},114 {"sets": [0, 9, 10], "size" :13},115 {"sets": [2, 7, 8], "size": 72}116 ];117 var chart = venn.VennDiagram()118 .width(400)119 .height(400)120 .fontSize("14px");121 var div = d3.select("#intersection-tooltip-venn");122 div.datum(sets).call(chart);123 var tooltip = d3.select("body").append("div")124 .attr("class", "venntooltip");125 div.selectAll("path")126 .style("stroke-opacity", 0)127 .style("stroke", "#fff")128 .style("stroke-width", 0);129 div.selectAll("text")130 .style("font-weight", "400");131 div.selectAll("g")132 .on("mouseover", function(d, i) {133 // sort all the areas relative to the current item134 venn.sortAreas(div, d);135 // Display a tooltip with the current size136 tooltip.transition().duration(400).style("opacity", .9);137 tooltip.text(d.size + " users");138 // highlight the current path139 var selection = d3.select(this).transition("tooltip").duration(400);140 selection.select("path")141 .style("stroke-width", 3)142 .style("fill-opacity", d.sets.length == 1 ? .4 : .1)143 .style("stroke-opacity", 1);144 })145 .on("mousemove", function() {146 tooltip.style("left", (d3.event.pageX) + "px")147 .style("top", (d3.event.pageY - 28) + "px");148 })149 .on("mouseout", function(d, i) {150 tooltip.transition().duration(400).style("opacity", 0);151 var selection = d3.select(this).transition("tooltip").duration(400);152 selection.select("path")153 .style("stroke-width", 0)154 .style("fill-opacity", d.sets.length == 1 ? .25 : .0)155 .style("stroke-opacity", 0);156 });...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1import React from 'react';2import SplitPane from 'react-split-pane';3import { isSmallMobileScreen } from 'embed/util/mobile';4import { GlobalActions, NavigationActions } from '../Actions';5import { Container, PaneContainer, RESIZER_WIDTH } from './elements';6export default function SplitView({7 showEditor,8 showPreview,9 isSmallScreen,10 sidebarOpen,11 children,12 showNavigationActions,13 refresh,14 openInNewWindow,15 sandbox,16 toggleLike,17 initialEditorSize = 50, // in percent18 initialPath,19 hideDevTools,20 setEditorSize,21 setDragging: setDraggingProp,22 ...props23}) {24 /* Things this component should do25 1. set inital size based on props26 2. let user move it around27 3. snap to edges28 4. stay snapped on window.resize and sidebar toggle (not implemented)29 5. introduce the resizer element with animation30 */31 const windowWidth = document.body.clientWidth;32 // TODO: pick this from the sidebar or ref instead of hardcoding33 const sidebarWidth = 250;34 const maxSize =35 (sidebarOpen ? windowWidth - sidebarWidth : windowWidth) - RESIZER_WIDTH;36 // #1. set initial size based on props37 let initialSize = null;38 if (showEditor && showPreview)39 initialSize = (initialEditorSize / 100) * maxSize;40 else if (showEditor && !showPreview) initialSize = maxSize;41 else if (showPreview && !showEditor) initialSize = 0;42 const [size, setSize] = React.useState(initialSize);43 React.useEffect(() => {44 setEditorSize(size);45 }, [size, setEditorSize]);46 // #2. We track dragging so that we can add an overlay on top47 // of the iframe which lets us keep focus on the resize toggle48 const [isDragging, setDragging] = React.useState(false);49 // #3. snap to edges, much logic, such wow.50 const handleAutomaticSnapping = newSize => {51 /* snap threshold on desktop is 50px on the left52 and 175px on the right (to keep the open sandbox button on one side)53 On mobile, it's 50% of the screen54 */55 const leftSnapThreshold = isSmallScreen ? maxSize / 2 : 50;56 const rightSnapThreshold = isSmallScreen ? maxSize / 2 : maxSize - 175;57 if (newSize === size) {58 /* if the size is unchanged, we assume it's a click.59 we don't rely on onResizerClick from react-split-pane60 because it requires the resizer to have some size which61 in our case isn't true because we artificially overlap62 the resizer on top of the preview/editor63 on mobile, we want to flip the current state.64 on desktop, we want to set it half if it's snapped to an edge.65 */66 if (isSmallScreen) setSize(size === 0 ? maxSize : 0);67 else if (size === 0 || size === maxSize) setSize(maxSize / 2);68 } else {69 // this means the user was able to drag70 // eslint-disable-next-line no-lonely-if71 if (newSize < leftSnapThreshold) setSize(0);72 else if (newSize > rightSnapThreshold) setSize(maxSize);73 else setSize(Math.min(newSize, maxSize));74 }75 };76 const onDragStarted = () => {77 setDragging(true);78 setDraggingProp(true);79 };80 const onDragFinished = newSize => {81 setDragging(false);82 setDraggingProp(false);83 // react-split-pane doesn't set newSize until84 // the end of the first drag, that breaks the click case85 // so we set it to the size that already is set86 handleAutomaticSnapping(newSize || size);87 setEditorSize(size);88 };89 const openEditor = () => {90 setSize(maxSize);91 };92 const openPreview = () => {93 setSize(0);94 };95 // TODO: #4. Handle edge case of keeping panes snapped96 // on window.resize and sidebar toggle97 /* We need at least 270px of space in the preview to98 fit global actions and navigation actions99 if there isn't enough space, navigation gets100 depririotized101 */102 const outOfSpaceForNavigation = maxSize - size < 270;103 /**104 * For small touch screens we show different buttons. We change for example that the105 * editor can be opened with a button106 */107 const smallTouchScreen = isSmallMobileScreen();108 return (109 <Container110 isDragging={isDragging}111 size={size}112 maxSize={maxSize}113 fullSize={size === maxSize}114 >115 <GlobalActions116 sandbox={sandbox}117 toggleLike={toggleLike}118 previewVisible={size < maxSize}119 isDragging={isDragging}120 offsetBottom={!hideDevTools && size < maxSize}121 openEditor={openEditor}122 openPreview={openPreview}123 smallTouchScreen={smallTouchScreen}124 initialPath={initialPath}125 />126 <SplitPane127 split="vertical"128 onDragStarted={onDragStarted}129 onDragFinished={onDragFinished}130 minSize="0%"131 maxSize={maxSize}132 onMouseEnter={onDragStarted}133 size={size}134 {...props}135 >136 <PaneContainer>{children[0]}</PaneContainer>137 <PaneContainer>138 {showNavigationActions && !outOfSpaceForNavigation ? (139 <NavigationActions140 refresh={refresh}141 openInNewWindow={openInNewWindow}142 isDragging={isDragging}143 offsetBottom={!hideDevTools && size < maxSize}144 />145 ) : null}146 {children[1]}147 </PaneContainer>148 </SplitPane>149 </Container>150 );...

Full Screen

Full Screen

size.test.js

Source:size.test.js Github

copy

Full Screen

1goog.provide('ol.test.size');2describe('ol.size', function() {3 describe('buffer()', function() {4 it('buffers a size', function() {5 var size = [50, 75];6 var bufferedSize = ol.size.buffer(size, 20);7 expect(bufferedSize).to.eql([90, 115]);8 });9 it('reuses an existing array', function() {10 var reuse = [0, 0];11 var size = [50, 50];12 var bufferedSize = ol.size.buffer(size, 20, reuse);13 expect(bufferedSize).to.equal(reuse);14 });15 });16 describe('hasArea()', function() {17 it('determines if a size has a positive area', function() {18 expect(ol.size.hasArea([50, 75])).to.equal(true);19 expect(ol.size.hasArea([0, 75])).to.equal(false);20 expect(ol.size.hasArea([50, 0])).to.equal(false);21 expect(ol.size.hasArea([0, 0])).to.equal(false);22 expect(ol.size.hasArea([-1, 75])).to.equal(false);23 expect(ol.size.hasArea([50, -1])).to.equal(false);24 expect(ol.size.hasArea([-1, -1])).to.equal(false);25 });26 });27 describe('scale()', function() {28 it('scales a size and rounds the result', function() {29 var size = [50, 75];30 var scaledSize = ol.size.scale(size, 1.75);31 expect(scaledSize).to.eql([88, 131]);32 });33 it('reuses an existing array', function() {34 var reuse = [0, 0];35 var size = [50, 50];36 var scaledSize = ol.size.scale(size, 1.75, reuse);37 expect(scaledSize).to.equal(reuse);38 });39 });40 describe('toSize()', function() {41 it('creates a size array from a number', function() {42 var size = ol.size.toSize(512);43 expect(size).to.eql([512, 512]);44 });45 it('reuses an existing array', function() {46 var sizeArray = [0, 0];47 var size = ol.size.toSize(512, sizeArray);48 expect(size).to.equal(sizeArray);49 });50 it('returns a size array unaltered', function() {51 var sizeArray = [512, 256];52 var size = ol.size.toSize(sizeArray);53 expect(size).to.equal(sizeArray);54 size = ol.size.toSize(sizeArray, [0, 0]);55 expect(size).to.equal(sizeArray);56 });57 });58});...

Full Screen

Full Screen

size.js

Source:size.js Github

copy

Full Screen

1goog.provide('ol.Size');2goog.provide('ol.size');3goog.require('goog.asserts');4/**5 * An array of numbers representing a size: `[width, height]`.6 * @typedef {Array.<number>}7 * @api stable8 */9ol.Size;10/**11 * Returns a buffered size.12 * @param {ol.Size} size Size.13 * @param {number} buffer Buffer.14 * @param {ol.Size=} opt_size Optional reusable size array.15 * @return {ol.Size}16 */17ol.size.buffer = function(size, buffer, opt_size) {18 if (opt_size === undefined) {19 opt_size = [0, 0];20 }21 opt_size[0] = size[0] + 2 * buffer;22 opt_size[1] = size[1] + 2 * buffer;23 return opt_size;24};25/**26 * Compares sizes for equality.27 * @param {ol.Size} a Size.28 * @param {ol.Size} b Size.29 * @return {boolean} Equals.30 */31ol.size.equals = function(a, b) {32 return a[0] == b[0] && a[1] == b[1];33};34/**35 * Determines if a size has a positive area.36 * @param {ol.Size} size The size to test.37 * @return {boolean} The size has a positive area.38 */39ol.size.hasArea = function(size) {40 return size[0] > 0 && size[1] > 0;41};42/**43 * Returns a size scaled by a ratio. The result will be an array of integers.44 * @param {ol.Size} size Size.45 * @param {number} ratio Ratio.46 * @param {ol.Size=} opt_size Optional reusable size array.47 * @return {ol.Size}48 */49ol.size.scale = function(size, ratio, opt_size) {50 if (opt_size === undefined) {51 opt_size = [0, 0];52 }53 opt_size[0] = (size[0] * ratio + 0.5) | 0;54 opt_size[1] = (size[1] * ratio + 0.5) | 0;55 return opt_size;56};57/**58 * Returns an `ol.Size` array for the passed in number (meaning: square) or59 * `ol.Size` array.60 * (meaning: non-square),61 * @param {number|ol.Size} size Width and height.62 * @param {ol.Size=} opt_size Optional reusable size array.63 * @return {ol.Size} Size.64 * @api stable65 */66ol.size.toSize = function(size, opt_size) {67 if (goog.isArray(size)) {68 return size;69 } else {70 goog.asserts.assert(goog.isNumber(size));71 if (opt_size === undefined) {72 opt_size = [size, size];73 } else {74 opt_size[0] = size;75 opt_size[1] = size;76 }77 return opt_size;78 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const navalia = require('navalia');2const browser = new navalia();3 .size()4 .then(size => console.log(size))5 .then(() => browser.close());6const puppeteer = require('puppeteer');7(async () => {8 const browser = await puppeteer.launch();9 const page = await browser.newPage();10 const dimensions = await page.evaluate(() => {11 return {12 };13 });14 console.log('Dimensions:', dimensions);15 await browser.close();16})();17const Nightmare = require('nightmare');18const nightmare = Nightmare({ show: true });19 .evaluate(() => {20 return {21 };22 })23 .end()24 .then(dimensions => console.log(dimensions));25const webdriverio = require('webdriverio');26const options = { desiredCapabilities: { browserName: 'chrome' } };27const client = webdriverio.remote(options);28 .init()29 .execute(function() {30 return {31 };32 })33 .then(result => console.log(result.value))34 .end();35var casper = require('casper').create();36 this.echo(37 this.evaluate(function() {38 return {39 };40 })41 );42});43casper.run();44const { Builder, By, Key, until } = require('selenium-webdriver');45const driver = new Builder().forBrowser('chrome').build();

Full Screen

Using AI Code Generation

copy

Full Screen

1const navalia = require('navalia');2const browser = new navalia();3 .size()4 .then(size => {5 console.log(size);6 })7 .catch(error => {8 console.log(error);9 });10MIT © [Karthik Muthukumar](

Full Screen

Using AI Code Generation

copy

Full Screen

1const navalia = require('navalia');2const browser = new navalia();3 .launch()4 .then(() => browser.size({width: 1000, height: 1000}))5 .then(() => browser.size())6 .then(size => console.log(size))7 .then(() => browser.close());8{ width: 1000, height: 1000 }

Full Screen

Using AI Code Generation

copy

Full Screen

1var navalia = require('navalia');2navalia.use('phantomjs');3var browser = navalia.createBrowser();4 .size()5 .then(function(size) {6 console.log(size);7 });8{ width: 1024, height: 768 }9var navalia = require('navalia');10navalia.use('phantomjs');11var browser = navalia.createBrowser();12 .size({ width: 800, height: 600 })13 .then(function(size) {14 console.log(size);15 });16{ width: 800, height: 600 }17var navalia = require('navalia');18navalia.use('phantomjs');19var browser = navalia.createBrowser();20 .size({ width: 800, height: 600 })21 .size()22 .then(function(size) {23 console.log(size);24 });25{ width: 800, height: 600 }26var navalia = require('navalia');27navalia.use('phantomjs');28var browser = navalia.createBrowser();29 .title()30 .then(function(title) {31 console.log(title);32 });33var navalia = require('navalia');34navalia.use('phantomjs');35var browser = navalia.createBrowser();36 .url()37 .then(function(url) {38 console.log(url);39 });40var navalia = require('navalia');41navalia.use('phantomjs');42var browser = navalia.createBrowser();43 .url()44 .then(function(url) {45 console.log(url

Full Screen

Using AI Code Generation

copy

Full Screen

1const Navalia = require('navalia');2const browser = new Navalia();3 .goto(url)4 .size()5 .then((size) => {6 console.log(size);7 })8 .catch((error) => {9 console.error(error);10 });11const Navalia = require('navalia');12const browser = new Navalia();13 .goto(url)14 .screenshot()15 .then((screenshot) => {16 console.log(screenshot);17 })18 .catch((error) => {19 console.error(error);20 });21const Navalia = require('navalia');22const browser = new Navalia();23 .goto(url)24 .screenshot()25 .then((screenshot) => {26 console.log(screenshot);27 })28 .catch((error) => {29 console.error(error);30 });31const Navalia = require('navalia');32const browser = new Navalia();33 .goto(url)34 .scroll(0, 100)35 .then((screenshot) => {36 console.log(screenshot);37 })38 .catch((error) => {39 console.error(error);40 });41const Navalia = require('navalia');42const browser = new Navalia();43 .goto(url)44 .scrollTo(0, 100)45 .then((screenshot) => {46 console.log(screenshot);47 })48 .catch((error) => {49 console.error(error);50 });51const Navalia = require('navalia');52const browser = new Navalia();

Full Screen

Using AI Code Generation

copy

Full Screen

1var navalia = require('navalia');2navalia(function (browser, done) {3 .size()4 .then(function (size) {5 console.log(size);6 done();7 });8});9var navalia = require('navalia');10navalia(function (browser, done) {11 .size()12 .then(function (size) {13 console.log(size);14 done();15 });16});17var navalia = require('navalia');18navalia(function (browser, done) {19 .size()20 .then(function (size) {21 console.log(size);22 done();23 });24});25var navalia = require('navalia');26navalia(function (browser, done) {27 .size()28 .then(function (size) {29 console.log(size);30 done();31 });32});33var navalia = require('navalia');34navalia(function (browser, done) {35 .size()36 .then(function (size) {37 console.log(size);38 done();39 });40});41var navalia = require('navalia');42navalia(function (browser, done) {43 .size()44 .then(function (size) {45 console.log(size);46 done();47 });48});

Full Screen

Using AI Code Generation

copy

Full Screen

1var navalia = require('navalia');2var browser = navalia('chrome');3 .size()4 .then(function(size){5 console.log(size);6 browser.close();7 })8 .catch(function(err){9 console.log(err);10 browser.close();11 });

Full Screen

Using AI Code Generation

copy

Full Screen

1var navalia = require('navalia');2var browser = navalia();3 .size(400, 600)4 .windowSize()5 .then(function (size) {6 console.log(size);7 });8var navalia = require('navalia');9var browser = navalia();10 .windowSize()11 .then(function (size) {12 console.log(size);13 });

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run navalia automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful