HTML5 lineJoin Property | lineJoin attributes of HTML5 canvas line

In this Html5 canvas tutorial we will discuss how to set lineJoin attributes of Html5 canvas line. Html5 Canvas lineJoin attributes and How to set lineJoin attributes using html5 Canvas will be presented here in this htm5 tutortial. Lets start with lineJoin Introduction. When two lines meets a corner is created.This meeting of two line in canvs is called lineJoin.

There are three types of lineJoin:

  • miter
  • bevel
  • round

the code for the lineJoin is given

context.lineJoin =type-of-lineJoin;


shape of lineJoin

html5 Canvas lineJoin attributes


1. miter

This is the default type of lineJoin in canvas.An edge is drawn at the join.
The maximum allowed ratio of miter length to line width is called miterLimit.
Its default value is 10.
The code to set lineJoin miter is


The shape of miter is given


2. bevel

The second type of lineJoin is bevel.In bevel a diagonal is drawn
at the join.The code to set lineJoin bevel is given following.

context.lineJoin ="bevel";

The shape of bevel lineJoin is given under.

bevel shape

lineJoin-bevel html5 Canvas


3. round

The third type of line join is called round.
In this join a round edge is drawn at the join.
The code for the round lineJoin is given.

context.lineJoin ="round";


round shape


html5 Canvas lineJoin attributes complete code example


            <title>The type of lineJoin.</title>
            <canvas id="myCanvas" width="600" height="200"
            style="border: 1px solid black">

             var canvas  = document.getElementById("myCanvas");
             var context = canvas.getContext("2d");

                 context.strokeStyle = "black";
                 context.lineWidth   = 30;
                 // bevel lineJoin
                 context.lineJoin    = 'bevel';
                 // round lineJoin
                 context.lineJoin    = 'round';
                 // miter lineJoin
                 context.lineJoin    = 'miter';




HTML5 lineJoin attributes of html5 canvasline



Live Demo lineJoin attributes of html5 canvas line


[codepen_embed height=500 theme_id=1 slug_hash=’ZYyoaG’ user=’aslamwaqar’ default_tab=’html’



Next Article step by step tutorial of this course.

Author: Habibullah Qamar

Its me Habib Ullah Qamar working as a Lecturer (Computer Sciences) in Pakistan. I have an MS(M.Phil) degree in computer sciences with specialization in software engineering from Virtual University of Pakistan Lahore. I have an experience of more than 15 years in the filed of Computer Science as a teacher. Blog Writing is my passion. I have many blogs, This one is special made with the aim of providing 100% Free online coaching and training to the students of under-graduate and postgraduate classes. Most of the students enrolled in computer sciences, information technology, software engineering and related disciplines find it difficult to understand core concepts of programming and office automation. They find difficult in understanding and solving their assignments.

Leave a Reply

Your email address will not be published. Required fields are marked *