rework client drawing code
This commit is contained in:
parent
d170204b31
commit
4d69677ede
@ -288,27 +288,24 @@ define(["d3"], function (d3) {
|
||||
if (clients === 0)
|
||||
return
|
||||
|
||||
var distance = 16
|
||||
var startDistance = 16
|
||||
var radius = 3
|
||||
var a = 1.2
|
||||
var startAngle = Math.PI
|
||||
var angle = startAngle
|
||||
|
||||
for (var i = 0; i < clients; i++) {
|
||||
if ((angle - startAngle) > 2 * Math.PI) {
|
||||
angle = startAngle
|
||||
distance += 2 * radius * a
|
||||
}
|
||||
|
||||
var x = d.x + distance * Math.cos(angle)
|
||||
var y = d.y + distance * Math.sin(angle)
|
||||
|
||||
ctx.moveTo(x, y)
|
||||
ctx.arc(x, y, radius, 0, 2 * Math.PI)
|
||||
|
||||
for (var orbit = 0, i = 0; i < clients; orbit++) {
|
||||
var distance = startDistance + orbit * 2 * radius * a
|
||||
var n = Math.floor((Math.PI * distance) / (a * radius))
|
||||
var angleDelta = 2 * Math.PI / n
|
||||
angle += angleDelta
|
||||
var delta = clients - i
|
||||
|
||||
for (var j = 0; j < Math.min(delta, n); i++, j++) {
|
||||
var angle = 2 * Math.PI / n * j
|
||||
var x = d.x + distance * Math.cos(angle + startAngle)
|
||||
var y = d.y + distance * Math.sin(angle + startAngle)
|
||||
|
||||
ctx.moveTo(x, y)
|
||||
ctx.arc(x, y, radius, 0, 2 * Math.PI)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -53,25 +53,19 @@ define(["leaflet", "jshashes"],
|
||||
p.x -= s.x
|
||||
p.y -= s.y
|
||||
|
||||
var distance = startDistance
|
||||
var startAngle = d.startAngle
|
||||
var angle = startAngle
|
||||
|
||||
for (var i = 0; i < clients; i++) {
|
||||
if ((angle - startAngle) > 2 * Math.PI) {
|
||||
angle = startAngle
|
||||
distance += 2 * radius * a
|
||||
}
|
||||
|
||||
var x = p.x + distance * Math.cos(angle)
|
||||
var y = p.y + distance * Math.sin(angle)
|
||||
|
||||
ctx.moveTo(x, y)
|
||||
ctx.arc(x, y, radius, 0, 2 * Math.PI)
|
||||
|
||||
for (var orbit = 0, i = 0; i < clients; orbit++) {
|
||||
var distance = startDistance + orbit * 2 * radius * a
|
||||
var n = Math.floor((Math.PI * distance) / (a * radius))
|
||||
var angleDelta = 2 * Math.PI / n
|
||||
angle += angleDelta
|
||||
var delta = clients - i
|
||||
|
||||
for (var j = 0; j < Math.min(delta, n); i++, j++) {
|
||||
var angle = 2 * Math.PI / n * j
|
||||
var x = p.x + distance * Math.cos(angle + d.startAngle)
|
||||
var y = p.y + distance * Math.sin(angle + d.startAngle)
|
||||
|
||||
ctx.moveTo(x, y)
|
||||
ctx.arc(x, y, radius, 0, 2 * Math.PI)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user