forked from smaranjitghose/doc2pen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
painter.html
106 lines (99 loc) · 5.97 KB
/
painter.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<!DOCTYPE html>
<html lang="en">
<head>
<!--- Meta Tags for SEO --->
<title>Doc2pen</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="shortcut icon" type="image/png" href="assets/images/favicon.png">
<!--Import Google Icon Font-->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Dancing+Script:wght@700&display=swap" rel="stylesheet">
<!--Importing JQUERY-->
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
<!--Import Font-->
<link href='https://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet'>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<!--Getting our CSS-->
<link rel="stylesheet" href="assets/css/painter.css">
<link rel="stylesheet" type="text/css" href="assets/css/style.css" />
</head>
<body>
<!--Navigation Bar is loaded dynamically from the main.js-->
<div class="nav-back"></div>
<div class="container">
<div class="row">
<div class="col-md-8">
<div class="row-top">
<div class="picker">
<input class="input" id="colorPicker" value="#000000" data-jscolor="" />
<div> Pen </div>
</div>
<!-- <label for="pen-size">Move</label> -->
<button class="neu pan" id="pan" onclick="toggleMode(modes.pan)">Move <i class="fa fa-arrows-alt" aria-hidden="true"></i></button>
<button class="neu pen" id="pen" onclick="toggleMode(modes.drawing)">Draw <i class="fas fa-pen"></i></button>
<label for="pen-size">Size</label>
<input type="range" id="pen-size" value=1 min="1" max="50">
<button class="neu" onclick="createRectangle(canvas)"><i class="fas fa-square"></i></button>
<button class="neu" onclick="createCircle(canvas)"><i class="fas fa-circle"></i></button>
<button class="neu" onclick="createTriangle(canvas)"><i class="fas fa-caret-up"></i></button>
<button class="neu" onclick="setText()"><i class="fas fa-text-width"></i></button>
<!-- <p><input class="neu" id="canvasColor"value="#ffffff" data-jscolor="" >Canvas</p> -->
<div class="picker">
<input class="input" id="canvasColor" data-jscolor="{preset:'myPreset'}" />
<div> Canvas </div>
</div>
</div>
<!-- Canvas is created by assest/js/painter.js file -->
<canvas id="canvas"></canvas>
<input type="file" id="imageFile" accept="image/*">
<button class="neu" onclick="groupObjects(canvas,group,true)">Group</button>
<button class="neu" onclick="groupObjects(canvas,group,false)">Ungroup</button>
<button class="neu" onclick="clearCanvas(canvas,svgState)">Redraw</button>
<button class="neu" onclick="doCapture()">Save</button>
</div>
<div class="col-md-4 right"><h1>Paint your own design.</h1></div>
</div>
</div>
<!-- For saving the canvas -->
<script>
const myCanvas = document.getElementById("canvas")
function doCapture(){
//For Ie/edge browsers
if(window.navigator.msSaveBlob){
window.navigator.msSaveBlob(myCanvas.msToBlob(),"canvas-image.png")
} else{
var canvas = document.getElementById("canvas");
canvas.toBlob(function(blob) {
saveAs(blob, "sketch.png");
});
}
}
</script>
<script src="assets/lib/jscolor.js"></script>
<script>
jscolor.presets.myPreset = {
format: 'hex',
width: 201,
height: 81,
backgroundColor: '#333',
palette: '#fff #000 #808080 #996e36 #f55525 #ffe438 #88dd20 #22e0cd #269aff #bb1cd4',
}
</script>
<!-- Using for saving the canvas (FileSaver.js) -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.0/FileSaver.min.js" integrity="sha512-csNcFYJniKjJxRWRV1R7fvnXrycHP6qDR21mgz1ZP55xY5d+aHLfo9/FcGDQLfn2IfngbAHd8LdfsagcCqgTcQ==" crossorigin="anonymous"></script>
<!-- Fabric.js main library -->
<script src="assets/lib/fabricMin.js"></script>
<!--JS File for dynamically loading navigation bar, footer, Team Section-->
<script src="assets/js/jquery.js"></script>
<script src="assets/js/main.js"></script>
<script src="assets/js/painter.js"></script>
<!-- Footer is loaded dynamically from main.js-->
</body>
</html>