English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
lineWidth is a Canvas 2D API sets the property for line thickness (i.e., the width of the line).
Using a width of 12 Draw rectangles with lines of pixels:
<!DOCTYPE html> <html> <head> <title>HTML canvas lineWidth property usage (Basic Tutorial Website oldtoolbag.com)</title> </head> <body> <canvas id="myCanvas" width="300" height="150" style="border:1px solid #d3d3d3"> Your browser does not support HTML5 canvas tag. </canvas> <script> var c=document.getElementById("myCanvas"); var ctx=c.getContext("2d"); ctx.lineWidth=12; ctx.strokeRect(20,20,80,100); </script> </body> </html>Test See ‹/›
IEFirefoxOperaChromeSafari
Internet Explorer 9Firefox, Opera, Chrome, and Safari support the lineWidth property.
Note:Internet Explorer 8 and earlier versions do not support the <canvas> element.
The lineWidth property sets or returns the current line width in pixels.
Default Value: | 1 |
---|---|
JavaScript Syntax: | context.lineWidth=number; |
Value | Description |
---|---|
number | The current line width, in pixels. |