Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions simpleheat.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ simpleheat.prototype = {
},

draw: function (minOpacity) {
//return if width or height invalid
if (!this._width || !this._height) return this;

// colorize the heatmap, using opacity value of each pixel to get the right color from our gradient
if (!this._circle) this.radius(this.defaultRadius);
if (!this._grad) this.gradient(this.defaultGradient);

Expand All @@ -110,10 +114,9 @@ simpleheat.prototype = {
ctx.drawImage(this._circle, p[0] - this._r, p[1] - this._r);
}

// colorize the heatmap, using opacity value of each pixel to get the right color from our gradient
var colored = ctx.getImageData(0, 0, this._width, this._height);
this._colorize(colored.data, this._grad);
ctx.putImageData(colored, 0, 0);
ctx.putImageData(colored, 0, 0);

return this;
},
Expand All @@ -139,4 +142,5 @@ simpleheat.prototype = {
return new this._canvas.constructor();
}
}

};