Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use Canvas to draw straight lines in ​ in html5

Shulou Source: shulou.com Published: 2022-06-01 11:06:52 10月01日 Update

This article mainly introduces "how to use Canvas to draw straight lines in html5". In daily operation, I believe many people have doubts about how to use Canvas to draw straight lines in html5. The editor consulted all kinds of data and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about "how to draw straight lines with Canvas in html5". Next, please follow the editor to study!

Use Canvas to draw lines:

XML/HTML Code copies content to the clipboard

Html >

Canvas {border:dashed?2px?#CCC}

Function?$$ (id) {

Return?document.getElementById (id)

}

Function?pageLoad () {

Varcan=?$$ ('can')

Varcancans=?can.getContext ('2d')

Cans.moveTo (20 and 30); / / the first starting point

Cans.lineTo (120men90); / / second point

Cans.lineTo (220, 060); / / the third point (starting with the second point)

Cans.lineWidth=3

Cans.strokeStyle='red'

Cans.stroke ()

}

At this point, the study on "how to use Canvas to draw straight lines in html5" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Straight line learning more starting point help practical next three content clipboard articles methods theory knowledge articles websites materials follow questions easy to use Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS OPPO Reno Microsoft vpn Huawei