lineWidth Property - Javascript Canvas Reference

Javascript examples for Canvas Reference:lineWidth

Description

The lineWidth property sets or gets the current line width in pixels. Default value is 1.

JavaScript syntax

context.lineWidth = number;

Property Values

Value Description
number The current line width, in pixels

Example

Draw a rectangle with a line width of 10 pixels:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<canvas id="myCanvas" width="300" height="250" style="border:1px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.</canvas>

<script>

var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.lineWidth = 10;/*from   w ww  .j ava  2 s .  c  o m*/
ctx.strokeRect(20, 20, 80, 100);

</script>

</body>
</html>

Related Tutorials