trianglify.js 82 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376
  1. /*
  2. * Trianglify.js
  3. * https://github.com/qrohlf/trianglify
  4. *
  5. * Licensed under the GPLv3
  6. */
  7. (function(e) {
  8. if ("object" == typeof exports && "undefined" != typeof module) module.exports = e();
  9. else if ("function" == typeof define && define.amd) define([], e);
  10. else {
  11. var f;
  12. f = "undefined" == typeof window ? "undefined" == typeof global ? "undefined" == typeof self ? this : self : global : window, f.Trianglify = e()
  13. }
  14. })(function() {
  15. var e, f = Math.sqrt,
  16. d = Math.abs,
  17. a = Math.min,
  18. n = Math.max,
  19. l = Math.floor;
  20. return function d(c, e, t) {
  21. function f(s, n) {
  22. if (!e[s]) {
  23. if (!c[s]) {
  24. var i = "function" == typeof require && require;
  25. if (!n && i) return i(s, !0);
  26. if (r) return r(s, !0);
  27. var a = new Error("Cannot find module '" + s + "'");
  28. throw a.code = "MODULE_NOT_FOUND", a
  29. }
  30. var o = e[s] = {
  31. exports: {}
  32. };
  33. c[s][0].call(o.exports, function(d) {
  34. var e = c[s][1][d];
  35. return f(e ? e : d)
  36. }, o, o.exports, d, c, e, t)
  37. }
  38. return e[s].exports
  39. }
  40. for (var r = "function" == typeof require && require, a = 0; a < t.length; a++) f(t[a]);
  41. return f
  42. }({
  43. "./lib/trianglify.js": [function(e, f) {
  44. function d(e) {
  45. function f(e, f) {
  46. return a(n(e, f[0]), f[1])
  47. }
  48. function d(e, f, d) {
  49. return (e - f[0]) * (d[1] - d[0]) / (f[1] - f[0]) + d[0]
  50. }
  51. function h(e) {
  52. return {
  53. x: (e[0][0] + e[1][0] + e[2][0]) / 3,
  54. y: (e[0][1] + e[1][1] + e[2][1]) / 3
  55. }
  56. }
  57. function g() {
  58. if (e.palette instanceof Array) return e.palette[l(u() * e.palette.length)];
  59. var f = Object.keys(e.palette);
  60. return e.palette[f[l(u() * f.length)]]
  61. }
  62. var u;
  63. if (e = function(e, f) {
  64. var d = {};
  65. for (var a in e) d[a] = e[a];
  66. for (a in f)
  67. if (e.hasOwnProperty(a)) d[a] = f[a];
  68. else throw new Error(a + " is not a configuration option for Trianglify. Check your spelling?");
  69. return d
  70. }(b, e), u = t(e.seed), "random" === e.x_colors && (e.x_colors = g()), "random" === e.y_colors && (e.y_colors = g()), "match_x" === e.y_colors && (e.y_colors = e.x_colors), !(0 < e.width && 0 < e.height)) throw new Error("Width and height must be numbers greater than 0");
  71. if (2 > e.cell_size) throw new Error("Cell size must be greater than 2.");
  72. if (!e.x_colors && !e.y_colors) throw new Error("X and Y colors can not be both undefined.");
  73. var p;
  74. if (e.color_function) p = function(f, d) {
  75. return s(e.color_function(f, d))
  76. };
  77. else if (e.x_colors && e.y_colors) {
  78. var m = s.scale(e.x_colors).mode(e.color_space),
  79. _ = s.scale(e.y_colors).mode(e.color_space);
  80. p = function(f, d) {
  81. return s.interpolate(m(f), _(d), 0.5, e.color_space)
  82. }
  83. } else {
  84. var w = s.scale(e.x_colors || e.y_colors).mode(e.color_space);
  85. p = e.x_colors ? function(e) {
  86. return w(e)
  87. } : function(e, f) {
  88. return w(f)
  89. }
  90. }
  91. for (var y = e.width, x = e.height, j = l((y + 4 * e.cell_size) / e.cell_size), v = l((x + 4 * e.cell_size) / e.cell_size), k = (j * e.cell_size - y) / 2, q = (v * e.cell_size - x) / 2, C = e.cell_size * e.variance / 2, z = function(e) {
  92. return f(d(e, [0, y], [0, 1]), [0, 1])
  93. }, U = function(e) {
  94. return f(d(e, [0, x], [0, 1]), [0, 1])
  95. }, B = e.points || o(y, x, k, q, e.cell_size, C, u), G = new r(B).triangles, S = [], P = function(e) {
  96. return B[e]
  97. }, R = 0; R < G.length; R += 3) {
  98. var i = [G[R], G[R + 1], G[R + 2]].map(P),
  99. A = h(i),
  100. L = p(z(A.x), U(A.y)).css();
  101. S.push([L, i])
  102. }
  103. return c(S, e)
  104. }
  105. var r = e("delaunator"),
  106. t = e("seedrandom"),
  107. s = e("chroma-js"),
  108. i = e("./colorbrewer"),
  109. o = e("./points"),
  110. c = e("./pattern"),
  111. b = {
  112. width: 600,
  113. height: 400,
  114. cell_size: 75,
  115. variance: 0.75,
  116. seed: null,
  117. x_colors: "random",
  118. y_colors: "match_x",
  119. palette: i,
  120. color_space: "lab",
  121. color_function: null,
  122. stroke_width: 1.51,
  123. points: void 0
  124. };
  125. d.colorbrewer = i, d.defaults = b, f.exports = d
  126. }, {
  127. "./colorbrewer": "/Users/qrohlf/Code/trianglify/lib/colorbrewer.js",
  128. "./pattern": "/Users/qrohlf/Code/trianglify/lib/pattern.js",
  129. "./points": "/Users/qrohlf/Code/trianglify/lib/points.js",
  130. "chroma-js": "/Users/qrohlf/Code/trianglify/node_modules/chroma-js/chroma.js",
  131. delaunator: "/Users/qrohlf/Code/trianglify/node_modules/delaunator/index.js",
  132. seedrandom: "/Users/qrohlf/Code/trianglify/node_modules/seedrandom/index.js"
  133. }],
  134. "/Users/qrohlf/Code/trianglify/lib/colorbrewer.js": [function(e, f) {
  135. f.exports = {
  136. YlGn: ["#ffffe5", "#f7fcb9", "#d9f0a3", "#addd8e", "#78c679", "#41ab5d", "#238443", "#006837", "#004529"],
  137. YlGnBu: ["#ffffd9", "#edf8b1", "#c7e9b4", "#7fcdbb", "#41b6c4", "#1d91c0", "#225ea8", "#253494", "#081d58"],
  138. GnBu: ["#f7fcf0", "#e0f3db", "#ccebc5", "#a8ddb5", "#7bccc4", "#4eb3d3", "#2b8cbe", "#0868ac", "#084081"],
  139. BuGn: ["#f7fcfd", "#e5f5f9", "#ccece6", "#99d8c9", "#66c2a4", "#41ae76", "#238b45", "#006d2c", "#00441b"],
  140. PuBuGn: ["#fff7fb", "#ece2f0", "#d0d1e6", "#a6bddb", "#67a9cf", "#3690c0", "#02818a", "#016c59", "#014636"],
  141. PuBu: ["#fff7fb", "#ece7f2", "#d0d1e6", "#a6bddb", "#74a9cf", "#3690c0", "#0570b0", "#045a8d", "#023858"],
  142. BuPu: ["#f7fcfd", "#e0ecf4", "#bfd3e6", "#9ebcda", "#8c96c6", "#8c6bb1", "#88419d", "#810f7c", "#4d004b"],
  143. RdPu: ["#fff7f3", "#fde0dd", "#fcc5c0", "#fa9fb5", "#f768a1", "#dd3497", "#ae017e", "#7a0177", "#49006a"],
  144. PuRd: ["#f7f4f9", "#e7e1ef", "#d4b9da", "#c994c7", "#df65b0", "#e7298a", "#ce1256", "#980043", "#67001f"],
  145. OrRd: ["#fff7ec", "#fee8c8", "#fdd49e", "#fdbb84", "#fc8d59", "#ef6548", "#d7301f", "#b30000", "#7f0000"],
  146. YlOrRd: ["#ffffcc", "#ffeda0", "#fed976", "#feb24c", "#fd8d3c", "#fc4e2a", "#e31a1c", "#bd0026", "#800026"],
  147. YlOrBr: ["#ffffe5", "#fff7bc", "#fee391", "#fec44f", "#fe9929", "#ec7014", "#cc4c02", "#993404", "#662506"],
  148. Purples: ["#fcfbfd", "#efedf5", "#dadaeb", "#bcbddc", "#9e9ac8", "#807dba", "#6a51a3", "#54278f", "#3f007d"],
  149. Blues: ["#f7fbff", "#deebf7", "#c6dbef", "#9ecae1", "#6baed6", "#4292c6", "#2171b5", "#08519c", "#08306b"],
  150. Greens: ["#f7fcf5", "#e5f5e0", "#c7e9c0", "#a1d99b", "#74c476", "#41ab5d", "#238b45", "#006d2c", "#00441b"],
  151. Oranges: ["#fff5eb", "#fee6ce", "#fdd0a2", "#fdae6b", "#fd8d3c", "#f16913", "#d94801", "#a63603", "#7f2704"],
  152. Reds: ["#fff5f0", "#fee0d2", "#fcbba1", "#fc9272", "#fb6a4a", "#ef3b2c", "#cb181d", "#a50f15", "#67000d"],
  153. Greys: ["#ffffff", "#f0f0f0", "#d9d9d9", "#bdbdbd", "#969696", "#737373", "#525252", "#252525", "#000000"],
  154. PuOr: ["#7f3b08", "#b35806", "#e08214", "#fdb863", "#fee0b6", "#f7f7f7", "#d8daeb", "#b2abd2", "#8073ac", "#542788", "#2d004b"],
  155. BrBG: ["#543005", "#8c510a", "#bf812d", "#dfc27d", "#f6e8c3", "#f5f5f5", "#c7eae5", "#80cdc1", "#35978f", "#01665e", "#003c30"],
  156. PRGn: ["#40004b", "#762a83", "#9970ab", "#c2a5cf", "#e7d4e8", "#f7f7f7", "#d9f0d3", "#a6dba0", "#5aae61", "#1b7837", "#00441b"],
  157. PiYG: ["#8e0152", "#c51b7d", "#de77ae", "#f1b6da", "#fde0ef", "#f7f7f7", "#e6f5d0", "#b8e186", "#7fbc41", "#4d9221", "#276419"],
  158. RdBu: ["#67001f", "#b2182b", "#d6604d", "#f4a582", "#fddbc7", "#f7f7f7", "#d1e5f0", "#92c5de", "#4393c3", "#2166ac", "#053061"],
  159. RdGy: ["#67001f", "#b2182b", "#d6604d", "#f4a582", "#fddbc7", "#ffffff", "#e0e0e0", "#bababa", "#878787", "#4d4d4d", "#1a1a1a"],
  160. RdYlBu: ["#a50026", "#d73027", "#f46d43", "#fdae61", "#fee090", "#ffffbf", "#e0f3f8", "#abd9e9", "#74add1", "#4575b4", "#313695"],
  161. Spectral: ["#9e0142", "#d53e4f", "#f46d43", "#fdae61", "#fee08b", "#ffffbf", "#e6f598", "#abdda4", "#66c2a5", "#3288bd", "#5e4fa2"],
  162. RdYlGn: ["#a50026", "#d73027", "#f46d43", "#fdae61", "#fee08b", "#ffffbf", "#d9ef8b", "#a6d96a", "#66bd63", "#1a9850", "#006837"]
  163. }
  164. }, {}],
  165. "/Users/qrohlf/Code/trianglify/lib/pattern.js": [function(e, f) {
  166. (function(d) {
  167. var a = "undefined" == typeof document ? e("jsdom").jsdom("<html/>") : document;
  168. f.exports = function(f, r) {
  169. function t(t) {
  170. var n;
  171. if ("object" == typeof d && "object" == typeof d.versions && "undefined" != typeof d.versions.node) try {
  172. e("canvas")
  173. } catch (f) {
  174. throw Error("The optional node-canvas dependency is needed for Trianglify to render using canvas in node.")
  175. }
  176. return t || (t = a.createElement("canvas")), t.setAttribute("width", r.width), t.setAttribute("height", r.height), n = t.getContext("2d"), n.canvas.width = r.width, n.canvas.height = r.height, f.forEach(function(e) {
  177. n.fillStyle = n.strokeStyle = e[0], n.lineWidth = r.stroke_width, n.beginPath(), n.moveTo.apply(n, e[1][0]), n.lineTo.apply(n, e[1][1]), n.lineTo.apply(n, e[1][2]), n.fill(), n.stroke()
  178. }), t
  179. }
  180. return {
  181. polys: f,
  182. opts: r,
  183. svg: function(e) {
  184. var d = a.createElementNS("http://www.w3.org/2000/svg", "svg");
  185. return d.setAttribute("width", r.width), d.setAttribute("height", r.height), e && e.includeNamespace && d.setAttribute("xmlns", "http://www.w3.org/2000/svg"), f.forEach(function(e) {
  186. var f = a.createElementNS("http://www.w3.org/2000/svg", "path");
  187. f.setAttribute("d", "M" + e[1].join("L") + "Z"), f.setAttribute("fill", e[0]), f.setAttribute("stroke", e[0]), f.setAttribute("stroke-width", r.stroke_width), d.appendChild(f)
  188. }), d
  189. },
  190. canvas: t,
  191. png: function() {
  192. return t().toDataURL("image/png")
  193. }
  194. }
  195. }
  196. }).call(this, e("_process"))
  197. }, {
  198. _process: "/Users/qrohlf/Code/trianglify/node_modules/process/browser.js",
  199. canvas: "/Users/qrohlf/Code/trianglify/node_modules/browser-resolve/empty.js",
  200. jsdom: "/Users/qrohlf/Code/trianglify/node_modules/browser-resolve/empty.js"
  201. }],
  202. "/Users/qrohlf/Code/trianglify/lib/points.js": [function(e, f) {
  203. f.exports = function(e, f, d, a, r, t, n) {
  204. for (var s = 0.5 * r, o = 2 * t, c = -t, b = [], h = -d; h < e + d; h += r)
  205. for (var i = -a; i < f + a; i += r) {
  206. var g = h + s + (n() * o + c),
  207. u = i + s + (n() * o + c);
  208. b.push([l(g), l(u)])
  209. }
  210. return b
  211. }
  212. }, {}],
  213. "/Users/qrohlf/Code/trianglify/node_modules/browser-resolve/empty.js": [function() {}, {}],
  214. "/Users/qrohlf/Code/trianglify/node_modules/chroma-js/chroma.js": [function(r, t, s) {
  215. (function() {
  216. var o, r, c, u, i, h, p, b, g, y, _, m, x, w, j, v, k, q, C, U, B, z, G, S, P, R, A, L, Y, E, T, O, N, X, D, K, M, V, W, F = Number.MAX_VALUE,
  217. I = Math.cos,
  218. Z = Math.pow,
  219. J = Math.PI,
  220. H = Number.NaN,
  221. $ = Math.round;
  222. y = function(e, f, d, a) {
  223. return new o(e, f, d, a)
  224. }, "undefined" != typeof t && null !== t && null != t.exports && (t.exports = y), "function" == typeof e && e.amd ? e([], function() {
  225. return y
  226. }) : (X = "undefined" != typeof s && null !== s ? s : this, X.chroma = y), y.color = function(e, f, d, a) {
  227. return new o(e, f, d, a)
  228. }, y.hsl = function(e, f, d, r) {
  229. return new o(e, f, d, r, "hsl")
  230. }, y.hsv = function(e, f, d, r) {
  231. return new o(e, f, d, r, "hsv")
  232. }, y.rgb = function(e, f, d, r) {
  233. return new o(e, f, d, r, "rgb")
  234. }, y.hex = function(e) {
  235. return new o(e)
  236. }, y.css = function(e) {
  237. return new o(e)
  238. }, y.lab = function(e, f, d) {
  239. return new o(e, f, d, "lab")
  240. }, y.lch = function(e, f, d) {
  241. return new o(e, f, d, "lch")
  242. }, y.hsi = function(e, f, d) {
  243. return new o(e, f, d, "hsi")
  244. }, y.gl = function(e, f, d, r) {
  245. return new o(255 * e, 255 * f, 255 * d, r, "gl")
  246. }, y.interpolate = function(e, d, a, f) {
  247. return null == e || null == d ? "#000" : ("string" === D(e) && (e = new o(e)), "string" === D(d) && (d = new o(d)), e.interpolate(a, d, f))
  248. }, y.mix = y.interpolate, y.contrast = function(e, f) {
  249. var d, a;
  250. return "string" === D(e) && (e = new o(e)), "string" === D(f) && (f = new o(f)), d = e.luminance(), a = f.luminance(), d > a ? (d + 0.05) / (a + 0.05) : (a + 0.05) / (d + 0.05)
  251. }, y.luminance = function(e) {
  252. return y(e).luminance()
  253. }, y._Color = o, o = function() {
  254. function e() {
  255. var e, f, d, a, r, t, n, l, s, i, o, c, b, h, g, u;
  256. for (r = this, d = [], (i = 0, o = arguments.length); i < o; i++) f = arguments[i], null != f && d.push(f);
  257. if (0 === d.length) c = [255, 0, 255, 1, "rgb"], n = c[0], l = c[1], s = c[2], e = c[3], a = c[4];
  258. else if ("array" === D(d[0])) {
  259. if (3 === d[0].length) b = d[0], n = b[0], l = b[1], s = b[2], e = 1;
  260. else if (4 === d[0].length) h = d[0], n = h[0], l = h[1], s = h[2], e = h[3];
  261. else throw "unknown input argument";
  262. a = null == (g = d[1]) ? "rgb" : g
  263. } else "string" === D(d[0]) ? (n = d[0], a = "hex") : "object" === D(d[0]) ? (u = d[0]._rgb, n = u[0], l = u[1], s = u[2], e = u[3], a = "rgb") : 3 <= d.length && (n = d[0], l = d[1], s = d[2]);
  264. 3 === d.length ? (a = "rgb", e = 1) : 4 === d.length ? "string" === D(d[3]) ? (a = d[3], e = 1) : "number" === D(d[3]) && (a = "rgb", e = d[3]) : 5 === d.length && (e = d[3], a = d[4]), null == e && (e = 1), "rgb" === a ? r._rgb = [n, l, s, e] : "gl" === a ? r._rgb = [255 * n, 255 * l, 255 * s, e] : "hsl" === a ? (r._rgb = k(n, l, s), r._rgb[3] = e) : "hsv" === a ? (r._rgb = q(n, l, s), r._rgb[3] = e) : "hex" === a ? r._rgb = j(n) : "lab" === a ? (r._rgb = U(n, l, s), r._rgb[3] = e) : "lch" === a ? (r._rgb = G(n, l, s), r._rgb[3] = e) : "hsi" === a && (r._rgb = v(n, l, s), r._rgb[3] = e), t = _(r._rgb)
  265. }
  266. return e.prototype.rgb = function() {
  267. return this._rgb.slice(0, 3)
  268. }, e.prototype.rgba = function() {
  269. return this._rgb
  270. }, e.prototype.hex = function() {
  271. return A(this._rgb)
  272. }, e.prototype.toString = function() {
  273. return this.name()
  274. }, e.prototype.hsl = function() {
  275. return Y(this._rgb)
  276. }, e.prototype.hsv = function() {
  277. return E(this._rgb)
  278. }, e.prototype.lab = function() {
  279. return T(this._rgb)
  280. }, e.prototype.lch = function() {
  281. return O(this._rgb)
  282. }, e.prototype.hsi = function() {
  283. return L(this._rgb)
  284. }, e.prototype.gl = function() {
  285. return [this._rgb[0] / 255, this._rgb[1] / 255, this._rgb[2] / 255, this._rgb[3]]
  286. }, e.prototype.luminance = function(f, a) {
  287. var r, t, n, s;
  288. return (null == a && (a = "rgb"), !arguments.length) ? P(this._rgb) : (0 === f && (this._rgb = [0, 0, 0, this._rgb[3]]), 1 === f && (this._rgb = [255, 255, 255, this._rgb[3]]), r = P(this._rgb), t = 1e-7, n = 20, s = function(e, r) {
  289. var l, i;
  290. return i = e.interpolate(0.5, r, a), l = i.luminance(), d(f - l) < t || !n-- ? i : l > f ? s(e, i) : s(i, r)
  291. }, this._rgb = (r > f ? s(new e("black"), this) : s(this, new e("white"))).rgba(), this)
  292. }, e.prototype.name = function() {
  293. var e, f;
  294. for (f in e = this.hex(), y.colors)
  295. if (e === y.colors[f]) return f;
  296. return e
  297. }, e.prototype.alpha = function(e) {
  298. return arguments.length ? (this._rgb[3] = e, this) : this._rgb[3]
  299. }, e.prototype.css = function(e) {
  300. var f, d, a, r;
  301. return (null == e && (e = "rgb"), d = this, a = d._rgb, 3 === e.length && 1 > a[3] && (e += "a"), "rgb" === e) ? e + "(" + a.slice(0, 3).map(Math.round).join(",") + ")" : "rgba" === e ? e + "(" + a.slice(0, 3).map(Math.round).join(",") + "," + a[3] + ")" : "hsl" === e || "hsla" === e ? (f = d.hsl(), r = function(e) {
  302. return $(100 * e) / 100
  303. }, f[0] = r(f[0]), f[1] = r(100 * f[1]) + "%", f[2] = r(100 * f[2]) + "%", 4 === e.length && (f[3] = a[3]), e + "(" + f.join(",") + ")") : void 0
  304. }, e.prototype.interpolate = function(d, f, a) {
  305. var r, t, n, l, s, i, o, c, b, h, g, u, p, m;
  306. if (c = this, null == a && (a = "rgb"), "string" === D(f) && (f = new e(f)), "hsl" === a || "hsv" === a || "lch" === a || "hsi" === a) "hsl" === a ? (p = c.hsl(), m = f.hsl()) : "hsv" === a ? (p = c.hsv(), m = f.hsv()) : "hsi" === a ? (p = c.hsi(), m = f.hsi()) : "lch" === a && (p = c.lch(), m = f.lch()), "h" === a.substr(0, 1) ? (n = p[0], g = p[1], i = p[2], l = m[0], u = m[1], o = m[2]) : (i = p[0], g = p[1], n = p[2], o = m[0], u = m[1], l = m[2]), isNaN(n) || isNaN(l) ? isNaN(n) ? isNaN(l) ? t = H : (t = l, (1 === i || 0 === i) && "hsv" !== a && (h = u)) : (t = n, (1 === o || 0 === o) && "hsv" !== a && (h = g)) : (r = l > n && 180 < l - n ? l - (n + 360) : l < n && 180 < n - l ? l + 360 - n : l - n, t = n + d * r), null == h && (h = g + d * (u - g)), s = i + d * (o - i), b = "h" === a.substr(0, 1) ? new e(t, h, s, a) : new e(s, h, t, a);
  307. else if ("rgb" === a) p = c._rgb, m = f._rgb, b = new e(p[0] + d * (m[0] - p[0]), p[1] + d * (m[1] - p[1]), p[2] + d * (m[2] - p[2]), a);
  308. else if ("lab" === a) p = c.lab(), m = f.lab(), b = new e(p[0] + d * (m[0] - p[0]), p[1] + d * (m[1] - p[1]), p[2] + d * (m[2] - p[2]), a);
  309. else throw "color mode " + a + " is not supported";
  310. return b.alpha(c.alpha() + d * (f.alpha() - c.alpha())), b
  311. }, e.prototype.premultiply = function() {
  312. var e, f;
  313. return f = this.rgb(), e = this.alpha(), y(f[0] * e, f[1] * e, f[2] * e, e)
  314. }, e.prototype.darken = function(e) {
  315. var f, d;
  316. return null == e && (e = 20), d = this, f = d.lch(), f[0] -= e, y.lch(f).alpha(d.alpha())
  317. }, e.prototype.darker = function(e) {
  318. return this.darken(e)
  319. }, e.prototype.brighten = function(e) {
  320. return null == e && (e = 20), this.darken(-e)
  321. }, e.prototype.brighter = function(e) {
  322. return this.brighten(e)
  323. }, e.prototype.saturate = function(e) {
  324. var f, d;
  325. return null == e && (e = 20), d = this, f = d.lch(), f[1] += e, y.lch(f).alpha(d.alpha())
  326. }, e.prototype.desaturate = function(e) {
  327. return null == e && (e = 20), this.saturate(-e)
  328. }, e
  329. }(), _ = function(e) {
  330. for (var f in e) 3 > f ? (0 > e[f] && (e[f] = 0), 255 < e[f] && (e[f] = 255)) : 3 === f && (0 > e[f] && (e[f] = 0), 1 < e[f] && (e[f] = 1));
  331. return e
  332. }, w = function(e) {
  333. var f, d, a, r, t, n, l, s;
  334. if (e = e.toLowerCase(), null != y.colors && y.colors[e]) return j(y.colors[e]);
  335. if (a = e.match(/rgb\(\s*(\-?\d+),\s*(\-?\d+)\s*,\s*(\-?\d+)\s*\)/)) {
  336. for (r = a.slice(1, 4), d = t = 0; 2 >= t; d = ++t) r[d] = +r[d];
  337. r[3] = 1
  338. } else if (a = e.match(/rgba\(\s*(\-?\d+),\s*(\-?\d+)\s*,\s*(\-?\d+)\s*,\s*([01]|[01]?\.\d+)\)/))
  339. for (r = a.slice(1, 5), d = n = 0; 3 >= n; d = ++n) r[d] = +r[d];
  340. else if (a = e.match(/rgb\(\s*(\-?\d+(?:\.\d+)?)%,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*\)/)) {
  341. for (r = a.slice(1, 4), d = l = 0; 2 >= l; d = ++l) r[d] = $(2.55 * r[d]);
  342. r[3] = 1
  343. } else if (a = e.match(/rgba\(\s*(\-?\d+(?:\.\d+)?)%,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)/)) {
  344. for (r = a.slice(1, 5), d = s = 0; 2 >= s; d = ++s) r[d] = $(2.55 * r[d]);
  345. r[3] = +r[3]
  346. } else(a = e.match(/hsl\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*\)/)) ? (f = a.slice(1, 4), f[1] *= 0.01, f[2] *= 0.01, r = k(f), r[3] = 1) : (a = e.match(/hsla\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)/)) && (f = a.slice(1, 4), f[1] *= 0.01, f[2] *= 0.01, r = k(f), r[3] = +a[4]);
  347. return r
  348. }, j = function(e) {
  349. var f, d, a, t, r, n;
  350. 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]), n = parseInt(e, 16), t = n >> 16, a = 255 & n >> 8, d = 255 & n, [t, a, d, 1];
  351. if (e.match(/^#?([A-Fa-f0-9]{8})$/)) return 9 === e.length && (e = e.substr(1)), n = parseInt(e, 16), t = 255 & n >> 24, a = 255 & n >> 16, d = 255 & n >> 8, f = 255 & n, [t, a, d, f];
  352. if (r = w(e)) return r;
  353. throw "unknown color: " + e
  354. }, v = function(e, f, d) {
  355. var a, t, n, r;
  356. return r = K(arguments), e = r[0], f = r[1], d = r[2], e /= 360, e < 1 / 3 ? (a = (1 - f) / 3, n = (1 + f * x(u * e) / x(c - u * e)) / 3, t = 1 - (a + n)) : e < 2 / 3 ? (e -= 1 / 3, n = (1 - f) / 3, t = (1 + f * x(u * e) / x(c - u * e)) / 3, a = 1 - (n + t)) : (e -= 2 / 3, t = (1 - f) / 3, a = (1 + f * x(u * e) / x(c - u * e)) / 3, n = 1 - (t + a)), n = S(3 * (d * n)), t = S(3 * (d * t)), a = S(3 * (d * a)), [255 * n, 255 * t, 255 * a]
  357. }, k = function() {
  358. var e, f, d, a, t, n, l, r, s, i, o, c, b, h;
  359. if (b = K(arguments), a = b[0], r = b[1], n = b[2], 0 === r) l = d = e = 255 * n;
  360. else {
  361. for (o = [0, 0, 0], f = [0, 0, 0], i = 0.5 > n ? n * (1 + r) : n + r - n * r, s = 2 * n - i, a /= 360, o[0] = a + 1 / 3, o[1] = a, o[2] = a - 1 / 3, t = c = 0; 2 >= c; t = ++c) 0 > o[t] && (o[t] += 1), 1 < o[t] && (o[t] -= 1), f[t] = 1 > 6 * o[t] ? s + 6 * (i - s) * o[t] : 1 > 2 * o[t] ? i : 2 > 3 * o[t] ? s + 6 * ((i - s) * (2 / 3 - o[t])) : s;
  362. h = [$(255 * f[0]), $(255 * f[1]), $(255 * f[2])], l = h[0], d = h[1], e = h[2]
  363. }
  364. return [l, d, e]
  365. }, q = function() {
  366. var e, d, f, a, n, i, o, c, r, s, t, b, h, g, u, p, m, y;
  367. return b = K(arguments), a = b[0], r = b[1], t = b[2], t *= 255, 0 === r ? c = f = e = t : (360 === a && (a = 0), 360 < a && (a -= 360), 0 > a && (a += 360), a /= 60, n = l(a), d = a - n, i = t * (1 - r), o = t * (1 - r * d), s = t * (1 - r * (1 - d)), 0 === n ? (h = [t, s, i], c = h[0], f = h[1], e = h[2]) : 1 === n ? (g = [o, t, i], c = g[0], f = g[1], e = g[2]) : 2 === n ? (u = [i, t, s], c = u[0], f = u[1], e = u[2]) : 3 === n ? (p = [i, o, t], c = p[0], f = p[1], e = p[2]) : 4 === n ? (m = [s, i, t], c = m[0], f = m[1], e = m[2]) : 5 === n ? (y = [t, i, o], c = y[0], f = y[1], e = y[2]) : void 0), (c = $(c), f = $(f), e = $(e), [c, f, e])
  368. }, r = 18, i = 0.95047, h = 1, p = 1.08883, C = function() {
  369. var e, d, a, r, t, n;
  370. return n = K(arguments), t = n[0], e = n[1], d = n[2], a = f(e * e + d * d), r = 180 * (Math.atan2(d, e) / J), [t, a, r]
  371. }, U = function(e, f, d) {
  372. var a, t, r, n, l, s, o;
  373. return void 0 !== e && 3 === e.length && (s = e, e = s[0], f = s[1], d = s[2]), void 0 !== e && 3 === e.length && (o = e, e = o[0], f = o[1], d = o[2]), n = (e + 16) / 116, r = n + f / 500, l = n - d / 200, r = B(r) * i, n = B(n) * h, l = B(l) * p, t = V(3.2404542 * r - 1.5371385 * n - 0.4985314 * l), a = V(-0.969266 * r + 1.8760108 * n + 0.041556 * l), d = V(0.0556434 * r - 0.2040259 * n + 1.0572252 * l), [S(t, 0, 255), S(a, 0, 255), S(d, 0, 255), 1]
  374. }, B = function(e) {
  375. return 0.206893034 < e ? e * e * e : (e - 4 / 29) / 7.787037
  376. }, V = function(e) {
  377. return $(255 * (0.00304 >= e ? 12.92 * e : 1.055 * Z(e, 1 / 2.4) - 0.055))
  378. }, z = function() {
  379. var e, f, d, a;
  380. return a = K(arguments), d = a[0], e = a[1], f = a[2], f = f * J / 180, [d, I(f) * e, Math.sin(f) * e]
  381. }, G = function(e, f, d) {
  382. var t, n, a, l, s, r, i;
  383. return r = z(e, f, d), t = r[0], n = r[1], a = r[2], i = U(t, n, a), s = i[0], l = i[1], a = i[2], [S(s, 0, 255), S(l, 0, 255), S(a, 0, 255)]
  384. }, P = function(e, f, d) {
  385. var a;
  386. return a = K(arguments), e = a[0], f = a[1], d = a[2], e = R(e), f = R(f), d = R(d), 0.2126 * e + 0.7152 * f + 0.0722 * d
  387. }, R = function(e) {
  388. return e /= 255, 0.03928 >= e ? e / 12.92 : Z((e + 0.055) / 1.055, 2.4)
  389. }, A = function() {
  390. var e, f, d, a, r, t;
  391. return t = K(arguments), d = t[0], f = t[1], e = t[2], r = d << 16 | f << 8 | e, a = "000000" + r.toString(16), "#" + a.substr(a.length - 6)
  392. }, L = function() {
  393. var e, d, t, n, l, i, o, r, s;
  394. return s = K(arguments), o = s[0], t = s[1], d = s[2], e = 2 * J, o /= 255, t /= 255, d /= 255, i = a(o, t, d), l = (o + t + d) / 3, r = 1 - i / l, 0 === r ? n = 0 : (n = (o - t + (o - d)) / 2, n /= f((o - t) * (o - t) + (o - d) * (t - d)), n = Math.acos(n), d > t && (n = e - n), n /= e), [360 * n, r, l]
  395. }, Y = function(e, f, d) {
  396. var r, t, l, i, o, s;
  397. return void 0 !== e && 3 <= e.length && (s = e, e = s[0], f = s[1], d = s[2]), e /= 255, f /= 255, d /= 255, i = a(e, f, d), l = n(e, f, d), t = (l + i) / 2, l === i ? (o = 0, r = H) : o = 0.5 > t ? (l - i) / (l + i) : (l - i) / (2 - l - i), e === l ? r = (f - d) / (l - i) : f === l ? r = 2 + (d - e) / (l - i) : d === l && (r = 4 + (e - f) / (l - i)), r *= 60, 0 > r && (r += 360), [r, o, t]
  398. }, E = function() {
  399. var e, f, d, t, l, i, o, r, s, c;
  400. return c = K(arguments), o = c[0], d = c[1], e = c[2], i = a(o, d, e), l = n(o, d, e), f = l - i, s = l / 255, 0 === l ? (t = H, r = 0) : (r = f / l, o === l && (t = (d - e) / f), d === l && (t = 2 + (e - o) / f), e === l && (t = 4 + (o - d) / f), t *= 60, 0 > t && (t += 360)), [t, r, s]
  401. }, T = function() {
  402. var e, f, d, a, r, t, n;
  403. return n = K(arguments), d = n[0], f = n[1], e = n[2], d = N(d), f = N(f), e = N(e), a = M((0.4124564 * d + 0.3575761 * f + 0.1804375 * e) / i), r = M((0.2126729 * d + 0.7151522 * f + 0.072175 * e) / h), t = M((0.0193339 * d + 0.119192 * f + 0.9503041 * e) / p), [116 * r - 16, 500 * (a - r), 200 * (r - t)]
  404. }, N = function(e) {
  405. return 0.04045 >= (e /= 255) ? e / 12.92 : Z((e + 0.055) / 1.055, 2.4)
  406. }, M = function(e) {
  407. return 0.008856 < e ? Z(e, 1 / 3) : 7.787037 * e + 4 / 29
  408. }, O = function() {
  409. var e, f, d, a, t, r, n;
  410. return r = K(arguments), t = r[0], d = r[1], f = r[2], n = T(t, d, f), a = n[0], e = n[1], f = n[2], C(a, e, f)
  411. }, y.scale = function(e, r) {
  412. var t, s, f, i, o, c, b, h, g, u, p, m, x, _, w, j, v, q, k, C, z;
  413. return j = "rgb", v = y("#ccc"), z = 0, x = !1, m = [0, 1], u = [], k = !1, C = [], w = 0, _ = 1, p = !1, q = 0, g = {}, c = function(e, f) {
  414. var d, a, r, t, n, l, s;
  415. if (null == e && (e = ["#ddd", "#222"]), null != e && "string" === D(e) && null != (null == (n = y.brewer) ? void 0 : n[e]) && (e = y.brewer[e]), "array" === D(e)) {
  416. for (e = e.slice(0), d = r = 0, l = e.length - 1; 0 <= l ? r <= l : r >= l; d = 0 <= l ? ++r : --r) a = e[d], "string" === D(a) && (e[d] = y(a));
  417. if (null != f) C = f;
  418. else
  419. for (C = [], d = t = 0, s = e.length - 1; 0 <= s ? t <= s : t >= s; d = 0 <= s ? ++t : --t) C.push(d / (e.length - 1))
  420. }
  421. return o(), u = e
  422. }, b = function(e) {
  423. return null == e && (e = []), m = e, w = e[0], _ = e[e.length - 1], o(), q = 2 === e.length ? 0 : e.length - 1
  424. }, f = function(e) {
  425. var f, d;
  426. if (null != m) {
  427. for (d = m.length - 1, f = 0; f < d && e >= m[f];) f++;
  428. return f - 1
  429. }
  430. return 0
  431. }, h = function(e) {
  432. return e
  433. }, t = function(e) {
  434. var d, a, r, t, n;
  435. return n = e, 2 < m.length && (t = m.length - 1, d = f(e), r = m[0] + (m[1] - m[0]) * (0 + 0.5 * z), a = m[t - 1] + (m[t] - m[t - 1]) * (1 - 0.5 * z), n = w + (m[d] + 0.5 * (m[d + 1] - m[d]) - r) / (a - r) * (_ - w)), n
  436. }, i = function(e, d) {
  437. var r, s, o, c, i, b, p, t, x;
  438. if (null == d && (d = !1), isNaN(e)) return v;
  439. if (d ? p = e : 2 < m.length ? (r = f(e), p = r / (q - 1)) : (p = o = w === _ ? 0 : (e - w) / (_ - w), p = o = (e - w) / (_ - w), p = a(1, n(0, p))), d || (p = h(p)), i = l(1e4 * p), g[i]) s = g[i];
  440. else {
  441. if ("array" === D(u))
  442. for (c = t = 0, x = C.length - 1; 0 <= x ? t <= x : t >= x; c = 0 <= x ? ++t : --t) {
  443. if (b = C[c], p <= b) {
  444. s = u[c];
  445. break
  446. }
  447. if (p >= b && c === C.length - 1) {
  448. s = u[c];
  449. break
  450. }
  451. if (p > b && p < C[c + 1]) {
  452. p = (p - b) / (C[c + 1] - b), s = y.interpolate(u[c], u[c + 1], p, j);
  453. break
  454. }
  455. } else "function" === D(u) && (s = u(p));
  456. g[i] = s
  457. }
  458. return s
  459. }, o = function() {
  460. return g = {}
  461. }, c(e, r), s = function(e) {
  462. var f;
  463. return f = i(e), k && f[k] ? f[k]() : f
  464. }, s.domain = function(e, f, a, r) {
  465. var t;
  466. return (null == a && (a = "e"), !arguments.length) ? m : (null != f && (t = y.analyze(e, r), e = 0 === f ? [t.min, t.max] : y.limits(t, a, f)), b(e), s)
  467. }, s.mode = function(e) {
  468. return arguments.length ? (j = e, o(), s) : j
  469. }, s.range = function(e, f) {
  470. return c(e, f), s
  471. }, s.out = function(e) {
  472. return k = e, s
  473. }, s.spread = function(e) {
  474. return arguments.length ? (z = e, s) : z
  475. }, s.correctLightness = function(e) {
  476. return arguments.length ? (p = e, o(), h = p ? function(e) {
  477. var f, a, r, t, n, l, s, o, c;
  478. for (f = i(0, !0).lab()[0], a = i(1, !0).lab()[0], s = f > a, r = i(e, !0).lab()[0], n = f + (a - f) * e, t = r - n, o = 0, c = 1, l = 20; 0.01 < d(t) && 0 < l--;)(function() {
  479. return s && (t *= -1), 0 > t ? (o = e, e += 0.5 * (c - e)) : (c = e, e += 0.5 * (o - e)), r = i(e, !0).lab()[0], t = r - n
  480. })();
  481. return e
  482. } : function(e) {
  483. return e
  484. }, s) : p
  485. }, s.colors = function(f) {
  486. var d, a, r, t, n, l;
  487. if (null == f && (f = "hex"), e = [], a = [], 2 < m.length)
  488. for (d = r = 1, l = m.length; 1 <= l ? r < l : r > l; d = 1 <= l ? ++r : --r) a.push(0.5 * (m[d - 1] + m[d]));
  489. else a = m;
  490. for (t = 0, n = a.length; t < n; t++) d = a[t], e.push(s(d)[f]());
  491. return e
  492. }, s
  493. }, null == (W = y.scales) && (y.scales = {}), y.scales.cool = function() {
  494. return y.scale([y.hsl(180, 1, .9), y.hsl(250, .7, .4)])
  495. }, y.scales.hot = function() {
  496. return y.scale(["#000", "#f00", "#ff0", "#fff"], [0, 0.25, 0.75, 1]).mode("rgb")
  497. }, y.analyze = function(e, f, d) {
  498. var a, t, n, r, l, s, i;
  499. if (n = {
  500. min: F,
  501. max: -1 * F,
  502. sum: 0,
  503. values: [],
  504. count: 0
  505. }, null == d && (d = function() {
  506. return !0
  507. }), a = function(e) {
  508. null == e || isNaN(e) || (n.values.push(e), n.sum += e, e < n.min && (n.min = e), e > n.max && (n.max = e), n.count += 1)
  509. }, l = function(e, r) {
  510. if (d(e, r)) return null != f && "function" === D(f) ? a(f(e)) : null != f && "string" === D(f) || "number" === D(f) ? a(e[f]) : a(e)
  511. }, "array" === D(e))
  512. for (s = 0, i = e.length; s < i; s++) r = e[s], l(r);
  513. else
  514. for (t in e) r = e[t], l(r, t);
  515. return n.domain = [n.min, n.max], n.limits = function(e, f) {
  516. return y.limits(n, e, f)
  517. }, n
  518. }, y.limits = function(e, f, a) {
  519. var r, t, s, o, c, b, h, i, g, u, m, x, _, w, j, v, n, k, q, p, C, z, U, B, G, S, P, R, A, L, Y, E, T, O, N, X, K, M, V, W, I, J, H, $, Q, ee, fe, de, ae, re, te, ne, le, se, ie, oe, ce = Math.log,
  520. be = Math.LOG10E;
  521. if (null == f && (f = "equal"), null == a && (a = 7), "array" === D(e) && (e = y.analyze(e)), _ = e.min, m = e.max, U = e.sum, S = e.values.sort(function(e, f) {
  522. return e - f
  523. }), u = [], "c" === f.substr(0, 1) && (u.push(_), u.push(m)), "e" === f.substr(0, 1)) {
  524. for (u.push(_), h = P = 1, K = a - 1; 1 <= K ? P <= K : P >= K; h = 1 <= K ? ++P : --P) u.push(_ + h / a * (m - _));
  525. u.push(m)
  526. } else if ("l" === f.substr(0, 1)) {
  527. if (0 >= _) throw "Logarithmic scales are only possible for values > 0";
  528. for (w = be * ce(_), x = be * ce(m), u.push(_), (h = R = 1, $ = a - 1); 1 <= $ ? R <= $ : R >= $; h = 1 <= $ ? ++R : --R) u.push(Z(10, w + h / a * (x - w)));
  529. u.push(m)
  530. } else if ("q" === f.substr(0, 1)) {
  531. for (u.push(_), h = A = 1, Q = a - 1; 1 <= Q ? A <= Q : A >= Q; h = 1 <= Q ? ++A : --A) q = S.length * h / a, p = l(q), p === q ? u.push(S[p]) : (C = q - p, u.push(S[p] * C + S[p + 1] * (1 - C)));
  532. u.push(m)
  533. } else if ("k" === f.substr(0, 1)) {
  534. for (v = S.length, r = Array(v), c = Array(a), z = !0, n = 0, s = null, s = [], s.push(_), (h = L = 1, ee = a - 1); 1 <= ee ? L <= ee : L >= ee; h = 1 <= ee ? ++L : --L) s.push(_ + h / a * (m - _));
  535. for (s.push(m); z;) {
  536. for (i = Y = 0, fe = a - 1; 0 <= fe ? Y <= fe : Y >= fe; i = 0 <= fe ? ++Y : --Y) c[i] = 0;
  537. for (h = E = 0, de = v - 1; 0 <= de ? E <= de : E >= de; h = 0 <= de ? ++E : --E) {
  538. for (G = S[h], j = F, (i = T = 0, ae = a - 1); 0 <= ae ? T <= ae : T >= ae; i = 0 <= ae ? ++T : --T) b = d(s[i] - G), b < j && (j = b, t = i);
  539. c[t]++, r[h] = t
  540. }
  541. for (k = Array(a), i = O = 0, re = a - 1; 0 <= re ? O <= re : O >= re; i = 0 <= re ? ++O : --O) k[i] = null;
  542. for (h = N = 0, te = v - 1; 0 <= te ? N <= te : N >= te; h = 0 <= te ? ++N : --N) o = r[h], null === k[o] ? k[o] = S[h] : k[o] += S[h];
  543. for (i = X = 0, M = a - 1; 0 <= M ? X <= M : X >= M; i = 0 <= M ? ++X : --X) k[i] *= 1 / c[i];
  544. for (z = !1, i = ne = 0, V = a - 1; 0 <= V ? ne <= V : ne >= V; i = 0 <= V ? ++ne : --ne)
  545. if (k[i] !== s[h]) {
  546. z = !0;
  547. break
  548. } s = k, n++, 200 < n && (z = !1)
  549. }
  550. for (g = {}, i = le = 0, W = a - 1; 0 <= W ? le <= W : le >= W; i = 0 <= W ? ++le : --le) g[i] = [];
  551. for (h = se = 0, I = v - 1; 0 <= I ? se <= I : se >= I; h = 0 <= I ? ++se : --se) o = r[h], g[o].push(S[h]);
  552. for (B = [], i = ie = 0, J = a - 1; 0 <= J ? ie <= J : ie >= J; i = 0 <= J ? ++ie : --ie) B.push(g[i][0]), B.push(g[i][g[i].length - 1]);
  553. for (B = B.sort(function(e, f) {
  554. return e - f
  555. }), u.push(B[0]), (h = oe = 1, H = B.length - 1); oe <= H; h = oe += 2) isNaN(B[h]) || u.push(B[h])
  556. }
  557. return u
  558. }, y.brewer = g = {
  559. OrRd: ["#fff7ec", "#fee8c8", "#fdd49e", "#fdbb84", "#fc8d59", "#ef6548", "#d7301f", "#b30000", "#7f0000"],
  560. PuBu: ["#fff7fb", "#ece7f2", "#d0d1e6", "#a6bddb", "#74a9cf", "#3690c0", "#0570b0", "#045a8d", "#023858"],
  561. BuPu: ["#f7fcfd", "#e0ecf4", "#bfd3e6", "#9ebcda", "#8c96c6", "#8c6bb1", "#88419d", "#810f7c", "#4d004b"],
  562. Oranges: ["#fff5eb", "#fee6ce", "#fdd0a2", "#fdae6b", "#fd8d3c", "#f16913", "#d94801", "#a63603", "#7f2704"],
  563. BuGn: ["#f7fcfd", "#e5f5f9", "#ccece6", "#99d8c9", "#66c2a4", "#41ae76", "#238b45", "#006d2c", "#00441b"],
  564. YlOrBr: ["#ffffe5", "#fff7bc", "#fee391", "#fec44f", "#fe9929", "#ec7014", "#cc4c02", "#993404", "#662506"],
  565. YlGn: ["#ffffe5", "#f7fcb9", "#d9f0a3", "#addd8e", "#78c679", "#41ab5d", "#238443", "#006837", "#004529"],
  566. Reds: ["#fff5f0", "#fee0d2", "#fcbba1", "#fc9272", "#fb6a4a", "#ef3b2c", "#cb181d", "#a50f15", "#67000d"],
  567. RdPu: ["#fff7f3", "#fde0dd", "#fcc5c0", "#fa9fb5", "#f768a1", "#dd3497", "#ae017e", "#7a0177", "#49006a"],
  568. Greens: ["#f7fcf5", "#e5f5e0", "#c7e9c0", "#a1d99b", "#74c476", "#41ab5d", "#238b45", "#006d2c", "#00441b"],
  569. YlGnBu: ["#ffffd9", "#edf8b1", "#c7e9b4", "#7fcdbb", "#41b6c4", "#1d91c0", "#225ea8", "#253494", "#081d58"],
  570. Purples: ["#fcfbfd", "#efedf5", "#dadaeb", "#bcbddc", "#9e9ac8", "#807dba", "#6a51a3", "#54278f", "#3f007d"],
  571. GnBu: ["#f7fcf0", "#e0f3db", "#ccebc5", "#a8ddb5", "#7bccc4", "#4eb3d3", "#2b8cbe", "#0868ac", "#084081"],
  572. Greys: ["#ffffff", "#f0f0f0", "#d9d9d9", "#bdbdbd", "#969696", "#737373", "#525252", "#252525", "#000000"],
  573. YlOrRd: ["#ffffcc", "#ffeda0", "#fed976", "#feb24c", "#fd8d3c", "#fc4e2a", "#e31a1c", "#bd0026", "#800026"],
  574. PuRd: ["#f7f4f9", "#e7e1ef", "#d4b9da", "#c994c7", "#df65b0", "#e7298a", "#ce1256", "#980043", "#67001f"],
  575. Blues: ["#f7fbff", "#deebf7", "#c6dbef", "#9ecae1", "#6baed6", "#4292c6", "#2171b5", "#08519c", "#08306b"],
  576. PuBuGn: ["#fff7fb", "#ece2f0", "#d0d1e6", "#a6bddb", "#67a9cf", "#3690c0", "#02818a", "#016c59", "#014636"],
  577. Spectral: ["#9e0142", "#d53e4f", "#f46d43", "#fdae61", "#fee08b", "#ffffbf", "#e6f598", "#abdda4", "#66c2a5", "#3288bd", "#5e4fa2"],
  578. RdYlGn: ["#a50026", "#d73027", "#f46d43", "#fdae61", "#fee08b", "#ffffbf", "#d9ef8b", "#a6d96a", "#66bd63", "#1a9850", "#006837"],
  579. RdBu: ["#67001f", "#b2182b", "#d6604d", "#f4a582", "#fddbc7", "#f7f7f7", "#d1e5f0", "#92c5de", "#4393c3", "#2166ac", "#053061"],
  580. PiYG: ["#8e0152", "#c51b7d", "#de77ae", "#f1b6da", "#fde0ef", "#f7f7f7", "#e6f5d0", "#b8e186", "#7fbc41", "#4d9221", "#276419"],
  581. PRGn: ["#40004b", "#762a83", "#9970ab", "#c2a5cf", "#e7d4e8", "#f7f7f7", "#d9f0d3", "#a6dba0", "#5aae61", "#1b7837", "#00441b"],
  582. RdYlBu: ["#a50026", "#d73027", "#f46d43", "#fdae61", "#fee090", "#ffffbf", "#e0f3f8", "#abd9e9", "#74add1", "#4575b4", "#313695"],
  583. BrBG: ["#543005", "#8c510a", "#bf812d", "#dfc27d", "#f6e8c3", "#f5f5f5", "#c7eae5", "#80cdc1", "#35978f", "#01665e", "#003c30"],
  584. RdGy: ["#67001f", "#b2182b", "#d6604d", "#f4a582", "#fddbc7", "#ffffff", "#e0e0e0", "#bababa", "#878787", "#4d4d4d", "#1a1a1a"],
  585. PuOr: ["#7f3b08", "#b35806", "#e08214", "#fdb863", "#fee0b6", "#f7f7f7", "#d8daeb", "#b2abd2", "#8073ac", "#542788", "#2d004b"],
  586. Set2: ["#66c2a5", "#fc8d62", "#8da0cb", "#e78ac3", "#a6d854", "#ffd92f", "#e5c494", "#b3b3b3"],
  587. Accent: ["#7fc97f", "#beaed4", "#fdc086", "#ffff99", "#386cb0", "#f0027f", "#bf5b17", "#666666"],
  588. Set1: ["#e41a1c", "#377eb8", "#4daf4a", "#984ea3", "#ff7f00", "#ffff33", "#a65628", "#f781bf", "#999999"],
  589. Set3: ["#8dd3c7", "#ffffb3", "#bebada", "#fb8072", "#80b1d3", "#fdb462", "#b3de69", "#fccde5", "#d9d9d9", "#bc80bd", "#ccebc5", "#ffed6f"],
  590. Dark2: ["#1b9e77", "#d95f02", "#7570b3", "#e7298a", "#66a61e", "#e6ab02", "#a6761d", "#666666"],
  591. Paired: ["#a6cee3", "#1f78b4", "#b2df8a", "#33a02c", "#fb9a99", "#e31a1c", "#fdbf6f", "#ff7f00", "#cab2d6", "#6a3d9a", "#ffff99", "#b15928"],
  592. Pastel2: ["#b3e2cd", "#fdcdac", "#cbd5e8", "#f4cae4", "#e6f5c9", "#fff2ae", "#f1e2cc", "#cccccc"],
  593. Pastel1: ["#fbb4ae", "#b3cde3", "#ccebc5", "#decbe4", "#fed9a6", "#ffffcc", "#e5d8bd", "#fddaec", "#f2f2f2"]
  594. }, y.colors = m = {
  595. indigo: "#4b0082",
  596. gold: "#ffd700",
  597. hotpink: "#ff69b4",
  598. firebrick: "#b22222",
  599. indianred: "#cd5c5c",
  600. yellow: "#ffff00",
  601. mistyrose: "#ffe4e1",
  602. darkolivegreen: "#556b2f",
  603. olive: "#808000",
  604. darkseagreen: "#8fbc8f",
  605. pink: "#ffc0cb",
  606. tomato: "#ff6347",
  607. lightcoral: "#f08080",
  608. orangered: "#ff4500",
  609. navajowhite: "#ffdead",
  610. lime: "#00ff00",
  611. palegreen: "#98fb98",
  612. darkslategrey: "#2f4f4f",
  613. greenyellow: "#adff2f",
  614. burlywood: "#deb887",
  615. seashell: "#fff5ee",
  616. mediumspringgreen: "#00fa9a",
  617. fuchsia: "#ff00ff",
  618. papayawhip: "#ffefd5",
  619. blanchedalmond: "#ffebcd",
  620. chartreuse: "#7fff00",
  621. dimgray: "#696969",
  622. black: "#000000",
  623. peachpuff: "#ffdab9",
  624. springgreen: "#00ff7f",
  625. aquamarine: "#7fffd4",
  626. white: "#ffffff",
  627. orange: "#ffa500",
  628. lightsalmon: "#ffa07a",
  629. darkslategray: "#2f4f4f",
  630. brown: "#a52a2a",
  631. ivory: "#fffff0",
  632. dodgerblue: "#1e90ff",
  633. peru: "#cd853f",
  634. lawngreen: "#7cfc00",
  635. chocolate: "#d2691e",
  636. crimson: "#dc143c",
  637. forestgreen: "#228b22",
  638. darkgrey: "#a9a9a9",
  639. lightseagreen: "#20b2aa",
  640. cyan: "#00ffff",
  641. mintcream: "#f5fffa",
  642. silver: "#c0c0c0",
  643. antiquewhite: "#faebd7",
  644. mediumorchid: "#ba55d3",
  645. skyblue: "#87ceeb",
  646. gray: "#808080",
  647. darkturquoise: "#00ced1",
  648. goldenrod: "#daa520",
  649. darkgreen: "#006400",
  650. floralwhite: "#fffaf0",
  651. darkviolet: "#9400d3",
  652. darkgray: "#a9a9a9",
  653. moccasin: "#ffe4b5",
  654. saddlebrown: "#8b4513",
  655. grey: "#808080",
  656. darkslateblue: "#483d8b",
  657. lightskyblue: "#87cefa",
  658. lightpink: "#ffb6c1",
  659. mediumvioletred: "#c71585",
  660. slategrey: "#708090",
  661. red: "#ff0000",
  662. deeppink: "#ff1493",
  663. limegreen: "#32cd32",
  664. darkmagenta: "#8b008b",
  665. palegoldenrod: "#eee8aa",
  666. plum: "#dda0dd",
  667. turquoise: "#40e0d0",
  668. lightgrey: "#d3d3d3",
  669. lightgoldenrodyellow: "#fafad2",
  670. darkgoldenrod: "#b8860b",
  671. lavender: "#e6e6fa",
  672. maroon: "#800000",
  673. yellowgreen: "#9acd32",
  674. sandybrown: "#f4a460",
  675. thistle: "#d8bfd8",
  676. violet: "#ee82ee",
  677. navy: "#000080",
  678. magenta: "#ff00ff",
  679. dimgrey: "#696969",
  680. tan: "#d2b48c",
  681. rosybrown: "#bc8f8f",
  682. olivedrab: "#6b8e23",
  683. blue: "#0000ff",
  684. lightblue: "#add8e6",
  685. ghostwhite: "#f8f8ff",
  686. honeydew: "#f0fff0",
  687. cornflowerblue: "#6495ed",
  688. slateblue: "#6a5acd",
  689. linen: "#faf0e6",
  690. darkblue: "#00008b",
  691. powderblue: "#b0e0e6",
  692. seagreen: "#2e8b57",
  693. darkkhaki: "#bdb76b",
  694. snow: "#fffafa",
  695. sienna: "#a0522d",
  696. mediumblue: "#0000cd",
  697. royalblue: "#4169e1",
  698. lightcyan: "#e0ffff",
  699. green: "#008000",
  700. mediumpurple: "#9370db",
  701. midnightblue: "#191970",
  702. cornsilk: "#fff8dc",
  703. paleturquoise: "#afeeee",
  704. bisque: "#ffe4c4",
  705. slategray: "#708090",
  706. darkcyan: "#008b8b",
  707. khaki: "#f0e68c",
  708. wheat: "#f5deb3",
  709. teal: "#008080",
  710. darkorchid: "#9932cc",
  711. deepskyblue: "#00bfff",
  712. salmon: "#fa8072",
  713. darkred: "#8b0000",
  714. steelblue: "#4682b4",
  715. palevioletred: "#db7093",
  716. lightslategray: "#778899",
  717. aliceblue: "#f0f8ff",
  718. lightslategrey: "#778899",
  719. lightgreen: "#90ee90",
  720. orchid: "#da70d6",
  721. gainsboro: "#dcdcdc",
  722. mediumseagreen: "#3cb371",
  723. lightgray: "#d3d3d3",
  724. mediumturquoise: "#48d1cc",
  725. lemonchiffon: "#fffacd",
  726. cadetblue: "#5f9ea0",
  727. lightyellow: "#ffffe0",
  728. lavenderblush: "#fff0f5",
  729. coral: "#ff7f50",
  730. purple: "#800080",
  731. aqua: "#00ffff",
  732. whitesmoke: "#f5f5f5",
  733. mediumslateblue: "#7b68ee",
  734. darkorange: "#ff8c00",
  735. mediumaquamarine: "#66cdaa",
  736. darksalmon: "#e9967a",
  737. beige: "#f5f5dc",
  738. blueviolet: "#8a2be2",
  739. azure: "#f0ffff",
  740. lightsteelblue: "#b0c4de",
  741. oldlace: "#fdf5e6"
  742. }, D = function() {
  743. var e, f, d, a, r;
  744. for (e = {}, r = ["Boolean", "Number", "String", "Function", "Array", "Date", "RegExp", "Undefined", "Null"], (d = 0, a = r.length); d < a; d++) f = r[d], e["[object " + f + "]"] = f.toLowerCase();
  745. return function(f) {
  746. var d;
  747. return d = Object.prototype.toString.call(f), e[d] || "object"
  748. }
  749. }(), S = function(e, f, d) {
  750. return null == f && (f = 0), null == d && (d = 1), e < f && (e = f), e > d && (e = d), e
  751. }, K = function(e) {
  752. return 3 <= e.length ? e : e[0]
  753. }, u = 2 * J, c = J / 3, x = I, b = function(e) {
  754. var f, d, a, r, n, l, s, o, t, i, c;
  755. return e = function() {
  756. var f, d, a;
  757. for (a = [], f = 0, d = e.length; f < d; f++) r = e[f], a.push(y(r));
  758. return a
  759. }(), 2 === e.length ? (t = function() {
  760. var f, d, a;
  761. for (a = [], f = 0, d = e.length; f < d; f++) r = e[f], a.push(r.lab());
  762. return a
  763. }(), n = t[0], l = t[1], f = function(e) {
  764. var f, d;
  765. return d = function() {
  766. var d, a;
  767. for (a = [], f = d = 0; 2 >= d; f = ++d) a.push(n[f] + e * (l[f] - n[f]));
  768. return a
  769. }(), y.lab.apply(y, d)
  770. }) : 3 === e.length ? (i = function() {
  771. var f, d, a;
  772. for (a = [], f = 0, d = e.length; f < d; f++) r = e[f], a.push(r.lab());
  773. return a
  774. }(), n = i[0], l = i[1], s = i[2], f = function(e) {
  775. var f, d;
  776. return d = function() {
  777. var d, a;
  778. for (a = [], f = d = 0; 2 >= d; f = ++d) a.push((1 - e) * (1 - e) * n[f] + 2 * (1 - e) * e * l[f] + e * e * s[f]);
  779. return a
  780. }(), y.lab.apply(y, d)
  781. }) : 4 === e.length ? (c = function() {
  782. var f, d, a;
  783. for (a = [], f = 0, d = e.length; f < d; f++) r = e[f], a.push(r.lab());
  784. return a
  785. }(), n = c[0], l = c[1], s = c[2], o = c[3], f = function(e) {
  786. var f, d;
  787. return d = function() {
  788. var d, a;
  789. for (a = [], f = d = 0; 2 >= d; f = ++d) a.push((1 - e) * (1 - e) * (1 - e) * n[f] + 3 * (1 - e) * (1 - e) * e * l[f] + 3 * (1 - e) * e * e * s[f] + e * e * e * o[f]);
  790. return a
  791. }(), y.lab.apply(y, d)
  792. }) : 5 === e.length && (d = b(e.slice(0, 3)), a = b(e.slice(2, 5)), f = function(e) {
  793. return 0.5 > e ? d(2 * e) : a(2 * (e - 0.5))
  794. }), f
  795. }, y.interpolate.bezier = b
  796. }).call(this)
  797. }, {}],
  798. "/Users/qrohlf/Code/trianglify/node_modules/delaunator/index.js": [function(e, a) {
  799. "use strict";
  800. function r(a, l, s) {
  801. l || (l = m), s || (s = _);
  802. for (var u = Infinity, w = Infinity, j = -Infinity, v = -Infinity, C = this.coords = [], z = this.ids = new Uint32Array(a.length), U = 0; U < a.length; U++) {
  803. var i = a[U],
  804. p = l(i),
  805. x = s(i);
  806. z[U] = U, C[2 * U] = p, C[2 * U + 1] = x, p < u && (u = p), x < w && (w = x), p > j && (j = p), x > v && (v = x)
  807. }
  808. var y, B, G, S = (u + j) / 2,
  809. P = (w + v) / 2,
  810. R = Infinity;
  811. for (U = 0; U < a.length; U++) {
  812. var A = t(S, P, C[2 * U], C[2 * U + 1]);
  813. A < R && (y = U, R = A)
  814. }
  815. for (R = Infinity, U = 0; U < a.length; U++) U !== y && (A = t(C[2 * y], C[2 * y + 1], C[2 * U], C[2 * U + 1]), A < R && 0 < A && (B = U, R = A));
  816. var d = Infinity;
  817. for (U = 0; U < a.length; U++)
  818. if (U !== y && U !== B) {
  819. var L = o(C[2 * y], C[2 * y + 1], C[2 * B], C[2 * B + 1], C[2 * U], C[2 * U + 1]);
  820. L < d && (G = U, d = L)
  821. } if (d === Infinity) throw new Error("No Delaunay triangulation exists for this input.");
  822. if (0 > n(C[2 * y], C[2 * y + 1], C[2 * B], C[2 * B + 1], C[2 * G], C[2 * G + 1])) {
  823. var r = B;
  824. B = G, G = r
  825. }
  826. var Y = C[2 * y],
  827. E = C[2 * y + 1],
  828. T = C[2 * B],
  829. O = C[2 * B + 1],
  830. N = C[2 * G],
  831. X = C[2 * G + 1],
  832. D = c(Y, E, T, O, N, X);
  833. for (this._cx = D.x, this._cy = D.y, g(z, C, 0, z.length - 1, D.x, D.y), this._hashSize = Math.ceil(f(a.length)), this._hash = [], U = 0; U < this._hashSize; U++) this._hash[U] = null;
  834. var K = this.hull = b(C, y);
  835. this._hashEdge(K), K.t = 0, K = b(C, B, K), this._hashEdge(K), K.t = 1, K = b(C, G, K), this._hashEdge(K), K.t = 2;
  836. var e = 2 * a.length - 5,
  837. M = this.triangles = new Uint32Array(3 * e),
  838. V = this.halfedges = new Int32Array(3 * e);
  839. this.trianglesLen = 0, this._addTriangle(y, B, G, -1, -1, -1);
  840. for (var W, F, I = 0; I < z.length; I++)
  841. if (U = z[I], p = C[2 * U], x = C[2 * U + 1], (p !== W || x !== F) && (W = p, F = x, (p !== Y || x !== E) && (p !== T || x !== O) && (p !== N || x !== X))) {
  842. var k, Z = this._hashKey(p, x),
  843. J = Z;
  844. do k = this._hash[J], J = (J + 1) % this._hashSize; while ((!k || k.removed) && J !== Z);
  845. for (K = k; 0 <= n(p, x, K.x, K.y, K.next.x, K.next.y);)
  846. if (K = K.next, K === k) throw new Error("Something is wrong with the input points.");
  847. var H = K === k,
  848. $ = this._addTriangle(K.i, U, K.next.i, -1, -1, K.t);
  849. K.t = $, K = b(C, U, K), K.t = this._legalize($ + 2), K.prev.prev.t === V[$ + 1] && (K.prev.prev.t = $ + 2);
  850. for (var Q = K.next; 0 > n(p, x, Q.x, Q.y, Q.next.x, Q.next.y);) $ = this._addTriangle(Q.i, U, Q.next.i, Q.prev.t, -1, Q.t), Q.prev.t = this._legalize($ + 2), this.hull = h(Q), Q = Q.next;
  851. if (H)
  852. for (Q = K.prev; 0 > n(p, x, Q.prev.x, Q.prev.y, Q.x, Q.y);) $ = this._addTriangle(Q.prev.i, U, Q.i, -1, Q.t, Q.prev.t), this._legalize($ + 2), Q.prev.t = $, this.hull = h(Q), Q = Q.prev;
  853. this._hashEdge(K), this._hashEdge(K.prev)
  854. } this.triangles = M.subarray(0, this.trianglesLen), this.halfedges = V.subarray(0, this.trianglesLen)
  855. }
  856. function t(e, f, d, a) {
  857. var r = e - d,
  858. t = f - a;
  859. return r * r + t * t
  860. }
  861. function n(e, f, d, a, r, t) {
  862. return (a - f) * (r - d) - (d - e) * (t - a)
  863. }
  864. function s(e, f, d, a, r, t, n, l) {
  865. e -= n, f -= l, d -= n, a -= l, r -= n, t -= l;
  866. var s = e * e + f * f,
  867. i = d * d + a * a,
  868. o = r * r + t * t;
  869. return 0 > e * (a * o - i * t) - f * (d * o - i * r) + s * (d * t - a * r)
  870. }
  871. function o(e, f, a, r, t, n) {
  872. a -= e, r -= f, t -= e, n -= f;
  873. var l = a * a + r * r,
  874. s = t * t + n * n;
  875. if (0 == l || 0 == s) return Infinity;
  876. var i = a * n - r * t;
  877. if (0 == i) return Infinity;
  878. var d = 0.5 * (n * l - r * s) / i,
  879. o = 0.5 * (a * s - t * l) / i;
  880. return d * d + o * o
  881. }
  882. function c(e, f, a, r, t, n) {
  883. a -= e, r -= f, t -= e, n -= f;
  884. var l = a * a + r * r,
  885. s = t * t + n * n,
  886. i = a * n - r * t,
  887. d = 0.5 * (n * l - r * s) / i,
  888. o = 0.5 * (a * s - t * l) / i;
  889. return {
  890. x: e + d,
  891. y: f + o
  892. }
  893. }
  894. function b(e, f, d) {
  895. var a = {
  896. i: f,
  897. x: e[2 * f],
  898. y: e[2 * f + 1],
  899. t: 0,
  900. prev: null,
  901. next: null,
  902. removed: !1
  903. };
  904. return d ? (a.next = d.next, a.prev = d, d.next.prev = a, d.next = a) : (a.prev = a, a.next = a), a
  905. }
  906. function h(e) {
  907. return e.prev.next = e.next, e.next.prev = e.prev, e.removed = !0, e.prev
  908. }
  909. function g(e, f, d, a, r, t) {
  910. var n, l, s;
  911. if (20 >= a - d)
  912. for (n = d + 1; n <= a; n++) {
  913. for (s = e[n], l = n - 1; l >= d && 0 < u(f, e[l], s, r, t);) e[l + 1] = e[l--];
  914. e[l + 1] = s
  915. } else {
  916. for (n = d + 1, l = a, p(e, d + a >> 1, n), 0 < u(f, e[d], e[a], r, t) && p(e, d, a), 0 < u(f, e[n], e[a], r, t) && p(e, n, a), 0 < u(f, e[d], e[n], r, t) && p(e, d, n), s = e[n];;) {
  917. do n++; while (0 > u(f, e[n], s, r, t));
  918. do l--; while (0 < u(f, e[l], s, r, t));
  919. if (l < n) break;
  920. p(e, n, l)
  921. }
  922. e[d + 1] = e[l], e[l] = s, a - n + 1 >= l - d ? (g(e, f, n, a, r, t), g(e, f, d, l - 1, r, t)) : (g(e, f, d, l - 1, r, t), g(e, f, n, a, r, t))
  923. }
  924. }
  925. function u(e, f, d, a, r) {
  926. var n = t(e[2 * f], e[2 * f + 1], a, r),
  927. l = t(e[2 * d], e[2 * d + 1], a, r);
  928. return n - l || e[2 * f] - e[2 * d] || e[2 * f + 1] - e[2 * d + 1]
  929. }
  930. function p(e, f, d) {
  931. var a = e[f];
  932. e[f] = e[d], e[d] = a
  933. }
  934. function m(e) {
  935. return e[0]
  936. }
  937. function _(e) {
  938. return e[1]
  939. }
  940. a.exports = r, r.prototype = {
  941. _hashEdge: function(f) {
  942. this._hash[this._hashKey(f.x, f.y)] = f
  943. },
  944. _hashKey: function(e, f) {
  945. var a = e - this._cx,
  946. r = f - this._cy,
  947. t = 1 - a / (d(a) + d(r));
  948. return l((2 + (0 > r ? -t : t)) / 4 * this._hashSize)
  949. },
  950. _legalize: function(e) {
  951. var f = this.triangles,
  952. d = this.coords,
  953. a = this.halfedges,
  954. r = a[e],
  955. t = e - e % 3,
  956. n = r - r % 3,
  957. l = t + (e + 2) % 3,
  958. i = n + (r + 2) % 3,
  959. o = f[l],
  960. c = f[e],
  961. b = f[t + (e + 1) % 3],
  962. h = f[i],
  963. g = s(d[2 * o], d[2 * o + 1], d[2 * c], d[2 * c + 1], d[2 * b], d[2 * b + 1], d[2 * h], d[2 * h + 1]);
  964. return g ? (f[e] = h, f[r] = o, this._link(e, a[i]), this._link(r, a[l]), this._link(l, i), this._legalize(e), this._legalize(n + (r + 1) % 3)) : l
  965. },
  966. _link: function(e, f) {
  967. this.halfedges[e] = f, -1 !== f && (this.halfedges[f] = e)
  968. },
  969. _addTriangle: function(e, f, d, r, a, n) {
  970. var l = this.trianglesLen;
  971. return this.triangles[l] = e, this.triangles[l + 1] = f, this.triangles[l + 2] = d, this._link(l, r), this._link(l + 1, a), this._link(l + 2, n), this.trianglesLen += 3, l
  972. }
  973. }
  974. }, {}],
  975. "/Users/qrohlf/Code/trianglify/node_modules/process/browser.js": [function(e, f) {
  976. function d() {
  977. if (!n) {
  978. n = !0;
  979. for (var e, f = t.length; f;) {
  980. e = t, t = [];
  981. for (var d = -1; ++d < f;) e[d]();
  982. f = t.length
  983. }
  984. n = !1
  985. }
  986. }
  987. function a() {}
  988. var r = f.exports = {},
  989. t = [],
  990. n = !1;
  991. r.nextTick = function(e) {
  992. t.push(e), n || setTimeout(d, 0)
  993. }, r.title = "browser", r.browser = !0, r.env = {}, r.argv = [], r.version = "", r.versions = {}, r.on = a, r.addListener = a, r.once = a, r.off = a, r.removeListener = a, r.removeAllListeners = a, r.emit = a, r.binding = function() {
  994. throw new Error("process.binding is not supported")
  995. }, r.cwd = function() {
  996. return "/"
  997. }, r.chdir = function() {
  998. throw new Error("process.chdir is not supported")
  999. }, r.umask = function() {
  1000. return 0
  1001. }
  1002. }, {}],
  1003. "/Users/qrohlf/Code/trianglify/node_modules/seedrandom/index.js": [function(e, f) {
  1004. var d = e("./lib/alea"),
  1005. a = e("./lib/xor128"),
  1006. r = e("./lib/xorwow"),
  1007. t = e("./lib/xorshift7"),
  1008. n = e("./lib/xor4096"),
  1009. l = e("./lib/tychei"),
  1010. s = e("./seedrandom");
  1011. s.alea = d, s.xor128 = a, s.xorwow = r, s.xorshift7 = t, s.xor4096 = n, s.tychei = l, f.exports = s
  1012. }, {
  1013. "./lib/alea": "/Users/qrohlf/Code/trianglify/node_modules/seedrandom/lib/alea.js",
  1014. "./lib/tychei": "/Users/qrohlf/Code/trianglify/node_modules/seedrandom/lib/tychei.js",
  1015. "./lib/xor128": "/Users/qrohlf/Code/trianglify/node_modules/seedrandom/lib/xor128.js",
  1016. "./lib/xor4096": "/Users/qrohlf/Code/trianglify/node_modules/seedrandom/lib/xor4096.js",
  1017. "./lib/xorshift7": "/Users/qrohlf/Code/trianglify/node_modules/seedrandom/lib/xorshift7.js",
  1018. "./lib/xorwow": "/Users/qrohlf/Code/trianglify/node_modules/seedrandom/lib/xorwow.js",
  1019. "./seedrandom": "/Users/qrohlf/Code/trianglify/node_modules/seedrandom/seedrandom.js"
  1020. }],
  1021. "/Users/qrohlf/Code/trianglify/node_modules/seedrandom/lib/alea.js": [function(f, d) {
  1022. (function(e, f, d) {
  1023. function a(e) {
  1024. var f = this,
  1025. d = n();
  1026. f.next = function() {
  1027. var e = 2091639 * f.s0 + 2.3283064365386963e-10 * f.c;
  1028. return f.s0 = f.s1, f.s1 = f.s2, f.s2 = e - (f.c = 0 | e)
  1029. }, f.c = 1, f.s0 = d(" "), f.s1 = d(" "), f.s2 = d(" "), f.s0 -= d(e), 0 > f.s0 && (f.s0 += 1), f.s1 -= d(e), 0 > f.s1 && (f.s1 += 1), f.s2 -= d(e), 0 > f.s2 && (f.s2 += 1), d = null
  1030. }
  1031. function r(e, f) {
  1032. return f.c = e.c, f.s0 = e.s0, f.s1 = e.s1, f.s2 = e.s2, f
  1033. }
  1034. function t(e, f) {
  1035. var d = new a(e),
  1036. t = f && f.state,
  1037. n = d.next;
  1038. return n.int32 = function() {
  1039. return 0 | 4294967296 * d.next()
  1040. }, n.double = function() {
  1041. return n() + 1.1102230246251565e-16 * (0 | 2097152 * n())
  1042. }, n.quick = n, t && ("object" == typeof t && r(t, d), n.state = function() {
  1043. return r(d, {})
  1044. }), n
  1045. }
  1046. function n() {
  1047. var e = 4022871197;
  1048. return function(f) {
  1049. f = f.toString();
  1050. for (var d = 0; d < f.length; d++) {
  1051. e += f.charCodeAt(d);
  1052. var a = 0.02519603282416938 * e;
  1053. e = a >>> 0, a -= e, a *= e, e = a >>> 0, a -= e, e += 4294967296 * a
  1054. }
  1055. return 2.3283064365386963e-10 * (e >>> 0)
  1056. }
  1057. }
  1058. f && f.exports ? f.exports = t : d && d.amd ? d(function() {
  1059. return t
  1060. }) : this.alea = t
  1061. })(this, "object" == typeof d && d, "function" == typeof e && e)
  1062. }, {}],
  1063. "/Users/qrohlf/Code/trianglify/node_modules/seedrandom/lib/tychei.js": [function(f, d) {
  1064. (function(e, f, d) {
  1065. function a(e) {
  1066. var f = this,
  1067. d = "";
  1068. f.next = function() {
  1069. var e = f.b,
  1070. r = f.c,
  1071. t = f.d,
  1072. d = f.a;
  1073. return e = e << 25 ^ e >>> 7 ^ r, r = 0 | r - t, t = t << 24 ^ t >>> 8 ^ d, d = 0 | d - e, f.b = e = e << 20 ^ e >>> 12 ^ r, f.c = r = 0 | r - t, f.d = t << 16 ^ r >>> 16 ^ d, f.a = 0 | d - e
  1074. }, f.a = 0, f.b = 0, f.c = -1640531527, f.d = 1367130551, e === l(e) ? (f.a = 0 | e / 4294967296, f.b = 0 | e) : d += e;
  1075. for (var a = 0; a < d.length + 20; a++) f.b ^= 0 | d.charCodeAt(a), f.next()
  1076. }
  1077. function r(e, f) {
  1078. return f.a = e.a, f.b = e.b, f.c = e.c, f.d = e.d, f
  1079. }
  1080. function t(e, f) {
  1081. var d = new a(e),
  1082. t = f && f.state,
  1083. n = function() {
  1084. return (d.next() >>> 0) / 4294967296
  1085. };
  1086. return n.double = function() {
  1087. do var e = d.next() >>> 11,
  1088. f = (d.next() >>> 0) / 4294967296,
  1089. a = (e + f) / 2097152; while (0 === a);
  1090. return a
  1091. }, n.int32 = d.next, n.quick = n, t && ("object" == typeof t && r(t, d), n.state = function() {
  1092. return r(d, {})
  1093. }), n
  1094. }
  1095. f && f.exports ? f.exports = t : d && d.amd ? d(function() {
  1096. return t
  1097. }) : this.tychei = t
  1098. })(this, "object" == typeof d && d, "function" == typeof e && e)
  1099. }, {}],
  1100. "/Users/qrohlf/Code/trianglify/node_modules/seedrandom/lib/xor128.js": [function(f, d) {
  1101. (function(e, f, d) {
  1102. function a(e) {
  1103. var f = this,
  1104. d = "";
  1105. f.x = 0, f.y = 0, f.z = 0, f.w = 0, f.next = function() {
  1106. var e = f.x ^ f.x << 11;
  1107. return f.x = f.y, f.y = f.z, f.z = f.w, f.w ^= f.w >>> 19 ^ e ^ e >>> 8
  1108. }, e === (0 | e) ? f.x = e : d += e;
  1109. for (var a = 0; a < d.length + 64; a++) f.x ^= 0 | d.charCodeAt(a), f.next()
  1110. }
  1111. function r(e, f) {
  1112. return f.x = e.x, f.y = e.y, f.z = e.z, f.w = e.w, f
  1113. }
  1114. function t(e, f) {
  1115. var d = new a(e),
  1116. t = f && f.state,
  1117. n = function() {
  1118. return (d.next() >>> 0) / 4294967296
  1119. };
  1120. return n.double = function() {
  1121. do var e = d.next() >>> 11,
  1122. f = (d.next() >>> 0) / 4294967296,
  1123. a = (e + f) / 2097152; while (0 === a);
  1124. return a
  1125. }, n.int32 = d.next, n.quick = n, t && ("object" == typeof t && r(t, d), n.state = function() {
  1126. return r(d, {})
  1127. }), n
  1128. }
  1129. f && f.exports ? f.exports = t : d && d.amd ? d(function() {
  1130. return t
  1131. }) : this.xor128 = t
  1132. })(this, "object" == typeof d && d, "function" == typeof e && e)
  1133. }, {}],
  1134. "/Users/qrohlf/Code/trianglify/node_modules/seedrandom/lib/xor4096.js": [function(f, d) {
  1135. (function(e, f, d) {
  1136. function a(e) {
  1137. var f = this;
  1138. f.next = function() {
  1139. var e, d, a = f.w,
  1140. r = f.X,
  1141. t = f.i;
  1142. return f.w = a = 0 | a + 1640531527, d = r[127 & t + 34], e = r[t = 127 & t + 1], d ^= d << 13, e ^= e << 17, d ^= d >>> 15, e ^= e >>> 12, d = r[t] = d ^ e, f.i = t, 0 | d + (a ^ a >>> 16)
  1143. },
  1144. function(e, f) {
  1145. var d, a, r, t, l, s = [],
  1146. i = 128;
  1147. for (f === (0 | f) ? (a = f, f = null) : (f += "\0", a = 0, i = n(i, f.length)), r = 0, t = -32; t < i; ++t) f && (a ^= f.charCodeAt((t + 32) % f.length)), 0 === t && (l = a), a ^= a << 10, a ^= a >>> 15, a ^= a << 4, a ^= a >>> 13, 0 <= t && (l = 0 | l + 1640531527, d = s[127 & t] ^= a + l, r = 0 == d ? r + 1 : 0);
  1148. for (128 <= r && (s[127 & (f && f.length || 0)] = -1), r = 127, t = 512; 0 < t; --t) a = s[127 & r + 34], d = s[r = 127 & r + 1], a ^= a << 13, d ^= d << 17, a ^= a >>> 15, d ^= d >>> 12, s[r] = a ^ d;
  1149. e.w = l, e.X = s, e.i = r
  1150. }(f, e)
  1151. }
  1152. function r(e, f) {
  1153. return f.i = e.i, f.w = e.w, f.X = e.X.slice(), f
  1154. }
  1155. function t(e, f) {
  1156. null == e && (e = +new Date);
  1157. var d = new a(e),
  1158. t = f && f.state,
  1159. n = function() {
  1160. return (d.next() >>> 0) / 4294967296
  1161. };
  1162. return n.double = function() {
  1163. do var e = d.next() >>> 11,
  1164. f = (d.next() >>> 0) / 4294967296,
  1165. a = (e + f) / 2097152; while (0 === a);
  1166. return a
  1167. }, n.int32 = d.next, n.quick = n, t && (t.X && r(t, d), n.state = function() {
  1168. return r(d, {})
  1169. }), n
  1170. }
  1171. f && f.exports ? f.exports = t : d && d.amd ? d(function() {
  1172. return t
  1173. }) : this.xor4096 = t
  1174. })(this, "object" == typeof d && d, "function" == typeof e && e)
  1175. }, {}],
  1176. "/Users/qrohlf/Code/trianglify/node_modules/seedrandom/lib/xorshift7.js": [function(f, d) {
  1177. (function(e, f, d) {
  1178. function a(e) {
  1179. var f = this;
  1180. f.next = function() {
  1181. var e, d, a = f.x,
  1182. r = f.i;
  1183. return e = a[r], e ^= e >>> 7, d = e ^ e << 24, e = a[7 & r + 1], d ^= e ^ e >>> 10, e = a[7 & r + 3], d ^= e ^ e >>> 3, e = a[7 & r + 4], d ^= e ^ e << 7, e = a[7 & r + 7], e ^= e << 13, d ^= e ^ e << 9, a[r] = d, f.i = 7 & r + 1, d
  1184. },
  1185. function(e, f) {
  1186. var d, a, r = [];
  1187. if (f === (0 | f)) a = r[0] = f;
  1188. else
  1189. for (f = "" + f, d = 0; d < f.length; ++d) r[7 & d] = r[7 & d] << 15 ^ f.charCodeAt(d) + r[7 & d + 1] << 13;
  1190. for (; 8 > r.length;) r.push(0);
  1191. for (d = 0; 8 > d && 0 === r[d]; ++d);
  1192. for (a = 8 == d ? r[7] = -1 : r[d], e.x = r, e.i = 0, d = 256; 0 < d; --d) e.next()
  1193. }(f, e)
  1194. }
  1195. function r(e, f) {
  1196. return f.x = e.x.slice(), f.i = e.i, f
  1197. }
  1198. function t(e, f) {
  1199. null == e && (e = +new Date);
  1200. var d = new a(e),
  1201. t = f && f.state,
  1202. n = function() {
  1203. return (d.next() >>> 0) / 4294967296
  1204. };
  1205. return n.double = function() {
  1206. do var e = d.next() >>> 11,
  1207. f = (d.next() >>> 0) / 4294967296,
  1208. a = (e + f) / 2097152; while (0 === a);
  1209. return a
  1210. }, n.int32 = d.next, n.quick = n, t && (t.x && r(t, d), n.state = function() {
  1211. return r(d, {})
  1212. }), n
  1213. }
  1214. f && f.exports ? f.exports = t : d && d.amd ? d(function() {
  1215. return t
  1216. }) : this.xorshift7 = t
  1217. })(this, "object" == typeof d && d, "function" == typeof e && e)
  1218. }, {}],
  1219. "/Users/qrohlf/Code/trianglify/node_modules/seedrandom/lib/xorwow.js": [function(f, d) {
  1220. (function(e, f, d) {
  1221. function a(e) {
  1222. var f = this,
  1223. d = "";
  1224. f.next = function() {
  1225. var e = f.x ^ f.x >>> 2;
  1226. return f.x = f.y, f.y = f.z, f.z = f.w, f.w = f.v, 0 | (f.d = 0 | f.d + 362437) + (f.v = f.v ^ f.v << 4 ^ (e ^ e << 1))
  1227. }, f.x = 0, f.y = 0, f.z = 0, f.w = 0, f.v = 0, e === (0 | e) ? f.x = e : d += e;
  1228. for (var a = 0; a < d.length + 64; a++) f.x ^= 0 | d.charCodeAt(a), a == d.length && (f.d = f.x << 10 ^ f.x >>> 4), f.next()
  1229. }
  1230. function r(e, f) {
  1231. return f.x = e.x, f.y = e.y, f.z = e.z, f.w = e.w, f.v = e.v, f.d = e.d, f
  1232. }
  1233. function t(e, f) {
  1234. var d = new a(e),
  1235. t = f && f.state,
  1236. n = function() {
  1237. return (d.next() >>> 0) / 4294967296
  1238. };
  1239. return n.double = function() {
  1240. do var e = d.next() >>> 11,
  1241. f = (d.next() >>> 0) / 4294967296,
  1242. a = (e + f) / 2097152; while (0 === a);
  1243. return a
  1244. }, n.int32 = d.next, n.quick = n, t && ("object" == typeof t && r(t, d), n.state = function() {
  1245. return r(d, {})
  1246. }), n
  1247. }
  1248. f && f.exports ? f.exports = t : d && d.amd ? d(function() {
  1249. return t
  1250. }) : this.xorwow = t
  1251. })(this, "object" == typeof d && d, "function" == typeof e && e)
  1252. }, {}],
  1253. "/Users/qrohlf/Code/trianglify/node_modules/seedrandom/seedrandom.js": [function(f, d) {
  1254. (function(a, r) {
  1255. function t(e, f, d) {
  1256. var t = [];
  1257. f = !0 == f ? {
  1258. entropy: !0
  1259. } : f || {};
  1260. var b = i(s(f.entropy ? [e, c(a)] : null == e ? o() : e, 3), t),
  1261. h = new n(t),
  1262. x = function() {
  1263. for (var e = h.g(u), f = m, d = 0; e < y;) e = (e + d) * g, f *= g, d = h.g(1);
  1264. for (; e >= _;) e /= 2, f /= 2, d >>>= 1;
  1265. return (e + d) / f
  1266. };
  1267. return x.int32 = function() {
  1268. return 0 | h.g(4)
  1269. }, x.quick = function() {
  1270. return h.g(4) / 4294967296
  1271. }, x.double = x, i(c(h.S), a), (f.pass || d || function(e, f, d, a) {
  1272. return a && (a.S && l(a, h), e.state = function() {
  1273. return l(h, {})
  1274. }), d ? (r[p] = e, f) : e
  1275. })(x, b, "global" in f ? f.global : this == r, f.state)
  1276. }
  1277. function n(e) {
  1278. var f, d = e.length,
  1279. a = this,
  1280. r = 0,
  1281. t = a.i = a.j = 0,
  1282. n = a.S = [];
  1283. for (d || (e = [d++]); r < g;) n[r] = r++;
  1284. for (r = 0; r < g; r++) n[r] = n[t = x & t + e[r % d] + (f = n[r])], n[t] = f;
  1285. (a.g = function(e) {
  1286. for (var f, d = 0, r = a.i, t = a.j, n = a.S; e--;) f = n[r = x & r + 1], d = d * g + n[x & (n[r] = n[t = x & t + f]) + (n[t] = f)];
  1287. return a.i = r, a.j = t, d
  1288. })(g)
  1289. }
  1290. function l(e, f) {
  1291. return f.i = e.i, f.j = e.j, f.S = e.S.slice(), f
  1292. }
  1293. function s(e, f) {
  1294. var d, a = [],
  1295. r = typeof e;
  1296. if (f && "object" == r)
  1297. for (d in e) try {
  1298. a.push(s(e[d], f - 1))
  1299. } catch (f) {}
  1300. return a.length ? a : "string" == r ? e : e + "\0"
  1301. }
  1302. function i(e, f) {
  1303. for (var d, a = e + "", r = 0; r < a.length;) f[x & r] = x & (d ^= 19 * f[x & r]) + a.charCodeAt(r++);
  1304. return c(f)
  1305. }
  1306. function o() {
  1307. try {
  1308. var e;
  1309. return b && (e = b.randomBytes) ? e = e(g) : (e = new Uint8Array(g), (h.crypto || h.msCrypto).getRandomValues(e)), c(e)
  1310. } catch (r) {
  1311. var f = h.navigator,
  1312. d = f && f.plugins;
  1313. return [+new Date, h, d, h.screen, c(a)]
  1314. }
  1315. }
  1316. function c(e) {
  1317. return String.fromCharCode.apply(0, e)
  1318. }
  1319. var b, h = this,
  1320. g = 256,
  1321. u = 6,
  1322. p = "random",
  1323. m = r.pow(g, u),
  1324. y = r.pow(2, 52),
  1325. _ = 2 * y,
  1326. x = g - 1;
  1327. if (r["seed" + p] = t, i(r.random(), a), "object" == typeof d && d.exports) {
  1328. d.exports = t;
  1329. try {
  1330. b = f("crypto")
  1331. } catch (e) {}
  1332. } else "function" == typeof e && e.amd && e(function() {
  1333. return t
  1334. })
  1335. })([], Math)
  1336. }, {
  1337. crypto: !1
  1338. }]
  1339. }, {}, ["./lib/trianglify.js"])("./lib/trianglify.js")
  1340. });