@zsoltc/gradient-generator
Version:
Color gradient generator
1 lines • 2.12 kB
JavaScript
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n;"undefined"!=typeof window?n=window:"undefined"!=typeof global?n=global:"undefined"!=typeof self&&(n=self),n.WorleyNoise=t()}}(function(){return function t(n,e,o){function r(u,f){if(!e[u]){if(!n[u]){var a="function"==typeof require&&require;if(!f&&a)return a(u,!0);if(i)return i(u,!0);var s=new Error("Cannot find module '"+u+"'");throw s.code="MODULE_NOT_FOUND",s}var p=e[u]={exports:{}};n[u][0].call(p.exports,function(t){var e=n[u][1][t];return r(e?e:t)},p,p.exports,t,n,e,o)}return e[u].exports}for(var i="function"==typeof require&&require,u=0;u<o.length;u++)r(o[u]);return r}({1:[function(t,n){function e(t){this._numPoints=t||0,this._init()}function o(t,n){return t*t+n*n}function r(t,n){return Math.abs(t)+Math.abs(n)}e.prototype.addPoint=function(t,n){this._points[this._numPoints++]={x:t,y:n}},e.prototype.getEuclidean=function(t,n,e){return Math.sqrt(this._calculateValue(t,n,e,o))},e.prototype.getManhattan=function(t,n,e){return this._calculateValue(t,n,e,r)},e.prototype.getMap=function(t,n){function e(t){return Math.sqrt(p._calculateValue(u*a,f*a,t,o))}function i(t){return p._calculateValue(u*a,f*a,t,r)}var u,f,a=1/(t-1),s=[],p=this;for(n=n||function(t){return t(1)},f=0;t>f;++f)for(u=0;t>u;++u)s[f*t+u]=n(e,i);return s},e.prototype.getNormalizedMap=function(t,n){var e,o,r=this.getMap(t,n),i=Number.POSITIVE_INFINITY,u=Number.NEGATIVE_INFINITY;for(o=0;o<r.length;++o)i=Math.min(i,r[o]),u=Math.max(u,r[o]);for(e=1/(u-i),o=0;o<r.length;++o)r[o]=(r[o]-i)*e;return r},e.prototype._init=function(){var t;for(this._points=[],t=0;t<this._numPoints;++t)this._points.push({x:Math.random(),y:Math.random()})},e.prototype._calculateValue=function(t,n,e,o){var r,i,u,f,a;for(f=0;f<this._numPoints;++f)this._points[f].selected=!1;for(a=0;e>a;++a){for(r=Number.POSITIVE_INFINITY,f=0;f<this._numPoints;++f)i=o(t-this._points[f].x,n-this._points[f].y),r>i&&!this._points[f].selected&&(r=i,u=f);this._points[u].selected=!0}return r},n.exports=e},{}]},{},[1])(1)});