const t={.4:"blue",.6:"cyan",.7:"lime",.8:"yellow",1:"red"};class a{constructor(t){this._canvas=t="string"==typeof t?document.getElementById(t):t,this._ctx=t.getContext("2d"),this._width=t.width,this._height=t.height,this._max=1,this._data=[]}data(t){return this._data=t,this}max(t){return this._max=t,this}add(t){return this._data.push(t),this}clear(){return this._data=[],this}radius(t,a=15){const i=this._circle=this._createCanvas(),e=i.getContext("2d"),h=this._r=t+a;return i.width=i.height=2*h,e.shadowOffsetX=e.shadowOffsetY=2*h,e.shadowBlur=a,e.shadowColor="black",e.beginPath(),e.arc(-h,-h,t,0,2*Math.PI,!0),e.closePath(),e.fill(),this}resize(){this._width=this._canvas.width,this._height=this._canvas.height}gradient(t){const a=this._createCanvas(),i=a.getContext("2d"),e=i.createLinearGradient(0,0,0,256);a.width=1,a.height=256;for(const a in t)e.addColorStop(+a,t[a]);return i.fillStyle=e,i.fillRect(0,0,1,256),this._grad=i.getImageData(0,0,1,256).data,this}draw(a){this._circle||this.radius(25),this._grad||this.gradient(t);const i=this._ctx;i.clearRect(0,0,this._width,this._height);for(let t,e=0,h=this._data.length;e<h;e++)t=this._data[e],i.globalAlpha=Math.min(Math.max(t[2]/this._max,void 0===a?.05:a),1),i.drawImage(this._circle,t[0]-this._r,t[1]-this._r);const e=i.getImageData(0,0,this._width,this._height);return this._colorize(e.data,this._grad),i.putImageData(e,0,0),this}_colorize(t,a){let i;for(let e=0;e<t.length;e+=4)i=4*t[e+3],i&&(t[e]=a[i],t[e+1]=a[i+1],t[e+2]=a[i+2])}_createCanvas(){return"undefined"!=typeof document?document.createElement("canvas"):new this._canvas.constructor}}export{a as Simpleheat};
//# sourceMappingURL=simpleheat.js.map
