forcegraph: node shadow hi-dpi fix
This commit is contained in:
parent
8b10d2ec10
commit
22e2c6d3c5
@ -252,6 +252,7 @@ define(["d3"], function (d3) {
|
||||
}
|
||||
|
||||
function redraw() {
|
||||
var r = window.devicePixelRatio
|
||||
var translate = zoomBehavior.translate()
|
||||
var scale = zoomBehavior.scale()
|
||||
var links = intLinks.filter(visibleLinks)
|
||||
@ -307,11 +308,11 @@ define(["d3"], function (d3) {
|
||||
// -- draw nodes --
|
||||
|
||||
var node = document.createElement("canvas")
|
||||
node.width = scale * nodeRadius * 8
|
||||
node.width = scale * nodeRadius * 8 * r
|
||||
node.height = node.width
|
||||
|
||||
var nctx = node.getContext("2d")
|
||||
nctx.scale(scale, scale)
|
||||
nctx.scale(scale * r, scale * r)
|
||||
nctx.save()
|
||||
|
||||
nctx.translate(-node.width / scale, -node.height / scale)
|
||||
@ -324,17 +325,17 @@ define(["d3"], function (d3) {
|
||||
nctx.strokeStyle = "rgba(255, 0, 0, 1)"
|
||||
nctx.shadowOffsetX = node.width * 1.5 + 0
|
||||
nctx.shadowOffsetY = node.height * 1.5 + 3
|
||||
nctx.shadowBlur = 6
|
||||
nctx.shadowColor = "rgba(0, 0, 0, 0.32)"
|
||||
nctx.shadowBlur = 12
|
||||
nctx.shadowColor = "rgba(0, 0, 0, 0.16)"
|
||||
nctx.stroke()
|
||||
nctx.shadowOffsetX = node.width * 1.5 + 0
|
||||
nctx.shadowOffsetY = node.height * 1.5 + 3
|
||||
nctx.shadowBlur = 6
|
||||
nctx.shadowColor = "rgba(0, 0, 0, 0.46)"
|
||||
nctx.shadowBlur = 12
|
||||
nctx.shadowColor = "rgba(0, 0, 0, 0.23)"
|
||||
nctx.stroke()
|
||||
|
||||
nctx.restore()
|
||||
nctx.translate(node.width / 2 / scale, node.height / 2 / scale)
|
||||
nctx.translate(node.width / 2 / scale / r, node.height / 2 / scale / r)
|
||||
|
||||
nctx.beginPath()
|
||||
nctx.moveTo(nodeRadius, 0)
|
||||
@ -345,9 +346,9 @@ define(["d3"], function (d3) {
|
||||
nctx.stroke()
|
||||
|
||||
ctx.save()
|
||||
ctx.scale(1 / scale, 1 / scale)
|
||||
ctx.scale(1 / scale / r, 1 / scale / r)
|
||||
nodes.filter(visibleNodes).forEach(function (d) {
|
||||
ctx.drawImage(node, scale * d.x - node.width / 2, scale * d.y - node.height / 2)
|
||||
ctx.drawImage(node, scale * r * d.x - node.width / 2, scale * r * d.y - node.height / 2)
|
||||
})
|
||||
ctx.restore()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user