Commit 59be7d61bc81ec9c80ff02921687c3cbd13aecb2
1 parent
d67e6f72
Exists in
master
and in
2 other branches
Adding third-party libraries to code instead of using CDN
Showing
4 changed files
with
339 additions
and
2 deletions
Show diff stats
.gitignore
ConfJuvApp/www/index.html
... | ... | @@ -19,7 +19,8 @@ |
19 | 19 | <script src="js/app.js"></script> |
20 | 20 | <script src="js/controllers.js"></script> |
21 | 21 | <script src="js/filters.js"></script> |
22 | - <script src="https://cdnjs.cloudflare.com/ajax/libs/trianglify/0.2.1/trianglify.min.js"></script> | |
22 | + <script src="js/trianglify.min.js"></script> | |
23 | + <script src="js/ionic.swipecards.js"></script> | |
23 | 24 | </head> |
24 | 25 | <body ng-app="confjuvapp" ng-controller="ProposalCtrl" ng-init="openModal()" ng-class="{ 'logged-in': loggedIn }"> |
25 | 26 | <ion-side-menus id="body"> | ... | ... |
... | ... | @@ -0,0 +1,333 @@ |
1 | +(function(ionic) { | |
2 | + | |
3 | + // Get transform origin poly | |
4 | + var d = document.createElement('div'); | |
5 | + var transformKeys = ['webkitTransformOrigin', 'transform-origin', '-webkit-transform-origin', 'webkit-transform-origin', | |
6 | + '-moz-transform-origin', 'moz-transform-origin', 'MozTransformOrigin', 'mozTransformOrigin']; | |
7 | + | |
8 | + var TRANSFORM_ORIGIN = 'webkitTransformOrigin'; | |
9 | + for(var i = 0; i < transformKeys.length; i++) { | |
10 | + if(d.style[transformKeys[i]] !== undefined) { | |
11 | + TRANSFORM_ORIGIN = transformKeys[i]; | |
12 | + break; | |
13 | + } | |
14 | + } | |
15 | + | |
16 | + var transitionKeys = ['webkitTransition', 'transition', '-webkit-transition', 'webkit-transition', | |
17 | + '-moz-transition', 'moz-transition', 'MozTransition', 'mozTransition']; | |
18 | + var TRANSITION = 'webkitTransition'; | |
19 | + for(var i = 0; i < transitionKeys.length; i++) { | |
20 | + if(d.style[transitionKeys[i]] !== undefined) { | |
21 | + TRANSITION = transitionKeys[i]; | |
22 | + break; | |
23 | + } | |
24 | + } | |
25 | + | |
26 | + var SwipeableCardController = ionic.views.View.inherit({ | |
27 | + initialize: function(opts) { | |
28 | + this.cards = []; | |
29 | + | |
30 | + var ratio = window.innerWidth / window.innerHeight; | |
31 | + | |
32 | + this.maxWidth = window.innerWidth - (opts.cardGutterWidth || 0); | |
33 | + this.maxHeight = opts.height || 300; | |
34 | + this.cardGutterWidth = opts.cardGutterWidth || 10; | |
35 | + this.cardPopInDuration = opts.cardPopInDuration || 400; | |
36 | + this.cardAnimation = opts.cardAnimation || 'pop-in'; | |
37 | + }, | |
38 | + /** | |
39 | + * Push a new card onto the stack. | |
40 | + */ | |
41 | + pushCard: function(card) { | |
42 | + var self = this; | |
43 | + | |
44 | + this.cards.push(card); | |
45 | + this.beforeCardShow(card); | |
46 | + | |
47 | + card.transitionIn(this.cardAnimation); | |
48 | + setTimeout(function() { | |
49 | + card.disableTransition(self.cardAnimation); | |
50 | + }, this.cardPopInDuration + 100); | |
51 | + }, | |
52 | + /** | |
53 | + * Set up a new card before it shows. | |
54 | + */ | |
55 | + beforeCardShow: function() { | |
56 | + var nextCard = this.cards[this.cards.length-1]; | |
57 | + if(!nextCard) return; | |
58 | + | |
59 | + // Calculate the top left of a default card, as a translated pos | |
60 | + var topLeft = window.innerHeight / 2 - this.maxHeight/2; | |
61 | + console.log(window.innerHeight, this.maxHeight); | |
62 | + | |
63 | + var cardOffset = Math.min(this.cards.length, 3) * 5; | |
64 | + | |
65 | + // Move each card 5 pixels down to give a nice stacking effect (max of 3 stacked) | |
66 | + nextCard.setPopInDuration(this.cardPopInDuration); | |
67 | + nextCard.setZIndex(this.cards.length); | |
68 | + }, | |
69 | + /** | |
70 | + * Pop a card from the stack | |
71 | + */ | |
72 | + popCard: function(animate) { | |
73 | + var card = this.cards.pop(); | |
74 | + if(animate) { | |
75 | + card.swipe(); | |
76 | + } | |
77 | + return card; | |
78 | + } | |
79 | + }); | |
80 | + | |
81 | + var SwipeableCardView = ionic.views.View.inherit({ | |
82 | + /** | |
83 | + * Initialize a card with the given options. | |
84 | + */ | |
85 | + initialize: function(opts) { | |
86 | + opts = ionic.extend({ | |
87 | + }, opts); | |
88 | + | |
89 | + ionic.extend(this, opts); | |
90 | + | |
91 | + this.el = opts.el; | |
92 | + | |
93 | + this.startX = this.startY = this.x = this.y = 0; | |
94 | + | |
95 | + this.bindEvents(); | |
96 | + }, | |
97 | + | |
98 | + /** | |
99 | + * Set the X position of the card. | |
100 | + */ | |
101 | + setX: function(x) { | |
102 | + this.el.style[ionic.CSS.TRANSFORM] = 'translate3d(' + x + 'px,' + this.y + 'px, 0)'; | |
103 | + this.x = x; | |
104 | + this.startX = x; | |
105 | + }, | |
106 | + | |
107 | + /** | |
108 | + * Set the Y position of the card. | |
109 | + */ | |
110 | + setY: function(y) { | |
111 | + this.el.style[ionic.CSS.TRANSFORM] = 'translate3d(' + this.x + 'px,' + y + 'px, 0)'; | |
112 | + this.y = y; | |
113 | + this.startY = y; | |
114 | + }, | |
115 | + | |
116 | + /** | |
117 | + * Set the Z-Index of the card | |
118 | + */ | |
119 | + setZIndex: function(index) { | |
120 | + this.el.style.zIndex = index; | |
121 | + }, | |
122 | + | |
123 | + /** | |
124 | + * Set the width of the card | |
125 | + */ | |
126 | + setWidth: function(width) { | |
127 | + this.el.style.width = width + 'px'; | |
128 | + }, | |
129 | + | |
130 | + /** | |
131 | + * Set the height of the card | |
132 | + */ | |
133 | + setHeight: function(height) { | |
134 | + this.el.style.height = height + 'px'; | |
135 | + }, | |
136 | + | |
137 | + /** | |
138 | + * Set the duration to run the pop-in animation | |
139 | + */ | |
140 | + setPopInDuration: function(duration) { | |
141 | + this.cardPopInDuration = duration; | |
142 | + }, | |
143 | + | |
144 | + /** | |
145 | + * Transition in the card with the given animation class | |
146 | + */ | |
147 | + transitionIn: function(animationClass) { | |
148 | + var self = this; | |
149 | + | |
150 | + this.el.classList.add(animationClass + '-start'); | |
151 | + this.el.classList.add(animationClass); | |
152 | + this.el.style.display = 'block'; | |
153 | + setTimeout(function() { | |
154 | + self.el.classList.remove(animationClass + '-start'); | |
155 | + }, 100); | |
156 | + }, | |
157 | + | |
158 | + /** | |
159 | + * Disable transitions on the card (for when dragging) | |
160 | + */ | |
161 | + disableTransition: function(animationClass) { | |
162 | + this.el.classList.remove(animationClass); | |
163 | + }, | |
164 | + | |
165 | + /** | |
166 | + * Swipe a card out programtically | |
167 | + */ | |
168 | + swipe: function() { | |
169 | + this.transitionOut(); | |
170 | + }, | |
171 | + | |
172 | + /** | |
173 | + * Fly the card out or animate back into resting position. | |
174 | + */ | |
175 | + transitionOut: function() { | |
176 | + var self = this; | |
177 | + | |
178 | + if(this.y < 0) { | |
179 | + this.el.style[TRANSITION] = '-webkit-transform 0.2s ease-in-out'; | |
180 | + this.el.style[ionic.CSS.TRANSFORM] = 'translate3d(' + this.x + ',' + (this.startY) + 'px, 0)'; | |
181 | + setTimeout(function() { | |
182 | + self.el.style[TRANSITION] = 'none'; | |
183 | + }, 200); | |
184 | + } else { | |
185 | + // Fly out | |
186 | + var rotateTo = (this.rotationAngle + (this.rotationDirection * 0.6)) || (Math.random() * 0.4); | |
187 | + var duration = this.rotationAngle ? 0.2 : 0.5; | |
188 | + this.el.style[TRANSITION] = '-webkit-transform ' + duration + 's ease-in-out'; | |
189 | + this.el.style[ionic.CSS.TRANSFORM] = 'translate3d(' + this.x + ',' + (window.innerHeight * 1.5) + 'px, 0) rotate(' + rotateTo + 'rad)'; | |
190 | + this.onSwipe && this.onSwipe(); | |
191 | + | |
192 | + // Trigger destroy after card has swiped out | |
193 | + setTimeout(function() { | |
194 | + self.onDestroy && self.onDestroy(); | |
195 | + }, duration * 1000); | |
196 | + } | |
197 | + }, | |
198 | + | |
199 | + /** | |
200 | + * Bind drag events on the card. | |
201 | + */ | |
202 | + bindEvents: function() { | |
203 | + var self = this; | |
204 | + ionic.onGesture('dragstart', function(e) { | |
205 | + var cx = window.innerWidth / 2; | |
206 | + if(e.gesture.touches[0].pageX < cx) { | |
207 | + self._transformOriginRight(); | |
208 | + } else { | |
209 | + self._transformOriginLeft(); | |
210 | + } | |
211 | + ionic.requestAnimationFrame(function() { self._doDragStart(e) }); | |
212 | + }, this.el); | |
213 | + | |
214 | + ionic.onGesture('drag', function(e) { | |
215 | + ionic.requestAnimationFrame(function() { self._doDrag(e) }); | |
216 | + }, this.el); | |
217 | + | |
218 | + ionic.onGesture('dragend', function(e) { | |
219 | + ionic.requestAnimationFrame(function() { self._doDragEnd(e) }); | |
220 | + }, this.el); | |
221 | + }, | |
222 | + | |
223 | + // Rotate anchored to the left of the screen | |
224 | + _transformOriginLeft: function() { | |
225 | + this.el.style[TRANSFORM_ORIGIN] = 'left center'; | |
226 | + this.rotationDirection = 1; | |
227 | + }, | |
228 | + | |
229 | + _transformOriginRight: function() { | |
230 | + this.el.style[TRANSFORM_ORIGIN] = 'right center'; | |
231 | + this.rotationDirection = -1; | |
232 | + }, | |
233 | + | |
234 | + _doDragStart: function(e) { | |
235 | + var width = this.el.offsetWidth; | |
236 | + var point = window.innerWidth / 2 + this.rotationDirection * (width / 2) | |
237 | + var distance = Math.abs(point - e.gesture.touches[0].pageX);// - window.innerWidth/2); | |
238 | + console.log(distance); | |
239 | + | |
240 | + this.touchDistance = distance * 10; | |
241 | + | |
242 | + console.log('Touch distance', this.touchDistance);//this.touchDistance, width); | |
243 | + }, | |
244 | + | |
245 | + _doDrag: function(e) { | |
246 | + var o = e.gesture.deltaY / 3; | |
247 | + | |
248 | + this.rotationAngle = Math.atan(o/this.touchDistance) * this.rotationDirection; | |
249 | + | |
250 | + if(e.gesture.deltaY < 0) { | |
251 | + this.rotationAngle = 0; | |
252 | + } | |
253 | + | |
254 | + this.y = this.startY + (e.gesture.deltaY * 0.4); | |
255 | + | |
256 | + this.el.style[ionic.CSS.TRANSFORM] = 'translate3d(' + this.x + 'px, ' + this.y + 'px, 0) rotate(' + (this.rotationAngle || 0) + 'rad)'; | |
257 | + }, | |
258 | + _doDragEnd: function(e) { | |
259 | + this.transitionOut(e); | |
260 | + } | |
261 | + }); | |
262 | + | |
263 | + | |
264 | + angular.module('ionic.contrib.ui.cards', ['ionic']) | |
265 | + | |
266 | + .directive('swipeCard', ['$timeout', function($timeout) { | |
267 | + return { | |
268 | + restrict: 'E', | |
269 | + template: '<div class="swipe-card" ng-transclude></div>', | |
270 | + require: '^swipeCards', | |
271 | + transclude: true, | |
272 | + scope: { | |
273 | + onCardSwipe: '&', | |
274 | + onDestroy: '&' | |
275 | + }, | |
276 | + link: function($scope, $element, $attr, swipeCards) { | |
277 | + var el = $element[0]; | |
278 | + | |
279 | + // Instantiate our card view | |
280 | + var swipeableCard = new SwipeableCardView({ | |
281 | + el: el, | |
282 | + onSwipe: function() { | |
283 | + $timeout(function() { | |
284 | + $scope.onCardSwipe(); | |
285 | + }); | |
286 | + }, | |
287 | + onDestroy: function() { | |
288 | + $timeout(function() { | |
289 | + $scope.onDestroy(); | |
290 | + }); | |
291 | + }, | |
292 | + }); | |
293 | + $scope.$parent.swipeCard = swipeableCard; | |
294 | + | |
295 | + swipeCards.swipeController.pushCard(swipeableCard); | |
296 | + | |
297 | + } | |
298 | + } | |
299 | + }]) | |
300 | + | |
301 | + .directive('swipeCards', ['$rootScope', function($rootScope) { | |
302 | + return { | |
303 | + restrict: 'E', | |
304 | + template: '<div class="swipe-cards" ng-transclude></div>', | |
305 | + transclude: true, | |
306 | + scope: true, | |
307 | + controller: function($scope, $element) { | |
308 | + var swipeController = new SwipeableCardController({ | |
309 | + }); | |
310 | + | |
311 | + $rootScope.$on('swipeCard.pop', function(isAnimated) { | |
312 | + swipeController.popCard(isAnimated); | |
313 | + }); | |
314 | + | |
315 | + this.swipeController = swipeController; | |
316 | + | |
317 | + //return swipeController; | |
318 | + } | |
319 | + } | |
320 | + }]) | |
321 | + | |
322 | + .factory('$ionicSwipeCardDelegate', ['$rootScope', function($rootScope) { | |
323 | + return { | |
324 | + popCard: function($scope, isAnimated) { | |
325 | + $rootScope.$emit('swipeCard.pop', isAnimated); | |
326 | + }, | |
327 | + getSwipeableCard: function($scope) { | |
328 | + return $scope.$parent.swipeCard; | |
329 | + } | |
330 | + } | |
331 | + }]); | |
332 | + | |
333 | +})(window.ionic); | ... | ... |
... | ... | @@ -0,0 +1,2 @@ |
1 | +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r;r="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,r.Trianglify=e()}}(function(){var e;return function r(e,f,n){function t(o,c){if(!f[o]){if(!e[o]){var u="function"==typeof require&&require;if(!c&&u)return u(o,!0);if(a)return a(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var i=f[o]={exports:{}};e[o][0].call(i.exports,function(r){var f=e[o][1][r];return t(f?f:r)},i,i.exports,r,e,f,n)}return f[o].exports}for(var a="function"==typeof require&&require,o=0;o<n.length;o++)t(n[o]);return t}({"./lib/trianglify.js":[function(e,r){function f(e){function r(e,r,f){return(e-r[0])*(f[1]-f[0])/(r[1]-r[0])+f[0]}function f(f,n){for(var t=[],a=-y;f+y>a;a+=e.cell_size)for(var o=-v;n+v>o;o+=e.cell_size){var c=a+e.cell_size/2+r(rand(),[0,1],[-w,w]),u=o+e.cell_size/2+r(rand(),[0,1],[-w,w]);t.push([c,u].map(Math.floor))}return t}function o(e){return{x:(e[0][0]+e[1][0]+e[2][0])/3,y:(e[0][1]+e[1][1]+e[2][1])/3}}function l(){if(e.palette instanceof Array)return e.palette[Math.floor(rand()*e.palette.length)];var r=Object.keys(e.palette);return e.palette[r[Math.floor(rand()*r.length)]]}function i(e,r){var f={};for(var n in e)f[n]=e[n];for(n in r){if(!e.hasOwnProperty(n))throw new Error(n+" is not a configuration option for Trianglify. Check your spelling?");f[n]=r[n]}return f}if(e=i(u,e),rand=t(e.seed),"random"===e.x_colors&&(e.x_colors=l()),"random"===e.y_colors&&(e.y_colors=l()),"match_x"===e.y_colors&&(e.y_colors=e.x_colors),!(e.width>0&&e.height>0))throw new Error("Width and height must be numbers greater than 0");if(e.cell_size<2)throw new Error("Cell size must be greater than 2.");var d;if(e.color_function)d=function(r,f){return a(e.color_function(r,f))};else{var s=a.scale(e.x_colors).mode(e.color_space),b=a.scale(e.y_colors).mode(e.color_space);d=function(r,f){return a.interpolate(s(r),b(f),.5,e.color_space)}}for(var h=e.width,g=e.height,p=Math.floor((h+4*e.cell_size)/e.cell_size),m=Math.floor((g+4*e.cell_size)/e.cell_size),y=(p*e.cell_size-h)/2,v=(m*e.cell_size-g)/2,w=e.cell_size*e.variance/2,_=function(e){return r(e,[-y,h+y],[0,1])},k=function(e){return r(e,[-v,g+v],[0,1])},x=f(h,g),M=n.triangulate(x),j=[],N=function(e){return x[e]},P=0;P<M.length;P+=3){var q=[M[P],M[P+1],M[P+2]].map(N),A=o(q),G=d(_(A.x),k(A.y)).hex();j.push([G,q])}return c(j,e)}var n=e("delaunay-fast"),t=e("seedrandom"),a=e("chroma-js"),o=e("./colorbrewer"),c=e("./pattern"),u={width:600,height:400,cell_size:75,variance:.75,seed:null,x_colors:"random",y_colors:"match_x",palette:o,color_space:"lab",color_function:null,stroke_width:1.51};f.colorbrewer=o,f.defaults=u,r.exports=f},{"./colorbrewer":"/Users/qrohlf/Projects/trianglify/lib/colorbrewer.js","./pattern":"/Users/qrohlf/Projects/trianglify/lib/pattern.js","chroma-js":"/Users/qrohlf/Projects/trianglify/node_modules/chroma-js/chroma.js","delaunay-fast":"/Users/qrohlf/Projects/trianglify/node_modules/delaunay-fast/delaunay.js",seedrandom:"/Users/qrohlf/Projects/trianglify/node_modules/seedrandom/seedrandom.js"}],"/Users/qrohlf/Projects/trianglify/lib/colorbrewer.js":[function(e,r){r.exports={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"],PuRd:["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"],OrRd:["#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:["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"],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"],PuOr:["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"],BrBG:["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"],PRGn:["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"],PiYG:["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"],RdBu:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"],RdGy:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"],RdYlBu:["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"],Spectral:["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"],RdYlGn:["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]}},{}],"/Users/qrohlf/Projects/trianglify/lib/pattern.js":[function(e,r){function f(e,r){function f(){var f=n.createElementNS("http://www.w3.org/2000/svg","svg");return f.setAttribute("width",r.width),f.setAttribute("height",r.height),e.forEach(function(e){var t=n.createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("d","M"+e[1].join("L")+"Z"),t.setAttribute("fill",e[0]),t.setAttribute("stroke",e[0]),t.setAttribute("stroke-width",r.stroke_width),f.appendChild(t)}),f}function t(f){return f||(f=n.createElement("canvas")),f.setAttribute("width",r.width),f.setAttribute("height",r.height),ctx=f.getContext("2d"),ctx.canvas.width=r.width,ctx.canvas.height=r.height,e.forEach(function(e){ctx.fillStyle=ctx.strokeStyle=e[0],ctx.lineWidth=r.stroke_width,ctx.beginPath(),ctx.moveTo.apply(ctx,e[1][0]),ctx.lineTo.apply(ctx,e[1][1]),ctx.lineTo.apply(ctx,e[1][2]),ctx.fill(),ctx.stroke()}),f}function a(){return t().toDataURL("image/png")}return{polys:e,opts:r,svg:f,canvas:t,png:a}}var n="undefined"!=typeof document?document:e("jsdom").jsdom("<html/>");r.exports=f},{jsdom:"/Users/qrohlf/Projects/trianglify/node_modules/browserify/node_modules/browser-resolve/empty.js"}],"/Users/qrohlf/Projects/trianglify/node_modules/browserify/node_modules/browser-resolve/empty.js":[function(){},{}],"/Users/qrohlf/Projects/trianglify/node_modules/chroma-js/chroma.js":[function(r,f,n){(function(){var r,t,a,o,c,u,l,i,d,s,b,h,g,p,m,y,v,w,_,k,x,M,j,N,P,q,A,G,B,I,E,R,S,O,U,z,Y,T,C;s=function(e,f,n,t){return new r(e,f,n,t)},"undefined"!=typeof f&&null!==f&&null!=f.exports&&(f.exports=s),"function"==typeof e&&e.amd?e([],function(){return s}):(O="undefined"!=typeof n&&null!==n?n:this,O.chroma=s),s.color=function(e,f,n,t){return new r(e,f,n,t)},s.hsl=function(e,f,n,t){return new r(e,f,n,t,"hsl")},s.hsv=function(e,f,n,t){return new r(e,f,n,t,"hsv")},s.rgb=function(e,f,n,t){return new r(e,f,n,t,"rgb")},s.hex=function(e){return new r(e)},s.css=function(e){return new r(e)},s.lab=function(e,f,n){return new r(e,f,n,"lab")},s.lch=function(e,f,n){return new r(e,f,n,"lch")},s.hsi=function(e,f,n){return new r(e,f,n,"hsi")},s.gl=function(e,f,n,t){return new r(255*e,255*f,255*n,t,"gl")},s.interpolate=function(e,f,n,t){return null==e||null==f?"#000":("string"===U(e)&&(e=new r(e)),"string"===U(f)&&(f=new r(f)),e.interpolate(n,f,t))},s.mix=s.interpolate,s.contrast=function(e,f){var n,t;return"string"===U(e)&&(e=new r(e)),"string"===U(f)&&(f=new r(f)),n=e.luminance(),t=f.luminance(),n>t?(n+.05)/(t+.05):(t+.05)/(n+.05)},s.luminance=function(e){return s(e).luminance()},s._Color=r,r=function(){function e(){var e,r,f,n,t,a,o,c,u,l,i,d,s,h,g,p;for(t=this,f=[],l=0,i=arguments.length;i>l;l++)r=arguments[l],null!=r&&f.push(r);if(0===f.length)d=[255,0,255,1,"rgb"],o=d[0],c=d[1],u=d[2],e=d[3],n=d[4];else if("array"===U(f[0])){if(3===f[0].length)s=f[0],o=s[0],c=s[1],u=s[2],e=1;else{if(4!==f[0].length)throw"unknown input argument";h=f[0],o=h[0],c=h[1],u=h[2],e=h[3]}n=null!=(g=f[1])?g:"rgb"}else"string"===U(f[0])?(o=f[0],n="hex"):"object"===U(f[0])?(p=f[0]._rgb,o=p[0],c=p[1],u=p[2],e=p[3],n="rgb"):f.length>=3&&(o=f[0],c=f[1],u=f[2]);3===f.length?(n="rgb",e=1):4===f.length?"string"===U(f[3])?(n=f[3],e=1):"number"===U(f[3])&&(n="rgb",e=f[3]):5===f.length&&(e=f[3],n=f[4]),null==e&&(e=1),"rgb"===n?t._rgb=[o,c,u,e]:"gl"===n?t._rgb=[255*o,255*c,255*u,e]:"hsl"===n?(t._rgb=v(o,c,u),t._rgb[3]=e):"hsv"===n?(t._rgb=w(o,c,u),t._rgb[3]=e):"hex"===n?t._rgb=m(o):"lab"===n?(t._rgb=k(o,c,u),t._rgb[3]=e):"lch"===n?(t._rgb=j(o,c,u),t._rgb[3]=e):"hsi"===n&&(t._rgb=y(o,c,u),t._rgb[3]=e),a=b(t._rgb)}return e.prototype.rgb=function(){return this._rgb.slice(0,3)},e.prototype.rgba=function(){return this._rgb},e.prototype.hex=function(){return A(this._rgb)},e.prototype.toString=function(){return this.name()},e.prototype.hsl=function(){return B(this._rgb)},e.prototype.hsv=function(){return I(this._rgb)},e.prototype.lab=function(){return E(this._rgb)},e.prototype.lch=function(){return R(this._rgb)},e.prototype.hsi=function(){return G(this._rgb)},e.prototype.gl=function(){return[this._rgb[0]/255,this._rgb[1]/255,this._rgb[2]/255,this._rgb[3]]},e.prototype.luminance=function(r,f){var n,t,a,o;return null==f&&(f="rgb"),arguments.length?(0===r&&(this._rgb=[0,0,0,this._rgb[3]]),1===r&&(this._rgb=[255,255,255,this._rgb[3]]),n=P(this._rgb),t=1e-7,a=20,o=function(e,n){var c,u;return u=e.interpolate(.5,n,f),c=u.luminance(),Math.abs(r-c)<t||!a--?u:c>r?o(e,u):o(u,n)},this._rgb=(n>r?o(new e("black"),this):o(this,new e("white"))).rgba(),this):P(this._rgb)},e.prototype.name=function(){var e,r;e=this.hex();for(r in s.colors)if(e===s.colors[r])return r;return e},e.prototype.alpha=function(e){return arguments.length?(this._rgb[3]=e,this):this._rgb[3]},e.prototype.css=function(e){var r,f,n,t;return null==e&&(e="rgb"),f=this,n=f._rgb,3===e.length&&n[3]<1&&(e+="a"),"rgb"===e?e+"("+n.slice(0,3).map(Math.round).join(",")+")":"rgba"===e?e+"("+n.slice(0,3).map(Math.round).join(",")+","+n[3]+")":"hsl"===e||"hsla"===e?(r=f.hsl(),t=function(e){return Math.round(100*e)/100},r[0]=t(r[0]),r[1]=t(100*r[1])+"%",r[2]=t(100*r[2])+"%",4===e.length&&(r[3]=n[3]),e+"("+r.join(",")+")"):void 0},e.prototype.interpolate=function(r,f,n){var t,a,o,c,u,l,i,d,s,b,h,g,p,m;if(d=this,null==n&&(n="rgb"),"string"===U(f)&&(f=new e(f)),"hsl"===n||"hsv"===n||"lch"===n||"hsi"===n)"hsl"===n?(p=d.hsl(),m=f.hsl()):"hsv"===n?(p=d.hsv(),m=f.hsv()):"hsi"===n?(p=d.hsi(),m=f.hsi()):"lch"===n&&(p=d.lch(),m=f.lch()),"h"===n.substr(0,1)?(o=p[0],h=p[1],l=p[2],c=m[0],g=m[1],i=m[2]):(l=p[0],h=p[1],o=p[2],i=m[0],g=m[1],c=m[2]),isNaN(o)||isNaN(c)?isNaN(o)?isNaN(c)?a=Number.NaN:(a=c,1!==l&&0!==l||"hsv"===n||(b=g)):(a=o,1!==i&&0!==i||"hsv"===n||(b=h)):(t=c>o&&c-o>180?c-(o+360):o>c&&o-c>180?c+360-o:c-o,a=o+r*t),null==b&&(b=h+r*(g-h)),u=l+r*(i-l),s="h"===n.substr(0,1)?new e(a,b,u,n):new e(u,b,a,n);else if("rgb"===n)p=d._rgb,m=f._rgb,s=new e(p[0]+r*(m[0]-p[0]),p[1]+r*(m[1]-p[1]),p[2]+r*(m[2]-p[2]),n);else{if("lab"!==n)throw"color mode "+n+" is not supported";p=d.lab(),m=f.lab(),s=new e(p[0]+r*(m[0]-p[0]),p[1]+r*(m[1]-p[1]),p[2]+r*(m[2]-p[2]),n)}return s.alpha(d.alpha()+r*(f.alpha()-d.alpha())),s},e.prototype.premultiply=function(){var e,r;return r=this.rgb(),e=this.alpha(),s(r[0]*e,r[1]*e,r[2]*e,e)},e.prototype.darken=function(e){var r,f;return null==e&&(e=20),f=this,r=f.lch(),r[0]-=e,s.lch(r).alpha(f.alpha())},e.prototype.darker=function(e){return this.darken(e)},e.prototype.brighten=function(e){return null==e&&(e=20),this.darken(-e)},e.prototype.brighter=function(e){return this.brighten(e)},e.prototype.saturate=function(e){var r,f;return null==e&&(e=20),f=this,r=f.lch(),r[1]+=e,s.lch(r).alpha(f.alpha())},e.prototype.desaturate=function(e){return null==e&&(e=20),this.saturate(-e)},e}(),b=function(e){var r;for(r in e)3>r?(e[r]<0&&(e[r]=0),e[r]>255&&(e[r]=255)):3===r&&(e[r]<0&&(e[r]=0),e[r]>1&&(e[r]=1));return e},p=function(e){var r,f,n,t,a,o,c,u;if(e=e.toLowerCase(),null!=s.colors&&s.colors[e])return m(s.colors[e]);if(n=e.match(/rgb\(\s*(\-?\d+),\s*(\-?\d+)\s*,\s*(\-?\d+)\s*\)/)){for(t=n.slice(1,4),f=a=0;2>=a;f=++a)t[f]=+t[f];t[3]=1}else if(n=e.match(/rgba\(\s*(\-?\d+),\s*(\-?\d+)\s*,\s*(\-?\d+)\s*,\s*([01]|[01]?\.\d+)\)/))for(t=n.slice(1,5),f=o=0;3>=o;f=++o)t[f]=+t[f];else if(n=e.match(/rgb\(\s*(\-?\d+(?:\.\d+)?)%,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*\)/)){for(t=n.slice(1,4),f=c=0;2>=c;f=++c)t[f]=Math.round(2.55*t[f]);t[3]=1}else if(n=e.match(/rgba\(\s*(\-?\d+(?:\.\d+)?)%,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)/)){for(t=n.slice(1,5),f=u=0;2>=u;f=++u)t[f]=Math.round(2.55*t[f]);t[3]=+t[3]}else(n=e.match(/hsl\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*\)/))?(r=n.slice(1,4),r[1]*=.01,r[2]*=.01,t=v(r),t[3]=1):(n=e.match(/hsla\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)/))&&(r=n.slice(1,4),r[1]*=.01,r[2]*=.01,t=v(r),t[3]=+n[4]);return t},m=function(e){var r,f,n,t,a,o;if(e.match(/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/))return(4===e.length||7===e.length)&&(e=e.substr(1)),3===e.length&&(e=e.split(""),e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),o=parseInt(e,16),t=o>>16,n=o>>8&255,f=255&o,[t,n,f,1];if(e.match(/^#?([A-Fa-f0-9]{8})$/))return 9===e.length&&(e=e.substr(1)),o=parseInt(e,16),t=o>>24&255,n=o>>16&255,f=o>>8&255,r=255&o,[t,n,f,r];if(a=p(e))return a;throw"unknown color: "+e},y=function(e,r,f){var n,t,c,u;return u=z(arguments),e=u[0],r=u[1],f=u[2],e/=360,1/3>e?(n=(1-r)/3,c=(1+r*g(o*e)/g(a-o*e))/3,t=1-(n+c)):2/3>e?(e-=1/3,c=(1-r)/3,t=(1+r*g(o*e)/g(a-o*e))/3,n=1-(c+t)):(e-=2/3,t=(1-r)/3,n=(1+r*g(o*e)/g(a-o*e))/3,c=1-(t+n)),c=N(f*c*3),t=N(f*t*3),n=N(f*n*3),[255*c,255*t,255*n]},v=function(){var e,r,f,n,t,a,o,c,u,l,i,d,s,b;if(s=z(arguments),n=s[0],c=s[1],a=s[2],0===c)o=f=e=255*a;else{for(i=[0,0,0],r=[0,0,0],l=.5>a?a*(1+c):a+c-a*c,u=2*a-l,n/=360,i[0]=n+1/3,i[1]=n,i[2]=n-1/3,t=d=0;2>=d;t=++d)i[t]<0&&(i[t]+=1),i[t]>1&&(i[t]-=1),r[t]=6*i[t]<1?u+6*(l-u)*i[t]:2*i[t]<1?l:3*i[t]<2?u+(l-u)*(2/3-i[t])*6:u;b=[Math.round(255*r[0]),Math.round(255*r[1]),Math.round(255*r[2])],o=b[0],f=b[1],e=b[2]}return[o,f,e]},w=function(){var e,r,f,n,t,a,o,c,u,l,i,d,s,b,h,g,p,m;if(d=z(arguments),n=d[0],u=d[1],i=d[2],i*=255,0===u)c=f=e=i;else switch(360===n&&(n=0),n>360&&(n-=360),0>n&&(n+=360),n/=60,t=Math.floor(n),r=n-t,a=i*(1-u),o=i*(1-u*r),l=i*(1-u*(1-r)),t){case 0:s=[i,l,a],c=s[0],f=s[1],e=s[2];break;case 1:b=[o,i,a],c=b[0],f=b[1],e=b[2];break;case 2:h=[a,i,l],c=h[0],f=h[1],e=h[2];break;case 3:g=[a,o,i],c=g[0],f=g[1],e=g[2];break;case 4:p=[l,a,i],c=p[0],f=p[1],e=p[2];break;case 5:m=[i,a,o],c=m[0],f=m[1],e=m[2]}return c=Math.round(c),f=Math.round(f),e=Math.round(e),[c,f,e]},t=18,c=.95047,u=1,l=1.08883,_=function(){var e,r,f,n,t,a;return a=z(arguments),t=a[0],e=a[1],r=a[2],f=Math.sqrt(e*e+r*r),n=Math.atan2(r,e)/Math.PI*180,[t,f,n]},k=function(e,r,f){var n,t,a,o,i,d,s;return void 0!==e&&3===e.length&&(d=e,e=d[0],r=d[1],f=d[2]),void 0!==e&&3===e.length&&(s=e,e=s[0],r=s[1],f=s[2]),o=(e+16)/116,a=o+r/500,i=o-f/200,a=x(a)*c,o=x(o)*u,i=x(i)*l,t=T(3.2404542*a-1.5371385*o-.4985314*i),n=T(-.969266*a+1.8760108*o+.041556*i),f=T(.0556434*a-.2040259*o+1.0572252*i),[N(t,0,255),N(n,0,255),N(f,0,255),1]},x=function(e){return e>.206893034?e*e*e:(e-4/29)/7.787037},T=function(e){return Math.round(255*(.00304>=e?12.92*e:1.055*Math.pow(e,1/2.4)-.055))},M=function(){var e,r,f,n;return n=z(arguments),f=n[0],e=n[1],r=n[2],r=r*Math.PI/180,[f,Math.cos(r)*e,Math.sin(r)*e]},j=function(e,r,f){var n,t,a,o,c,u,l;return u=M(e,r,f),n=u[0],t=u[1],a=u[2],l=k(n,t,a),c=l[0],o=l[1],a=l[2],[N(c,0,255),N(o,0,255),N(a,0,255)]},P=function(e,r,f){var n;return n=z(arguments),e=n[0],r=n[1],f=n[2],e=q(e),r=q(r),f=q(f),.2126*e+.7152*r+.0722*f},q=function(e){return e/=255,.03928>=e?e/12.92:Math.pow((e+.055)/1.055,2.4)},A=function(){var e,r,f,n,t,a;return a=z(arguments),f=a[0],r=a[1],e=a[2],t=f<<16|r<<8|e,n="000000"+t.toString(16),"#"+n.substr(n.length-6)},G=function(){var e,r,f,n,t,a,o,c,u;return u=z(arguments),o=u[0],f=u[1],r=u[2],e=2*Math.PI,o/=255,f/=255,r/=255,a=Math.min(o,f,r),t=(o+f+r)/3,c=1-a/t,0===c?n=0:(n=(o-f+(o-r))/2,n/=Math.sqrt((o-f)*(o-f)+(o-r)*(f-r)),n=Math.acos(n),r>f&&(n=e-n),n/=e),[360*n,c,t]},B=function(e,r,f){var n,t,a,o,c,u;return void 0!==e&&e.length>=3&&(u=e,e=u[0],r=u[1],f=u[2]),e/=255,r/=255,f/=255,o=Math.min(e,r,f),a=Math.max(e,r,f),t=(a+o)/2,a===o?(c=0,n=Number.NaN):c=.5>t?(a-o)/(a+o):(a-o)/(2-a-o),e===a?n=(r-f)/(a-o):r===a?n=2+(f-e)/(a-o):f===a&&(n=4+(e-r)/(a-o)),n*=60,0>n&&(n+=360),[n,c,t]},I=function(){var e,r,f,n,t,a,o,c,u,l;return l=z(arguments),o=l[0],f=l[1],e=l[2],a=Math.min(o,f,e),t=Math.max(o,f,e),r=t-a,u=t/255,0===t?(n=Number.NaN,c=0):(c=r/t,o===t&&(n=(f-e)/r),f===t&&(n=2+(e-o)/r),e===t&&(n=4+(o-f)/r),n*=60,0>n&&(n+=360)),[n,c,u]},E=function(){var e,r,f,n,t,a,o;return o=z(arguments),f=o[0],r=o[1],e=o[2],f=S(f),r=S(r),e=S(e),n=Y((.4124564*f+.3575761*r+.1804375*e)/c),t=Y((.2126729*f+.7151522*r+.072175*e)/u),a=Y((.0193339*f+.119192*r+.9503041*e)/l),[116*t-16,500*(n-t),200*(t-a)]},S=function(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)},Y=function(e){return e>.008856?Math.pow(e,1/3):7.787037*e+4/29},R=function(){var e,r,f,n,t,a,o;return a=z(arguments),t=a[0],f=a[1],r=a[2],o=E(t,f,r),n=o[0],e=o[1],r=o[2],_(n,e,r)},s.scale=function(e,r){var f,n,t,a,o,c,u,l,i,d,b,h,g,p,m,y,v,w,_,k,x;return y="rgb",v=s("#ccc"),x=0,g=!1,h=[0,1],d=[],_=!1,k=[],m=0,p=1,b=!1,w=0,i={},c=function(e,r){var f,n,t,a,c,u,l;if(null==e&&(e=["#ddd","#222"]),null!=e&&"string"===U(e)&&null!=(null!=(c=s.brewer)?c[e]:void 0)&&(e=s.brewer[e]),"array"===U(e)){for(e=e.slice(0),f=t=0,u=e.length-1;u>=0?u>=t:t>=u;f=u>=0?++t:--t)n=e[f],"string"===U(n)&&(e[f]=s(n));if(null!=r)k=r;else for(k=[],f=a=0,l=e.length-1;l>=0?l>=a:a>=l;f=l>=0?++a:--a)k.push(f/(e.length-1))}return o(),d=e},u=function(e){return null==e&&(e=[]),h=e,m=e[0],p=e[e.length-1],o(),w=2===e.length?0:e.length-1},t=function(e){var r,f;if(null!=h){for(f=h.length-1,r=0;f>r&&e>=h[r];)r++;return r-1}return 0},l=function(e){return e},f=function(e){var r,f,n,a,o;return o=e,h.length>2&&(a=h.length-1,r=t(e),n=h[0]+(h[1]-h[0])*(0+.5*x),f=h[a-1]+(h[a]-h[a-1])*(1-.5*x),o=m+(h[r]+.5*(h[r+1]-h[r])-n)/(f-n)*(p-m)),o},a=function(e,r){var f,n,a,o,c,u,b,g,_;if(null==r&&(r=!1),isNaN(e))return v;if(r?b=e:h.length>2?(f=t(e),b=f/(w-1)):(b=a=m!==p?(e-m)/(p-m):0,b=a=(e-m)/(p-m),b=Math.min(1,Math.max(0,b))),r||(b=l(b)),c=Math.floor(1e4*b),i[c])n=i[c];else{if("array"===U(d))for(o=g=0,_=k.length-1;_>=0?_>=g:g>=_;o=_>=0?++g:--g){if(u=k[o],u>=b){n=d[o];break}if(b>=u&&o===k.length-1){n=d[o];break}if(b>u&&b<k[o+1]){b=(b-u)/(k[o+1]-u),n=s.interpolate(d[o],d[o+1],b,y);break}}else"function"===U(d)&&(n=d(b));i[c]=n}return n},o=function(){return i={}},c(e,r),n=function(e){var r;return r=a(e),_&&r[_]?r[_]():r},n.domain=function(e,r,f,t){var a;return null==f&&(f="e"),arguments.length?(null!=r&&(a=s.analyze(e,t),e=0===r?[a.min,a.max]:s.limits(a,f,r)),u(e),n):h},n.mode=function(e){return arguments.length?(y=e,o(),n):y},n.range=function(e,r){return c(e,r),n},n.out=function(e){return _=e,n},n.spread=function(e){return arguments.length?(x=e,n):x},n.correctLightness=function(e){return arguments.length?(b=e,o(),l=b?function(e){var r,f,n,t,o,c,u,l,i;for(r=a(0,!0).lab()[0],f=a(1,!0).lab()[0],u=r>f,n=a(e,!0).lab()[0],o=r+(f-r)*e,t=n-o,l=0,i=1,c=20;Math.abs(t)>.01&&c-->0;)!function(){return u&&(t*=-1),0>t?(l=e,e+=.5*(i-e)):(i=e,e+=.5*(l-e)),n=a(e,!0).lab()[0],t=n-o}();return e}:function(e){return e},n):b},n.colors=function(r){var f,t,a,o,c,u;if(null==r&&(r="hex"),e=[],t=[],h.length>2)for(f=a=1,u=h.length;u>=1?u>a:a>u;f=u>=1?++a:--a)t.push(.5*(h[f-1]+h[f]));else t=h;for(o=0,c=t.length;c>o;o++)f=t[o],e.push(n(f)[r]());return e},n},null==(C=s.scales)&&(s.scales={}),s.scales.cool=function(){return s.scale([s.hsl(180,1,.9),s.hsl(250,.7,.4)])},s.scales.hot=function(){return s.scale(["#000","#f00","#ff0","#fff"],[0,.25,.75,1]).mode("rgb")},s.analyze=function(e,r,f){var n,t,a,o,c,u,l;if(a={min:Number.MAX_VALUE,max:-1*Number.MAX_VALUE,sum:0,values:[],count:0},null==f&&(f=function(){return!0}),n=function(e){null==e||isNaN(e)||(a.values.push(e),a.sum+=e,e<a.min&&(a.min=e),e>a.max&&(a.max=e),a.count+=1)},c=function(e,t){return f(e,t)?null!=r&&"function"===U(r)?n(r(e)):null!=r&&"string"===U(r)||"number"===U(r)?n(e[r]):n(e):void 0},"array"===U(e))for(u=0,l=e.length;l>u;u++)o=e[u],c(o);else for(t in e)o=e[t],c(o,t);return a.domain=[a.min,a.max],a.limits=function(e,r){return s.limits(a,e,r)},a},s.limits=function(e,r,f){var n,t,a,o,c,u,l,i,d,b,h,g,p,m,y,v,w,_,k,x,M,j,N,P,q,A,G,B,I,E,R,S,O,z,Y,T,C,L,F,V,D,X,W,$,Z,H,J,K,Q,er,rr,fr,nr,tr,ar,or;if(null==r&&(r="equal"),null==f&&(f=7),"array"===U(e)&&(e=s.analyze(e)),p=e.min,h=e.max,N=e.sum,A=e.values.sort(function(e,r){return e-r}),b=[],"c"===r.substr(0,1)&&(b.push(p),b.push(h)),"e"===r.substr(0,1)){for(b.push(p),l=G=1,C=f-1;C>=1?C>=G:G>=C;l=C>=1?++G:--G)b.push(p+l/f*(h-p));b.push(h)}else if("l"===r.substr(0,1)){if(0>=p)throw"Logarithmic scales are only possible for values > 0";for(m=Math.LOG10E*Math.log(p),g=Math.LOG10E*Math.log(h),b.push(p),l=B=1,$=f-1;$>=1?$>=B:B>=$;l=$>=1?++B:--B)b.push(Math.pow(10,m+l/f*(g-m)));b.push(h)}else if("q"===r.substr(0,1)){for(b.push(p),l=I=1,Z=f-1;Z>=1?Z>=I:I>=Z;l=Z>=1?++I:--I)k=A.length*l/f,x=Math.floor(k),x===k?b.push(A[x]):(M=k-x,b.push(A[x]*M+A[x+1]*(1-M)));b.push(h)}else if("k"===r.substr(0,1)){for(v=A.length,n=new Array(v),c=new Array(f),j=!0,w=0,a=null,a=[],a.push(p),l=E=1,H=f-1;H>=1?H>=E:E>=H;l=H>=1?++E:--E)a.push(p+l/f*(h-p));for(a.push(h);j;){for(i=R=0,J=f-1;J>=0?J>=R:R>=J;i=J>=0?++R:--R)c[i]=0;for(l=S=0,K=v-1;K>=0?K>=S:S>=K;l=K>=0?++S:--S){for(q=A[l],y=Number.MAX_VALUE,i=O=0,Q=f-1;Q>=0?Q>=O:O>=Q;i=Q>=0?++O:--O)u=Math.abs(a[i]-q),y>u&&(y=u,t=i);c[t]++,n[l]=t}for(_=new Array(f),i=z=0,er=f-1;er>=0?er>=z:z>=er;i=er>=0?++z:--z)_[i]=null;for(l=Y=0,rr=v-1;rr>=0?rr>=Y:Y>=rr;l=rr>=0?++Y:--Y)o=n[l],null===_[o]?_[o]=A[l]:_[o]+=A[l];for(i=T=0,L=f-1;L>=0?L>=T:T>=L;i=L>=0?++T:--T)_[i]*=1/c[i];for(j=!1,i=fr=0,F=f-1;F>=0?F>=fr:fr>=F;i=F>=0?++fr:--fr)if(_[i]!==a[l]){j=!0;break}a=_,w++,w>200&&(j=!1)}for(d={},i=nr=0,V=f-1;V>=0?V>=nr:nr>=V;i=V>=0?++nr:--nr)d[i]=[];for(l=tr=0,D=v-1;D>=0?D>=tr:tr>=D;l=D>=0?++tr:--tr)o=n[l],d[o].push(A[l]);for(P=[],i=ar=0,X=f-1;X>=0?X>=ar:ar>=X;i=X>=0?++ar:--ar)P.push(d[i][0]),P.push(d[i][d[i].length-1]);for(P=P.sort(function(e,r){return e-r}),b.push(P[0]),l=or=1,W=P.length-1;W>=or;l=or+=2)isNaN(P[l])||b.push(P[l])}return b},s.brewer=d={OrRd:["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"],PuBu:["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"],BuPu:["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"],Oranges:["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"],BuGn:["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"],YlOrBr:["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"],YlGn:["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"],Reds:["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"],RdPu:["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"],Greens:["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"],YlGnBu:["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"],Purples:["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"],GnBu:["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"],Greys:["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"],YlOrRd:["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"],PuRd:["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"],Blues:["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"],PuBuGn:["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"],Spectral:["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"],RdYlGn:["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"],RdBu:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"],PiYG:["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"],PRGn:["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"],RdYlBu:["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"],BrBG:["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"],RdGy:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"],PuOr:["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"],Set2:["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"],Accent:["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17","#666666"],Set1:["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf","#999999"],Set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],Dark2:["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d","#666666"],Paired:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99","#b15928"],Pastel2:["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc","#cccccc"],Pastel1:["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec","#f2f2f2"]},s.colors=h={indigo:"#4b0082",gold:"#ffd700",hotpink:"#ff69b4",firebrick:"#b22222",indianred:"#cd5c5c",yellow:"#ffff00",mistyrose:"#ffe4e1",darkolivegreen:"#556b2f",olive:"#808000",darkseagreen:"#8fbc8f",pink:"#ffc0cb",tomato:"#ff6347",lightcoral:"#f08080",orangered:"#ff4500",navajowhite:"#ffdead",lime:"#00ff00",palegreen:"#98fb98",darkslategrey:"#2f4f4f",greenyellow:"#adff2f",burlywood:"#deb887",seashell:"#fff5ee",mediumspringgreen:"#00fa9a",fuchsia:"#ff00ff",papayawhip:"#ffefd5",blanchedalmond:"#ffebcd",chartreuse:"#7fff00",dimgray:"#696969",black:"#000000",peachpuff:"#ffdab9",springgreen:"#00ff7f",aquamarine:"#7fffd4",white:"#ffffff",orange:"#ffa500",lightsalmon:"#ffa07a",darkslategray:"#2f4f4f",brown:"#a52a2a",ivory:"#fffff0",dodgerblue:"#1e90ff",peru:"#cd853f",lawngreen:"#7cfc00",chocolate:"#d2691e",crimson:"#dc143c",forestgreen:"#228b22",darkgrey:"#a9a9a9",lightseagreen:"#20b2aa",cyan:"#00ffff",mintcream:"#f5fffa",silver:"#c0c0c0",antiquewhite:"#faebd7",mediumorchid:"#ba55d3",skyblue:"#87ceeb",gray:"#808080",darkturquoise:"#00ced1",goldenrod:"#daa520",darkgreen:"#006400",floralwhite:"#fffaf0",darkviolet:"#9400d3",darkgray:"#a9a9a9",moccasin:"#ffe4b5",saddlebrown:"#8b4513",grey:"#808080",darkslateblue:"#483d8b",lightskyblue:"#87cefa",lightpink:"#ffb6c1",mediumvioletred:"#c71585",slategrey:"#708090",red:"#ff0000",deeppink:"#ff1493",limegreen:"#32cd32",darkmagenta:"#8b008b",palegoldenrod:"#eee8aa",plum:"#dda0dd",turquoise:"#40e0d0",lightgrey:"#d3d3d3",lightgoldenrodyellow:"#fafad2",darkgoldenrod:"#b8860b",lavender:"#e6e6fa",maroon:"#800000",yellowgreen:"#9acd32",sandybrown:"#f4a460",thistle:"#d8bfd8",violet:"#ee82ee",navy:"#000080",magenta:"#ff00ff",dimgrey:"#696969",tan:"#d2b48c",rosybrown:"#bc8f8f",olivedrab:"#6b8e23",blue:"#0000ff",lightblue:"#add8e6",ghostwhite:"#f8f8ff",honeydew:"#f0fff0",cornflowerblue:"#6495ed",slateblue:"#6a5acd",linen:"#faf0e6",darkblue:"#00008b",powderblue:"#b0e0e6",seagreen:"#2e8b57",darkkhaki:"#bdb76b",snow:"#fffafa",sienna:"#a0522d",mediumblue:"#0000cd",royalblue:"#4169e1",lightcyan:"#e0ffff",green:"#008000",mediumpurple:"#9370db",midnightblue:"#191970",cornsilk:"#fff8dc",paleturquoise:"#afeeee",bisque:"#ffe4c4",slategray:"#708090",darkcyan:"#008b8b",khaki:"#f0e68c",wheat:"#f5deb3",teal:"#008080",darkorchid:"#9932cc",deepskyblue:"#00bfff",salmon:"#fa8072",darkred:"#8b0000",steelblue:"#4682b4",palevioletred:"#db7093",lightslategray:"#778899",aliceblue:"#f0f8ff",lightslategrey:"#778899",lightgreen:"#90ee90",orchid:"#da70d6",gainsboro:"#dcdcdc",mediumseagreen:"#3cb371",lightgray:"#d3d3d3",mediumturquoise:"#48d1cc",lemonchiffon:"#fffacd",cadetblue:"#5f9ea0",lightyellow:"#ffffe0",lavenderblush:"#fff0f5",coral:"#ff7f50",purple:"#800080",aqua:"#00ffff",whitesmoke:"#f5f5f5",mediumslateblue:"#7b68ee",darkorange:"#ff8c00",mediumaquamarine:"#66cdaa",darksalmon:"#e9967a",beige:"#f5f5dc",blueviolet:"#8a2be2",azure:"#f0ffff",lightsteelblue:"#b0c4de",oldlace:"#fdf5e6"},U=function(){var e,r,f,n,t;for(e={},t="Boolean Number String Function Array Date RegExp Undefined Null".split(" "),f=0,n=t.length;n>f;f++)r=t[f],e["[object "+r+"]"]=r.toLowerCase();return function(r){var f;return f=Object.prototype.toString.call(r),e[f]||"object"}}(),N=function(e,r,f){return null==r&&(r=0),null==f&&(f=1),r>e&&(e=r),e>f&&(e=f),e},z=function(e){return e.length>=3?e:e[0]},o=2*Math.PI,a=Math.PI/3,g=Math.cos,i=function(e){var r,f,n,t,a,o,c,u,l,d,b;return e=function(){var r,f,n;for(n=[],r=0,f=e.length;f>r;r++)t=e[r],n.push(s(t));return n}(),2===e.length?(l=function(){var r,f,n;for(n=[],r=0,f=e.length;f>r;r++)t=e[r],n.push(t.lab());return n}(),a=l[0],o=l[1],r=function(e){var r,f;return f=function(){var f,n;for(n=[],r=f=0;2>=f;r=++f)n.push(a[r]+e*(o[r]-a[r]));return n}(),s.lab.apply(s,f)}):3===e.length?(d=function(){var r,f,n;for(n=[],r=0,f=e.length;f>r;r++)t=e[r],n.push(t.lab());return n}(),a=d[0],o=d[1],c=d[2],r=function(e){var r,f;return f=function(){var f,n;for(n=[],r=f=0;2>=f;r=++f)n.push((1-e)*(1-e)*a[r]+2*(1-e)*e*o[r]+e*e*c[r]);return n}(),s.lab.apply(s,f)}):4===e.length?(b=function(){var r,f,n;for(n=[],r=0,f=e.length;f>r;r++)t=e[r],n.push(t.lab());return n}(),a=b[0],o=b[1],c=b[2],u=b[3],r=function(e){var r,f;return f=function(){var f,n;for(n=[],r=f=0;2>=f;r=++f)n.push((1-e)*(1-e)*(1-e)*a[r]+3*(1-e)*(1-e)*e*o[r]+3*(1-e)*e*e*c[r]+e*e*e*u[r]);return n}(),s.lab.apply(s,f)}):5===e.length&&(f=i(e.slice(0,3)),n=i(e.slice(2,5)),r=function(e){return.5>e?f(2*e):n(2*(e-.5))}),r},s.interpolate.bezier=i}).call(this)},{}],"/Users/qrohlf/Projects/trianglify/node_modules/delaunay-fast/delaunay.js":[function(e,r){var f;!function(){"use strict";function e(e){var r,f,n,t,a,o,c=Number.POSITIVE_INFINITY,u=Number.POSITIVE_INFINITY,l=Number.NEGATIVE_INFINITY,i=Number.NEGATIVE_INFINITY;for(r=e.length;r--;)e[r][0]<c&&(c=e[r][0]),e[r][0]>l&&(l=e[r][0]),e[r][1]<u&&(u=e[r][1]),e[r][1]>i&&(i=e[r][1]); | |
2 | +return f=l-c,n=i-u,t=Math.max(f,n),a=c+.5*f,o=u+.5*n,[[a-20*t,o-t],[a,o+20*t],[a+20*t,o-t]]}function n(e,r,f,n){var t,o,c,u,l,i,d,s,b,h,g=e[r][0],p=e[r][1],m=e[f][0],y=e[f][1],v=e[n][0],w=e[n][1],_=Math.abs(p-y),k=Math.abs(y-w);if(a>_&&a>k)throw new Error("Eek! Coincident points!");return a>_?(u=-((v-m)/(w-y)),i=(m+v)/2,s=(y+w)/2,t=(m+g)/2,o=u*(t-i)+s):a>k?(c=-((m-g)/(y-p)),l=(g+m)/2,d=(p+y)/2,t=(v+m)/2,o=c*(t-l)+d):(c=-((m-g)/(y-p)),u=-((v-m)/(w-y)),l=(g+m)/2,i=(m+v)/2,d=(p+y)/2,s=(y+w)/2,t=(c*l-u*i+s-d)/(c-u),o=_>k?c*(t-l)+d:u*(t-i)+s),b=m-t,h=y-o,{i:r,j:f,k:n,x:t,y:o,r:b*b+h*h}}function t(e){var r,f,n,t,a,o;for(f=e.length;f;)for(t=e[--f],n=e[--f],r=f;r;)if(o=e[--r],a=e[--r],n===a&&t===o||n===o&&t===a){e.splice(f,2),e.splice(r,2);break}}var a=1/1048576;f={triangulate:function(r,f){var o,c,u,l,i,d,s,b,h,g,p,m,y=r.length;if(3>y)return[];if(r=r.slice(0),f)for(o=y;o--;)r[o]=r[o][f];for(u=new Array(y),o=y;o--;)u[o]=o;for(u.sort(function(e,f){return r[f][0]-r[e][0]}),l=e(r),r.push(l[0],l[1],l[2]),i=[n(r,y+0,y+1,y+2)],d=[],s=[],o=u.length;o--;s.length=0){for(m=u[o],c=i.length;c--;)b=r[m][0]-i[c].x,b>0&&b*b>i[c].r?(d.push(i[c]),i.splice(c,1)):(h=r[m][1]-i[c].y,b*b+h*h-i[c].r>a||(s.push(i[c].i,i[c].j,i[c].j,i[c].k,i[c].k,i[c].i),i.splice(c,1)));for(t(s),c=s.length;c;)p=s[--c],g=s[--c],i.push(n(r,g,p,m))}for(o=i.length;o--;)d.push(i[o]);for(i.length=0,o=d.length;o--;)d[o].i<y&&d[o].j<y&&d[o].k<y&&i.push(d[o].i,d[o].j,d[o].k);return i},contains:function(e,r){if(r[0]<e[0][0]&&r[0]<e[1][0]&&r[0]<e[2][0]||r[0]>e[0][0]&&r[0]>e[1][0]&&r[0]>e[2][0]||r[1]<e[0][1]&&r[1]<e[1][1]&&r[1]<e[2][1]||r[1]>e[0][1]&&r[1]>e[1][1]&&r[1]>e[2][1])return null;var f=e[1][0]-e[0][0],n=e[2][0]-e[0][0],t=e[1][1]-e[0][1],a=e[2][1]-e[0][1],o=f*a-n*t;if(0===o)return null;var c=(a*(r[0]-e[0][0])-n*(r[1]-e[0][1]))/o,u=(f*(r[1]-e[0][1])-t*(r[0]-e[0][0]))/o;return 0>c||0>u||c+u>1?null:[c,u]}},"undefined"!=typeof r&&(r.exports=f)}()},{}],"/Users/qrohlf/Projects/trianglify/node_modules/seedrandom/seedrandom.js":[function(r,f){!function(e,f,n,t,a,o,c,u,l){function i(e){var r,f=e.length,n=this,a=0,o=n.i=n.j=0,c=n.S=[];for(f||(e=[f++]);t>a;)c[a]=a++;for(a=0;t>a;a++)c[a]=c[o=w&o+e[a%f]+(r=c[a])],c[o]=r;(n.g=function(e){for(var r,f=0,a=n.i,o=n.j,c=n.S;e--;)r=c[a=w&a+1],f=f*t+c[w&(c[a]=c[o=w&o+r])+(c[o]=r)];return n.i=a,n.j=o,f})(t)}function d(e,r){return r.i=e.i,r.j=e.j,r.S=e.S.slice(),r}function s(e,r){var f,n=[],t=typeof e;if(r&&"object"==t)for(f in e)try{n.push(s(e[f],r-1))}catch(a){}return n.length?n:"string"==t?e:e+"\x00"}function b(e,r){for(var f,n=e+"",t=0;t<n.length;)r[w&t]=w&(f^=19*r[w&t])+n.charCodeAt(t++);return g(r)}function h(r){try{return p?g(p.randomBytes(t)):(e.crypto.getRandomValues(r=new Uint8Array(t)),g(r))}catch(n){return[+new Date,e,(r=e.navigator)&&r.plugins,e.screen,g(f)]}}function g(e){return String.fromCharCode.apply(0,e)}var p,m=n.pow(t,a),y=n.pow(2,o),v=2*y,w=t-1,_=n["seed"+l]=function(e,r,o){var c=[];r=1==r?{entropy:!0}:r||{};var u=b(s(r.entropy?[e,g(f)]:null==e?h():e,3),c),p=new i(c);return b(g(p.S),f),(r.pass||o||function(e,r,f,t){return t&&(t.S&&d(t,p),e.state=function(){return d(p,{})}),f?(n[l]=e,r):e})(function(){for(var e=p.g(a),r=m,f=0;y>e;)e=(e+f)*t,r*=t,f=p.g(1);for(;e>=v;)e/=2,r/=2,f>>>=1;return(e+f)/r},u,"global"in r?r.global:this==n,r.state)};if(b(n[l](),f),c&&c.exports){c.exports=_;try{p=r("crypto")}catch(k){}}else u&&u.amd&&u(function(){return _})}(this,[],Math,256,6,52,"object"==typeof f&&f,"function"==typeof e&&e,"random")},{crypto:!1}]},{},["./lib/trianglify.js"])("./lib/trianglify.js")}); | |
0 | 3 | \ No newline at end of file | ... | ... |