+ 1

In html canvas,when u draw a line can u change its collor?

HTML canvas question.

22nd Dec 2018, 6:22 PM
TOXIC dz
TOXIC dz - avatar
2 Respuestas
+ 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>
22nd Dec 2018, 6:38 PM
Mayank Dhillon
Mayank Dhillon - avatar
0
Thank u so much.
22nd Dec 2018, 9:12 PM
TOXIC dz
TOXIC dz - avatar