-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.js
More file actions
26 lines (21 loc) · 780 Bytes
/
setup.js
File metadata and controls
26 lines (21 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
let cTool ;
let canvasBoard = document.querySelector("canvas");
let tool = canvasBoard.getContext("2d");
// console.log(tool);
let body = document.querySelector("body");
let download = document.querySelector("#download");
// canvas dimesnions set karne ke baad jo changes karoge wahi reflect
canvasBoard.height = window.innerHeight;
canvasBoard.width = window.innerWidth;
tool.fillStyle = "white";
tool.fillRect(0, 0, canvasBoard.width, canvasBoard.height);
tool.strokeStyle = "black";
//download logic
download.addEventListener("click", (e) => {
//toDataURL method converts all graphics on the window of browser into a url
let url = canvasBoard.toDataURL();
let a = document.createElement("a");
a.href = url;
a.download = "board.jpg";
a.click();
})