Example of Setting Canvas Stroke Cap Style - Javascript Canvas

Javascript examples for Canvas:Stroke


Example of Setting Canvas Stroke Cap Style

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html lang="en">
  <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;
  <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);
  <canvas id="myCanvas" width="300" height="200"></canvas>   

Related Tutorials