showing results for - "take a screenshot javascript of canvas"
Domenico
21 Jan 2018
1canvas.toDataURL('png')
2
Maja
05 Aug 2017
1<!DOCTYPE HTML>
2<html>
3  <head>
4    <style>
5      body {
6        margin: 0px;
7        padding: 0px;
8      }
9    </style>
10  </head>
11  <body>
12    <canvas id="myCanvas" width="578" height="200"></canvas>
13    <script>
14      var canvas = document.getElementById('myCanvas');
15      var context = canvas.getContext('2d');
16
17      // draw cloud
18      context.beginPath();
19      context.moveTo(170, 80);
20      context.bezierCurveTo(130, 100, 130, 150, 230, 150);
21      context.bezierCurveTo(250, 180, 320, 180, 340, 150);
22      context.bezierCurveTo(420, 150, 420, 120, 390, 100);
23      context.bezierCurveTo(430, 40, 370, 30, 340, 50);
24      context.bezierCurveTo(320, 5, 250, 20, 250, 50);
25      context.bezierCurveTo(200, 5, 150, 20, 170, 80);
26      context.closePath();
27      context.lineWidth = 5;
28      context.fillStyle = '#8ED6FF';
29      context.fill();
30      context.strokeStyle = '#0000ff';
31      context.stroke();
32
33      // save canvas image as data url (png format by default)
34      var dataURL = canvas.toDataURL();
35    </script>
36  </body>
37</html>
38
Laetitia
22 Oct 2017
1<a href="%dataURI%" download>download</a>
2