HTML canvas lineWidth Property

Introduction

Draw a rectangle with a line width of 10 pixels:

View in separate window

<!DOCTYPE html>
<html>
<body>

<canvas id="myCanvas" width="300" height="180" 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  ww w  .  j ava 2s.  c  om*/
ctx.strokeRect(20, 20, 80, 100);
</script>

</body>
</html>

The lineWidth property sets or gets the current line width, in pixels.

The lineWidth property Default value: 1

     
context.lineWidth = number;

Property Values

Value Description
number The current line width, in pixels



PreviousNext

Related