Op basis van een artikel hier wil ik iets maken.
Ik heb een paar namen welke ik wil verbinden met een lijn in 2 kleuren.
Als ik de lijn splits op 50% lukt het. Hoe kan ik echter op 60 of 75% splitsen.
function lines(d1,d2){
div1=document.getElementById(d1);
div2=document.getElementById(d2);
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
var x1 = parseInt(div1.dataset.x);
var y1 = parseInt(div1.dataset.y);
var x2 = parseInt(div2.dataset.x);
var y2 = parseInt(div2.dataset.y);
randNum = function (i) {
return Math.round(Math.random() * i * (Math.random() > 0.5 ? -1 : 1));
};
ctx.beginPath();
ctx.moveTo(x1, y1);
ctx.lineTo( x2, y2);
ctx.strokeStyle = 'white';
ctx.lineWidth = 7;
ctx.stroke();
ctx.beginPath();
ctx.moveTo((x1+x2)/2 , (y1+y2)/2);
ctx.lineTo(x2, y2);
ctx.strokeStyle = 'black';
ctx.lineWidth = 7;
ctx.stroke();
}Jan


