From d90f7ccf23b4571f2c88b748ef5ccd3c8ce82e45 Mon Sep 17 00:00:00 2001 From: Paarth Date: Sat, 23 Jul 2016 21:08:37 +0530 Subject: [PATCH 1/2] Make Max Wind Intensity configurable --- components/renderers/renderer.js | 10 ++++++---- dist/windable.js | 11 ++++++----- dist/windable.min.js | 2 +- examples/googleMaps/basic.html | 2 +- examples/leaflet/basic.html | 2 +- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/components/renderers/renderer.js b/components/renderers/renderer.js index c78b6e2..0630b35 100644 --- a/components/renderers/renderer.js +++ b/components/renderers/renderer.js @@ -28,7 +28,7 @@ import {math} from './../utilities/math'; import {palettes} from './../utilities/palettes'; // Wind velocity at which particle intensity is maximum (m/s). -const MAX_WIND_INTENSITY = 30; +// const MAX_WIND_INTENSITY = 30; // Max number of frames a particle is drawn before regeneration. const MAX_PARTICLE_AGE = 100; @@ -83,7 +83,9 @@ export class Renderer { // Line width of a drawn particle. particleWidth: 2, // Reduce particle count to this fraction (improves FPS). - particleReduction: 0.1 + particleReduction: 0.1, + // Wind velocity at which particle intensity is maximum (m/s). + maxWindIntensity: 30 }; // Determine the context type. @@ -407,7 +409,7 @@ export class Renderer { this.config_.colorScheme.indexFor = (m) => { // map wind speed to a style const length = this.config_.colorScheme.length - 1; return Math.floor( - Math.min(m, MAX_WIND_INTENSITY) / MAX_WIND_INTENSITY * length); + Math.min(m, this.config_.maxWindIntensity) / this.config_.maxWindIntensity * length); }; this.rgbColorScheme_ = { @@ -457,7 +459,7 @@ export class Renderer { * @return {!Array>} [hexColor, velocity] */ velocityScale() { - const increment = MAX_WIND_INTENSITY / this.config_.colorScheme.length; + const increment = this.config_.maxWindIntensity / this.config_.colorScheme.length; return this.config_.colorScheme.map((color, idx) => { idx += 1; let value = idx * increment; diff --git a/dist/windable.js b/dist/windable.js index 1df876f..224f6f3 100644 --- a/dist/windable.js +++ b/dist/windable.js @@ -315,7 +315,7 @@ var _palettes = require('./../utilities/palettes'); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } // Wind velocity at which particle intensity is maximum (m/s). -var MAX_WIND_INTENSITY = 30; +// const MAX_WIND_INTENSITY = 30; // Max number of frames a particle is drawn before regeneration. var MAX_PARTICLE_AGE = 100; @@ -371,7 +371,9 @@ var Renderer = exports.Renderer = function () { // Line width of a drawn particle. particleWidth: 2, // Reduce particle count to this fraction (improves FPS). - particleReduction: 0.1 + particleReduction: 0.1, + // Wind velocity at which particle intensity is maximum (m/s). + maxWindIntensity: 30 }; // Determine the context type. @@ -725,7 +727,7 @@ var Renderer = exports.Renderer = function () { this.config_.colorScheme.indexFor = function (m) { // map wind speed to a style var length = _this4.config_.colorScheme.length - 1; - return Math.floor(Math.min(m, MAX_WIND_INTENSITY) / MAX_WIND_INTENSITY * length); + return Math.floor(Math.min(m, _this4.config_.maxWindIntensity) / _this4.config_.maxWindIntensity * length); }; this.rgbColorScheme_ = { @@ -779,7 +781,7 @@ var Renderer = exports.Renderer = function () { value: function velocityScale() { var _this5 = this; - var increment = MAX_WIND_INTENSITY / this.config_.colorScheme.length; + var increment = this.config_.maxWindIntensity / this.config_.colorScheme.length; return this.config_.colorScheme.map(function (color, idx) { idx += 1; var value = idx * increment; @@ -1144,7 +1146,6 @@ var WindMap = exports.WindMap = function () { * * @param {!ConfigPayload} config An instance of ConfigPayload. */ - function WindMap(config) { var _this = this; diff --git a/dist/windable.min.js b/dist/windable.min.js index bfd6357..780368e 100644 --- a/dist/windable.min.js +++ b/dist/windable.min.js @@ -1 +1 @@ -!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g0&&(c.context.beginPath(),c.context.strokeStyle=c.config_.colorScheme[b],a.forEach(function(a){c.context.moveTo(a.x1,a.y1),c.context.lineTo(a.x2,a.y2)}),c.context.stroke())}),this}},{key:"clear_",value:function(){return h(Object.getPrototypeOf(b.prototype),"clear_",this).call(this),this.mapBounds_?(this.context.clearRect(0,0,this.mapBounds_.width,this.mapBounds_.height),this.context.resetTransform?this.context.resetTransform():this.context.setTransform(1,0,0,1,0,0),this):void 0}}]),b}(i.Renderer)},{"./../renderer":5}],3:[function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function e(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!=typeof b&&"function"!=typeof b?a:b}function f(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}Object.defineProperty(c,"__esModule",{value:!0}),c.WebGLRenderer=void 0;var g=function(){function a(a,b){for(var c=0;c0||Math.abs(this.mapBounds_.west)-Math.abs(this.mapBounds_.east)===0||!this.data_)return void(a.boundsExceededCallback&&a.boundsExceededCallback(this.mapBounds_));this.config_.colorScheme=a.colorScheme||this.config_.colorScheme,this.config_.velocityScale=a.velocityScale||this.config_.velocityScale,this.config_.particleWidth=a.particleWidth||this.config_.particleWidth,this.config_.particleFadeOpacity=a.particleFadeOpacity||this.config_.particleFadeOpacity,this.config_.particleReduction=a.particleReduction||this.config_.particleReduction;var f=this.buildGrid_(this.data_),h=this.buildBounds_(e,c,d);return this.grid_=f,this.field_=this.interpolateField_(f,h,this.mapBounds_),this.stopped_=!1,this.animate_(h,this.data_[0].data.length)}},{key:"stop_",value:function(){return this.clear_(),this.stopped_=!0,this.field_&&this.field_.release(),this}},{key:"buildGrid_",value:function(a){for(var b=this,c=a[0],d=a[1],e=function(a){return[c.data[a],d.data[a]]},h=c.header.lo1,i=c.header.la1,j=c.header.dx,k=c.header.dy,l=c.header.nx,m=c.header.ny,n=[],o=Math.floor(l*j)>=360,p=0,q=0;m>q;q++){for(var r=[],s=0;l>s;s++,p++)r[s]=e(p);o&&r.push(r[0]),n[q]=r}var t=function(a,c){var d=g.math.floorMod(a-h,360)/j,e=(i-c)/k,l=Math.floor(d),m=l+1,o=Math.floor(e),p=o+1,q=void 0;if(q=n[o]){var r=q[l],s=q[m];if((0,f.isValue)(r)&&(0,f.isValue)(s)&&(q=n[p])){var t=q[l],u=q[m];if((0,f.isValue)(t)&&(0,f.isValue)(u)){var v=g.math.bilinearInterpolateVector(d-l,e-o,r,s,t,u);return v[2]>b.maxWindSpeed_&&(b.maxWindSpeed_=v[2]),v}}}return null};return t.bind(this)}},{key:"distort_",value:function(a,b,c,d,e,f){var h=f[0]*e,i=f[1]*e,j=g.math.distortion(a,b,c,d,this.mapBounds_);return f[0]=j[0]*h+j[2]*i,f[1]=j[1]*h+j[3]*i,f}},{key:"createField_",value:function(a,b){function c(b,c){var d=a[Math.round(b)];return d&&d[Math.round(c)]||k}return c.release=function(){a=[]},c.randomize=function(a){return Object.assign(a,{x1:Math.round(Math.floor(Math.random()*b.width)+b.x),y1:Math.round(Math.floor(Math.random()*b.height)+b.y)})},c}},{key:"buildBounds_",value:function(a,b,c){var d=a[0],e=a[1],f=Math.round(d[0]),g=Math.max(Math.floor(d[1],0),0),h=(Math.min(Math.ceil(e[0],b),b-1),Math.min(Math.ceil(e[1],c),c-1));return{x:f,y:g,xMax:b,yMax:h,width:b,height:c}}},{key:"interpolateField_",value:function(a,b){for(var c=this,d=b.height*this.config_.velocityScale,e=b.x,f=[],h=function(e){for(var h=[],i=b.y;i<=b.yMax;i+=2){var j=g.math.invert(e,i,c.mapBounds_);if(j){var k=j[0],l=j[1];if(isFinite(k)){var m=a(k,l);m&&(m=c.distort_(k,l,e,i,d,m),h[i+1]=h[i]=m)}}}f[e+1]=f[e]=h};ej&&(d.field_.randomize(b).age=0);var e=d.field_(b.x1,b.y1);if(null===e[2])b.age=j;else{var f=b.x1+e[0],g=b.y1+e[1];if(null!==d.field_(f,g)[2]){b.x2=f,b.y2=g;var h=d.config_.colorScheme.indexFor(e[2]),i=d.rgbColorScheme_.get(h);a[h].push(b),d.particleVectors_.push(b.x1),d.particleVectors_.push(b.y1),i.forEach(function(a){d.particleVectors_.push(a)}),d.particleVectors_.push(b.x2),d.particleVectors_.push(b.y2),i.forEach(function(a){d.particleVectors_.push(a)})}else b.x1=f,b.y1=g}b.age+=1})}},{key:"animate_",value:function(a,b){var c=this;this.config_.colorScheme.indexFor=function(a){var b=c.config_.colorScheme.length-1;return Math.floor(Math.min(a,i)/i*b)},this.rgbColorScheme_={colors:this.config_.colorScheme.map(function(a){a=a.replace("#","");var b=parseInt(a.substring(0,2),16),c=parseInt(a.substring(2,4),16),d=parseInt(a.substring(4,6),16);return[b,c,d,255]}),get:function(a){return c.rgbColorScheme_.colors[a]}};for(var d=this.config_.colorScheme.map(Array),e=[],g=0;g=1e4&&(h=0,c.clear_()),c.currentFrame_=(0,f.getAnimationFrame)(l),c.evolve_(d,e,1===h),c.draw_(d,a))};k()}},{key:"velocityScale",value:function(){var a=this,b=i/this.config_.colorScheme.length;return this.config_.colorScheme.map(function(c,d){d+=1;var e=d*b;return d===a.config_.colorScheme.length&&(e=a.maxWindSpeed_),[c,Math.round(g.math.convertMagnitudeToKMPH(e))]})}},{key:"pointFromXY",value:function(a,b){if(!this.field_)throw new Error("Must supply data first.");return g.math.formatVector(this.field_(a,b))}},{key:"pointFromLatLng",value:function(a,b){if(!this.grid_)throw new Error("Must supply data first.");return g.math.formatVector(this.grid_(b,a))}},{key:"clear_",value:function(){return this.currentFrame_&&cancelAnimationFrame(this.currentFrame_),this}},{key:"prepare_",value:function(){return this}},{key:"draw_",value:function(){return this}}]),a}()},{"./../utilities/functions":6,"./../utilities/math":7,"./../utilities/palettes":8}],6:[function(a,b,c){"use strict";function d(a){var b=arguments.length<=1||void 0===arguments[1]?100:arguments[1],c=arguments.length<=2||void 0===arguments[2]?!1:arguments[2],d=void 0;return function(){var e=this,f=arguments,g=function(){d=null,c||a.apply(e,f)},h=c&&!d;clearTimeout(d),d=setTimeout(g,b),h&&a.apply(e,f)}}function e(a){var b=String(a.getMonth()+1),c=String(a.getDate()),d=a.getHours();return d=String(6*Math.round(d/6)||0),1===b.length&&(b="0"+b),1===c.length&&(c="0"+c),1===d.length&&(d="0"+d),""+a.getFullYear()+b+c+d}Object.defineProperty(c,"__esModule",{value:!0}),c.debounce=d,c.formatTime=e;c.getAnimationFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){window.setTimeout(a,50)}}(),c.isValue=function(a){return null!==a&&void 0!==a}},{}],7:[function(a,b,c){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d=2*Math.PI,e=Math.pow(10,-5.2),f=function(a,b){return a-b*Math.floor(a/b)},g=function(a){var b=Math.atan2(-a[0],-a[1])/d*360,c=5*Math.round((b+360)%360/5),e=h(a[2]);return[c,e]},h=function(a){return 3.6*a},i=function(a){return a/180*Math.PI},j=function(a){return a/(Math.PI/180)},k=function(a,b,c,d,e,f){var g=1-a,h=1-b,i=g*h,j=a*h,k=g*b,l=a*b,m=c[0]*i+d[0]*j+e[0]*k+f[0]*l,n=c[1]*i+d[1]*j+e[1]*k+f[1]*l;return[m,n,Math.sqrt(m*m+n*n)]},l=function(a,b,c,f,g){var h=0>a?e:-e,i=0>b?e:-e,j=n(b,a+h,g),k=n(b+i,a,g),l=Math.cos(b/360*d);return[(j[0]-c)/h/l,(j[1]-f)/h/l,(k[0]-c)/i,(k[1]-f)/i]},m=function(a){return Math.log(Math.tan(a/2+Math.PI/4))},n=function(a,b,c){var d=m(c.south),e=m(c.north),f=c.width/(c.east-c.west),g=c.height/(e-d),h=m(p.deg2rad(a)),i=(p.deg2rad(b)-c.west)*f;return[i,(e-h)*g]},o=function(a,b,c){var d=c.east-c.west,e=c.width/p.rad2deg(d)*360/(2*Math.PI),f=e/2*Math.log((1+Math.sin(c.south))/(1-Math.sin(c.south))),g=c.height+f,h=(g-b)/e,i=180/Math.PI*(2*Math.atan(Math.exp(h))-Math.PI/2),j=p.rad2deg(c.west)+a/c.width*p.rad2deg(d);return[j,i]},p=c.math={deg2rad:i,bilinearInterpolateVector:k,convertMagnitudeToKMPH:h,distortion:l,floorMod:f,formatVector:g,invert:o,rad2deg:j}},{}],8:[function(a,b,c){"use strict";Object.defineProperty(c,"__esModule",{value:!0});c.palettes={YlGn:["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"],YlGnBu:["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"],GnBu:["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"],BuGn:["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"],PuBuGn:["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"],PuBu:["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"],BuPu:["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"],RdPu:["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"],PuRed:["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"],OrRed:["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"],YlOrRd:["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"],YlOrBr:["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"],Purples:["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"],Blues:["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"],Greens:["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"],Oranges:["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"],Reds:["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"],Greys:["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]}},{}],9:[function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(c,"__esModule",{value:!0}),c.WindMap=void 0;var e=function(){function a(a,b){for(var c=0;c-1?this.renderer=new f.CanvasRenderer(b.canvas,b.extent,i.renderer):i.type.indexOf("webgl")>-1&&(this.renderer=new h.WebGLRenderer(b.canvas,b.extent,i)),this.debounceStart_=(0,g.debounce)(function(a){e.renderer.start_(a)})}return e(a,[{key:"stop",value:function(){return this.renderer.stop_(),this}},{key:"start",value:function(){var a=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],b=arguments.length<=1||void 0===arguments[1]?!1:arguments[1];return b?this.renderer.start_(a):this.debounceStart_(a),this}},{key:"update",value:function(){var a=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],b=arguments.length<=1||void 0===arguments[1]?!1:arguments[1];return this.stop().start(a,b)}}]),a}()},{"./../renderers/canvas/canvas":2,"./../renderers/gl/gl":3,"./../utilities/functions":6}]},{},[1]); \ No newline at end of file +!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g0&&(c.context.beginPath(),c.context.strokeStyle=c.config_.colorScheme[b],a.forEach(function(a){c.context.moveTo(a.x1,a.y1),c.context.lineTo(a.x2,a.y2)}),c.context.stroke())}),this}},{key:"clear_",value:function(){if(h(Object.getPrototypeOf(b.prototype),"clear_",this).call(this),this.mapBounds_)return this.context.clearRect(0,0,this.mapBounds_.width,this.mapBounds_.height),this.context.resetTransform?this.context.resetTransform():this.context.setTransform(1,0,0,1,0,0),this}}]),b}(i.Renderer)},{"./../renderer":5}],3:[function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function e(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!=typeof b&&"function"!=typeof b?a:b}function f(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}Object.defineProperty(c,"__esModule",{value:!0}),c.WebGLRenderer=void 0;var g=function(){function a(a,b){for(var c=0;c0||Math.abs(this.mapBounds_.west)-Math.abs(this.mapBounds_.east)===0||!this.data_)return void(a.boundsExceededCallback&&a.boundsExceededCallback(this.mapBounds_));this.config_.colorScheme=a.colorScheme||this.config_.colorScheme,this.config_.velocityScale=a.velocityScale||this.config_.velocityScale,this.config_.particleWidth=a.particleWidth||this.config_.particleWidth,this.config_.particleFadeOpacity=a.particleFadeOpacity||this.config_.particleFadeOpacity,this.config_.particleReduction=a.particleReduction||this.config_.particleReduction;var f=this.buildGrid_(this.data_),h=this.buildBounds_(e,c,d);return this.grid_=f,this.field_=this.interpolateField_(f,h,this.mapBounds_),this.stopped_=!1,this.animate_(h,this.data_[0].data.length)}},{key:"stop_",value:function(){return this.clear_(),this.stopped_=!0,this.field_&&this.field_.release(),this}},{key:"buildGrid_",value:function(a){for(var b=this,c=a[0],d=a[1],e=function(a){return[c.data[a],d.data[a]]},h=c.header.lo1,i=c.header.la1,j=c.header.dx,k=c.header.dy,l=c.header.nx,m=c.header.ny,n=[],o=Math.floor(l*j)>=360,p=0,q=0;qb.maxWindSpeed_&&(b.maxWindSpeed_=v[2]),v}}}return null};return t.bind(this)}},{key:"distort_",value:function(a,b,c,d,e,f){var h=f[0]*e,i=f[1]*e,j=g.math.distortion(a,b,c,d,this.mapBounds_);return f[0]=j[0]*h+j[2]*i,f[1]=j[1]*h+j[3]*i,f}},{key:"createField_",value:function(a,b){function c(b,c){var d=a[Math.round(b)];return d&&d[Math.round(c)]||j}return c.release=function(){a=[]},c.randomize=function(a){return Object.assign(a,{x1:Math.round(Math.floor(Math.random()*b.width)+b.x),y1:Math.round(Math.floor(Math.random()*b.height)+b.y)})},c}},{key:"buildBounds_",value:function(a,b,c){var d=a[0],e=a[1],f=Math.round(d[0]),g=Math.max(Math.floor(d[1],0),0),h=(Math.min(Math.ceil(e[0],b),b-1),Math.min(Math.ceil(e[1],c),c-1));return{x:f,y:g,xMax:b,yMax:h,width:b,height:c}}},{key:"interpolateField_",value:function(a,b){for(var c=this,d=b.height*this.config_.velocityScale,e=b.x,f=[],h=function(e){for(var h=[],i=b.y;i<=b.yMax;i+=2){var j=g.math.invert(e,i,c.mapBounds_);if(j){var k=j[0],l=j[1];if(isFinite(k)){var m=a(k,l);m&&(m=c.distort_(k,l,e,i,d,m),h[i+1]=h[i]=m)}}}f[e+1]=f[e]=h};ei&&(d.field_.randomize(b).age=0);var e=d.field_(b.x1,b.y1);if(null===e[2])b.age=i;else{var f=b.x1+e[0],g=b.y1+e[1];if(null!==d.field_(f,g)[2]){b.x2=f,b.y2=g;var h=d.config_.colorScheme.indexFor(e[2]),j=d.rgbColorScheme_.get(h);a[h].push(b),d.particleVectors_.push(b.x1),d.particleVectors_.push(b.y1),j.forEach(function(a){d.particleVectors_.push(a)}),d.particleVectors_.push(b.x2),d.particleVectors_.push(b.y2),j.forEach(function(a){d.particleVectors_.push(a)})}else b.x1=f,b.y1=g}b.age+=1})}},{key:"animate_",value:function(a,b){var c=this;this.config_.colorScheme.indexFor=function(a){var b=c.config_.colorScheme.length-1;return Math.floor(Math.min(a,c.config_.maxWindIntensity)/c.config_.maxWindIntensity*b)},this.rgbColorScheme_={colors:this.config_.colorScheme.map(function(a){a=a.replace("#","");var b=parseInt(a.substring(0,2),16),c=parseInt(a.substring(2,4),16),d=parseInt(a.substring(4,6),16);return[b,c,d,255]}),get:function(a){return c.rgbColorScheme_.colors[a]}};for(var d=this.config_.colorScheme.map(Array),e=[],g=0;g=1e4&&(h=0,c.clear_()),c.currentFrame_=(0,f.getAnimationFrame)(k),c.evolve_(d,e,1===h),c.draw_(d,a))};j()}},{key:"velocityScale",value:function(){var a=this,b=this.config_.maxWindIntensity/this.config_.colorScheme.length;return this.config_.colorScheme.map(function(c,d){d+=1;var e=d*b;return d===a.config_.colorScheme.length&&(e=a.maxWindSpeed_),[c,Math.round(g.math.convertMagnitudeToKMPH(e))]})}},{key:"pointFromXY",value:function(a,b){if(!this.field_)throw new Error("Must supply data first.");return g.math.formatVector(this.field_(a,b))}},{key:"pointFromLatLng",value:function(a,b){if(!this.grid_)throw new Error("Must supply data first.");return g.math.formatVector(this.grid_(b,a))}},{key:"clear_",value:function(){return this.currentFrame_&&cancelAnimationFrame(this.currentFrame_),this}},{key:"prepare_",value:function(){return this}},{key:"draw_",value:function(){return this}}]),a}()},{"./../utilities/functions":6,"./../utilities/math":7,"./../utilities/palettes":8}],6:[function(a,b,c){"use strict";function d(a){var b=arguments.length<=1||void 0===arguments[1]?100:arguments[1],c=!(arguments.length<=2||void 0===arguments[2])&&arguments[2],d=void 0;return function(){var e=this,f=arguments,g=function(){d=null,c||a.apply(e,f)},h=c&&!d;clearTimeout(d),d=setTimeout(g,b),h&&a.apply(e,f)}}function e(a){var b=String(a.getMonth()+1),c=String(a.getDate()),d=a.getHours();return d=String(6*Math.round(d/6)||0),1===b.length&&(b="0"+b),1===c.length&&(c="0"+c),1===d.length&&(d="0"+d),""+a.getFullYear()+b+c+d}Object.defineProperty(c,"__esModule",{value:!0}),c.debounce=d,c.formatTime=e;c.getAnimationFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){window.setTimeout(a,50)}}(),c.isValue=function(a){return null!==a&&void 0!==a}},{}],7:[function(a,b,c){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d=2*Math.PI,e=Math.pow(10,-5.2),f=function(a,b){return a-b*Math.floor(a/b)},g=function(a){var b=Math.atan2(-a[0],-a[1])/d*360,c=5*Math.round((b+360)%360/5),e=h(a[2]);return[c,e]},h=function(a){return 3.6*a},i=function(a){return a/180*Math.PI},j=function(a){return a/(Math.PI/180)},k=function(a,b,c,d,e,f){var g=1-a,h=1-b,i=g*h,j=a*h,k=g*b,l=a*b,m=c[0]*i+d[0]*j+e[0]*k+f[0]*l,n=c[1]*i+d[1]*j+e[1]*k+f[1]*l;return[m,n,Math.sqrt(m*m+n*n)]},l=function(a,b,c,f,g){var h=a<0?e:-e,i=b<0?e:-e,j=n(b,a+h,g),k=n(b+i,a,g),l=Math.cos(b/360*d);return[(j[0]-c)/h/l,(j[1]-f)/h/l,(k[0]-c)/i,(k[1]-f)/i]},m=function(a){return Math.log(Math.tan(a/2+Math.PI/4))},n=function(a,b,c){var d=m(c.south),e=m(c.north),f=c.width/(c.east-c.west),g=c.height/(e-d),h=m(p.deg2rad(a)),i=(p.deg2rad(b)-c.west)*f;return[i,(e-h)*g]},o=function(a,b,c){var d=c.east-c.west,e=c.width/p.rad2deg(d)*360/(2*Math.PI),f=e/2*Math.log((1+Math.sin(c.south))/(1-Math.sin(c.south))),g=c.height+f,h=(g-b)/e,i=180/Math.PI*(2*Math.atan(Math.exp(h))-Math.PI/2),j=p.rad2deg(c.west)+a/c.width*p.rad2deg(d);return[j,i]},p=c.math={deg2rad:i,bilinearInterpolateVector:k,convertMagnitudeToKMPH:h,distortion:l,floorMod:f,formatVector:g,invert:o,rad2deg:j}},{}],8:[function(a,b,c){"use strict";Object.defineProperty(c,"__esModule",{value:!0});c.palettes={YlGn:["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"],YlGnBu:["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"],GnBu:["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"],BuGn:["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"],PuBuGn:["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"],PuBu:["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"],BuPu:["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"],RdPu:["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"],PuRed:["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"],OrRed:["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"],YlOrRd:["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"],YlOrBr:["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"],Purples:["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"],Blues:["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"],Greens:["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"],Oranges:["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"],Reds:["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"],Greys:["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]}},{}],9:[function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(c,"__esModule",{value:!0}),c.WindMap=void 0;var e=function(){function a(a,b){for(var c=0;c-1?this.renderer=new f.CanvasRenderer(b.canvas,b.extent,i.renderer):i.type.indexOf("webgl")>-1&&(this.renderer=new h.WebGLRenderer(b.canvas,b.extent,i.renderer)),this.debounceStart_=(0,g.debounce)(function(a){e.renderer.start_(a)})}return e(a,[{key:"stop",value:function(){return this.renderer.stop_(),this}},{key:"start",value:function(){var a=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],b=!(arguments.length<=1||void 0===arguments[1])&&arguments[1];return b?this.renderer.start_(a):this.debounceStart_(a),this}},{key:"update",value:function(){var a=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],b=!(arguments.length<=1||void 0===arguments[1])&&arguments[1];return this.stop().start(a,b)}}]),a}()},{"./../renderers/canvas/canvas":2,"./../renderers/gl/gl":3,"./../utilities/functions":6}]},{},[1]); \ No newline at end of file diff --git a/examples/googleMaps/basic.html b/examples/googleMaps/basic.html index d5b6649..4f7efab 100644 --- a/examples/googleMaps/basic.html +++ b/examples/googleMaps/basic.html @@ -7,7 +7,7 @@ - +