69 function drawLigament(a, b) {
70 const WIDTH_FACTOR = 0.1;
71 let ligAngle = Math.angleRadians(a, b);
72 let ligCenter = Math.circupoint(a, a.width, ligAngle);
73 let ligOpposite = Math.circupoint(b, b.width, Math.angleRadians(b, a));
74 let ligA = Math.circupoint(a, a.width, ligAngle - Math.PI * WIDTH_FACTOR);
75 let ligB = Math.circupoint(a, a.width, ligAngle + Math.PI * WIDTH_FACTOR);
76
77 let apex = ligOpposite;
78 ctx.beginPath();
79
80 ctx.moveTo(ligB.x, ligB.y);
81 ctx.quadraticCurveTo(ligCenter.x, ligCenter.y, apex.x, apex.y);
82 ctx.quadraticCurveTo(ligCenter.x, ligCenter.y, ligA.x, ligA.y);
83 ctx.lineWidth = 1;
84 ctx.stroke();
85
86 let gradient = ctx.createLinearGradient(ligCenter.x, ligCenter.y, ligOpposite.x, ligOpposite.y);
87 gradient.addColorStop(0, fillStyleForDepth(a.depth));
88 gradient.addColorStop(1, fillStyleForDepth(b.depth));
89 ctx.fillStyle = gradient;
90 ctx.fill();
91 }