simpler-dash/hp_assets/js/trianglify.min.js

1 line
45 KiB
JavaScript
Raw Normal View History

(function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;f="undefined"==typeof window?"undefined"==typeof global?"undefined"==typeof self?this:self:global:window,f.Trianglify=e()}})(function(){var e,f=Math.max,d=Math.sqrt,a=Math.abs,n=Math.floor;return function d(c,e,n){function f(i,o){if(!e[i]){if(!c[i]){var r="function"==typeof require&&require;if(!o&&r)return r(i,!0);if(t)return t(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var s=e[i]={exports:{}};c[i][0].call(s.exports,function(d){var e=c[i][1][d];return f(e?e:d)},s,s.exports,d,c,e,n)}return e[i].exports}for(var t="function"==typeof require&&require,a=0;a<n.length;a++)f(n[a]);return f}({"./lib/trianglify.js":[function(e,f){function d(e){function f(e,f,d){return(e-f[0])*(d[1]-d[0])/(f[1]-f[0])+d[0]}function d(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 s(){if(e.palette instanceof Array)return e.palette[n(b()*e.palette.length)];var f=Object.keys(e.palette);return e.palette[f[n(b()*f.length)]]}var b;if(e=function(e,f){var d={};for(var a in e)d[a]=e[a];for(a in f)if(e.hasOwnProperty(a))d[a]=f[a];else throw new Error(a+" is not a configuration option for Trianglify. Check your spelling?");return d}(c,e),b=t(e.seed),"random"===e.x_colors&&(e.x_colors=s()),"random"===e.y_colors&&(e.y_colors=s()),"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");if(2>e.cell_size)throw new Error("Cell size must be greater than 2.");var h;if(e.color_function)h=function(f,d){return o(e.color_function(f,d))};else{var u=o.scale(e.x_colors).mode(e.color_space),g=o.scale(e.y_colors).mode(e.color_space);h=function(f,d){return o.interpolate(u(f),g(d),0.5,e.color_space)}}for(var p=e.width,m=e.height,y=n((p+4*e.cell_size)/e.cell_size),x=n((m+4*e.cell_size)/e.cell_size),_=(y*e.cell_size-p)/2,k=(x*e.cell_size-m)/2,w=e.cell_size*e.variance/2,j=function(e){return f(e,[-_,p+_],[0,1])},v=function(e){return f(e,[-k,m+k],[0,1])},z=e.points||r(p,m,_,k,e.cell_size,w,b),B=new a(z).triangles,S=[],G=function(e){return z[e]},P=0;P<B.length;P+=3){var i=[B[P],B[P+1],B[P+2]].map(G),R=d(i),A=h(j(R.x),v(R.y)).hex();S.push([A,i])}return l(S,e)}var a=e("delaunator"),t=e("seedrandom"),o=e("chroma-js"),i=e("./colorbrewer"),r=e("./points"),l=e("./pattern"),c={width:600,height:400,cell_size:75,variance:0.75,seed:null,x_colors:"random",y_colors:"match_x",palette:i,color_space:"lab",color_function:null,stroke_width:1.51,points:void 0};d.colorbrewer=i,d.defaults=c,f.exports=d},{"./colorbrewer":"/home/fmauneko/code/trianglify/lib/colorbrewer.js","./pattern":"/home/fmauneko/code/trianglify/lib/pattern.js","./points":"/home/fmauneko/code/trianglify/lib/points.js","chroma-js":"/home/fmauneko/code/trianglify/node_modules/chroma-js/chroma.js",delaunator:"/home/fmauneko/code/trianglify/node_modules/delaunator/index.js",seedrandom:"/home/fmauneko/code/trianglify/node_modules/seedrandom/index.js"}],"/home/fmauneko/code/trianglify/lib/colorbrewer.js":[function(e,f){f.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","#f