Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add a way to render without smoothing. much faster. uglier as well.

  • Loading branch information...
commit 57b36ad1a63e9cd3c3d271f1f16539d946d49c94 1 parent 648ca0d
mpd authored
Showing with 9 additions and 7 deletions.
  1. +2 −1  heatmap.html
  2. +4 −4 heatmap.js
  3. +3 −2 render_worker.js
View
3  heatmap.html
@@ -7,7 +7,8 @@
<img id="trackme" src="img.jpg" />
</div>
- <button type="button" id="doRender">RENDER</button>
+ <button type="button" id="doRender">RENDER with smoothing</button>
+ <button type="button" id="doRenderWithoutSmoothing">RENDER without smoothing (faster)</button>
<div id="render-time">
Render Time: <span class="time">0</span> sec
</div>
View
8 heatmap.js
@@ -21,7 +21,7 @@ $(function () {
renderHeat(JSON.parse(event.data).heat);
$('#render-time .time').text((new Date().getTime() - renderStartTime) / 1000);
renderStartTime = 0;
- $('#doRender').removeAttr('disabled');
+ $('#doRender, #doRenderWithoutSmoothing').removeAttr('disabled');
};
// mask we apply to a point that is moused over.
@@ -196,10 +196,10 @@ $(function () {
return cache.hueToRGB[cachekey];
};
- $('#doRender').click(function (e) {
- $(this).attr('disabled', 'disabled');
+ $('#doRender, #doRenderWithoutSmoothing').click(function (e) {
+ $('#doRender, #doRenderWithoutSmoothing').attr('disabled', 'disabled');
renderStartTime = new Date().getTime();
- worker.postMessage(JSON.stringify({heat: heat, width: canvasWidth, height: canvasHeight}));
+ worker.postMessage(JSON.stringify({heat: heat, width: canvasWidth, height: canvasHeight, smoothing: $(this).is('#doRender')}));
e.preventDefault();
});
View
5 render_worker.js
@@ -2,10 +2,11 @@
var smoothHeat, normalizeHeat, canvasWidth, canvasHeight;
onmessage = function (event) {
- var data = JSON.parse(event.data);
+ var data = JSON.parse(event.data), result;
canvasWidth = data.width;
canvasHeight = data.height;
- postMessage(JSON.stringify({heat: normalizeHeat(smoothHeat(data.heat))}));
+ result = data.smoothing ? normalizeHeat(smoothHeat(data.heat)) : normalizeHeat(data.heat);
+ postMessage(JSON.stringify({heat: result}));
};
Please sign in to comment.
Something went wrong with that request. Please try again.