Merge pull request #12 from flokli/startAngle
use node_id hash to calculate startAngle for client layer
This commit is contained in:
commit
7f74fff992
3
app.js
3
app.js
@ -13,7 +13,8 @@ require.config({
|
||||
"numeral-intl": "../bower_components/numeraljs/min/languages.min",
|
||||
"virtual-dom": "../bower_components/virtual-dom/dist/virtual-dom",
|
||||
"rbush": "../bower_components/rbush/rbush",
|
||||
"helper": "../helper"
|
||||
"helper": "../helper",
|
||||
"jshashes": "../bower_components/jshashes/hashes"
|
||||
},
|
||||
shim: {
|
||||
"leaflet.label": ["leaflet"],
|
||||
|
@ -24,7 +24,8 @@
|
||||
"roboto-fontface": "~0.3.0",
|
||||
"virtual-dom": "~2.0.1",
|
||||
"leaflet-providers": "~1.0.27",
|
||||
"rbush": "https://github.com/mourner/rbush.git#~1.3.5"
|
||||
"rbush": "https://github.com/mourner/rbush.git#~1.3.5",
|
||||
"jshashes": "~1.0.5"
|
||||
},
|
||||
"authors": [
|
||||
"Nils Schneider <nils@nilsschneider.net>"
|
||||
|
@ -1,8 +1,16 @@
|
||||
define(["leaflet"],
|
||||
function (L) {
|
||||
define(["leaflet", "jshashes"],
|
||||
function (L, jsHashes) {
|
||||
var MD5 = new jsHashes.MD5()
|
||||
|
||||
return L.TileLayer.Canvas.extend({
|
||||
setData: function (d) {
|
||||
this.data = d
|
||||
|
||||
//pre-calculate start angles
|
||||
this.data.all().forEach(function (d) {
|
||||
var hash = MD5.hex(d.node.nodeinfo.node_id)
|
||||
d.startAngle = (parseInt(hash.substr(0, 2), 16) / 255) * 2 * Math.PI
|
||||
})
|
||||
this.redraw()
|
||||
},
|
||||
drawTile: function (canvas, tilePoint) {
|
||||
@ -33,7 +41,6 @@ define(["leaflet"],
|
||||
var radius = 3
|
||||
var a = 1.2
|
||||
var startDistance = 12
|
||||
var startAngle = Math.PI
|
||||
|
||||
ctx.beginPath()
|
||||
nodes.forEach(function (d) {
|
||||
@ -47,6 +54,7 @@ define(["leaflet"],
|
||||
p.y -= s.y
|
||||
|
||||
var distance = startDistance
|
||||
var startAngle = d.startAngle
|
||||
var angle = startAngle
|
||||
|
||||
for (var i = 0; i < clients; i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user