How to draw two lines with diffrrent color that start from the same point in JavaScript

1 Answer

0 votes
<canvas id="canvas" width="1024" height="600"></canvas>
<script type="text/JavaScript">   

var ctx = document.getElementById('canvas').getContext('2d');

ctx.beginPath();
ctx.strokeStyle = 'blue';
ctx.moveTo(30, 30);
ctx.lineTo(200, 30);
ctx.stroke();

ctx.beginPath();
ctx.strokeStyle = 'red';
ctx.moveTo(30, 30);
ctx.lineTo(130, 130);
ctx.stroke();

</script>

 



answered May 27, 2016 by avibootz
...