function drawNode()

in web/js/render.js [11:45]


function drawNode(graph, node) {
    const x = node.x
    const y = node.y
    // console.log(`About to draw node ${node.id} at ${x}, ${y}`)

    const ctx = graph.canvas.getContext("2d")
    const radius = graph.NODE_RADIUS
    ctx.beginPath()
    ctx.fillStyle = getFillStyle(graph, node)
    ctx.strokeStyle = util.inverthex(ctx.fillStyle)
    let actualRadius = radius
    if (node.hover || node.selected) {
        ctx.lineWidth = 5
        actualRadius = actualRadius + 5
    } else {
        ctx.lineWidth = 2
    }
    ctx.arc(x, y, actualRadius, 0, 2 * Math.PI)
    ctx.stroke()
    ctx.fill()
    //const textColor = "#" + util.rgbhex(complement(util.hexrgb(ctx.fillStyle)))
    // const textColor = util.inverthex(ctx.fillStyle)
    const textColor = util.getTextColor(ctx.fillStyle)
    // console.log(`${ctx.fillStyle} -> ${textColor}`)
    ctx.strokeStyle = textColor
    ctx.fillStyle = textColor
    ctx.lineWidth = 1
    ctx.font = "normal 9pt Arial"
    if (node.selected) {
        ctx.font = "bold 9pt Arial"
    }
    ctx.textAlign = "center"
    ctx.fillText(node.properties.name, x, y + 5)

}