+ 1
In html canvas,when u draw a line can u change its collor?
HTML canvas question.
2 ответов
+ 3
yes you can by using stroke method
<html>
<head>
</head>
<body>
<canvas id="myCanvas" width="578" height="200"></canvas>
<script>
var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');
context.beginPath();
context.moveTo(100, 10);
context.lineTo(450, 10);
context.lineWidth = 10;
// set line color by
context.strokeStyle = '#9966ff';
context.stroke();
</script>
</body>
</html>
0
Thank u so much.