The code is too simple, so I won’t talk nonsense
var canvas=document.getElementById("canvas ");
//Set the drawing environment
var cxt=canvas.getContext('2d');
//Open a new path
cxt.beginPath();
// Set The width of the stroke
cxt.lineWidth=10;
//Set the color of the stroke
cxt.strokeStyle="#00ff00";
//Set the position of the stroke
cxt.moveTo( 20,20);
//Set the moving position
cxt.lineTo(100,20);
//Draw a line
cxt.stroke();//The line at this time has come out
//Close the path
cxt.closePath();
//All path graphics must start the path first, and the path must end after drawing
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn