Example of Setting Canvas Stroke Cap Style - Javascript Canvas

Javascript examples for Canvas:Stroke

Description

Example of Setting Canvas Stroke Cap Style

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html lang="en">
 <head> 
  <meta charset="UTF-8"> 
  <title>Example of Setting Stroke Cap Style</title> 
  <style type="text/css">
  canvas{//from   w ww .  ja  va 2s.  com
    border: 1px solid #000;
  }
</style> 
  <script type="text/javascript">
    window.onload = function(){
        var canvas = document.getElementById("myCanvas");
        var context = canvas.getContext("2d");
        context.lineWidth = 10;
        context.strokeStyle = "orange";
        context.lineCap = "round";
        context.arc(150, 150, 80, 1.2 * Math.PI, 1.8 * Math.PI, false);
        context.stroke();
    };
</script> 
 </head> 
 <body> 
  <canvas id="myCanvas" width="300" height="200"></canvas>   
 </body>
</html>

Related Tutorials