Created
May 20, 2014 15:03
-
-
Save Southclaws/7651a5eb903356d00000 to your computer and use it in GitHub Desktop.
Generates a heatmap from coordinates loaded from "coords-list.txt".
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var heatmap = require('heatmap'); | |
var fs = require('fs'); | |
var heat = heatmap(6000, 6000, { radius : 30 }); | |
fs.readFile('coords-list.txt', 'utf8', function(error, data) | |
{ | |
var arr = data.split("\r\n"); | |
for (var i = 0; i < arr.length; i++) | |
{ | |
var xy = arr[i].split(", "); | |
console.log("x: "+(parseInt(xy[0]) + 3000)+" y: "+(6000 - (parseInt(xy[1]) + 3000))); | |
heat.addPoint(parseInt(xy[0]) + 3000, 6000 - (parseInt(xy[1]) + 3000)); | |
}; | |
console.log("executing: heat.draw"); | |
heat.draw(); | |
console.log("executing: fs.writeFileSync"); | |
fs.writeFileSync('blob.png', heat.canvas.toBuffer()); | |
console.log("Done!"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment