Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

take a screenshot javascript of canvas

canvas.toDataURL('png')
Comment

take a screenshot javascript of canvas

<!DOCTYPE HTML>
<html>
  <head>
    <style>
      body {
        margin: 0px;
        padding: 0px;
      }
    </style>
  </head>
  <body>
    <canvas id="myCanvas" width="578" height="200"></canvas>
    <script>
      var canvas = document.getElementById('myCanvas');
      var context = canvas.getContext('2d');

      // draw cloud
      context.beginPath();
      context.moveTo(170, 80);
      context.bezierCurveTo(130, 100, 130, 150, 230, 150);
      context.bezierCurveTo(250, 180, 320, 180, 340, 150);
      context.bezierCurveTo(420, 150, 420, 120, 390, 100);
      context.bezierCurveTo(430, 40, 370, 30, 340, 50);
      context.bezierCurveTo(320, 5, 250, 20, 250, 50);
      context.bezierCurveTo(200, 5, 150, 20, 170, 80);
      context.closePath();
      context.lineWidth = 5;
      context.fillStyle = '#8ED6FF';
      context.fill();
      context.strokeStyle = '#0000ff';
      context.stroke();

      // save canvas image as data url (png format by default)
      var dataURL = canvas.toDataURL();
    </script>
  </body>
</html>
Comment

take a screenshot javascript of canvas

<a href="%dataURI%" download>download</a>
Comment

PREVIOUS NEXT
Code Example
Javascript :: event in javascript 
Javascript :: javascript test cases 
Javascript :: promise definition in javascript 
Javascript :: js add event listener 
Javascript :: arrow functions syntax 
Javascript :: toast not showing 
Javascript :: update property of object in array javascript 
Javascript :: web storage api 
Javascript :: byte array to json 
Javascript :: add select option jquery 
Javascript :: javascript weakmap 
Javascript :: javascript eval alternative 
Javascript :: base64 to base64url javascript 
Javascript :: The Lodash Array Remove Method 
Javascript :: string in js 
Javascript :: vscode react snippets 
Javascript :: array of 
Javascript :: Iterating or loop through the elements of an array is with a for loop (for): 
Javascript :: solidity payable 
Javascript :: const in javascript 
Javascript :: js push multiple arguments 
Javascript :: js sort array 
Javascript :: javaScript disable submit button until form is fully validated 
Javascript :: React Hook "useState" is called in function which is neither a React function component or a custom React Hook functio 
Javascript :: object object js 
Javascript :: javascript pass this to callback 
Javascript :: react using object as prop 
Javascript :: how we can set react select required 
Javascript :: pass array as function argument javascript 
Javascript :: redux toolkit reducer 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =