-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
227 lines (185 loc) · 7.63 KB
/
index.html
File metadata and controls
227 lines (185 loc) · 7.63 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<!DOCTYPE html>
<html>
<head>
<title>Pixel Art Maker!</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- jquery cdn -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!-- google cdn -->
<link href="https://fonts.googleapis.com/css?family=Roboto+Slab" rel="stylesheet">
<!-- custom fonts -->
<link rel="stylesheet" type="text/css" href="css/styles.css">
<!-- style for navbar -->
<link rel="stylesheet" type="text/css" href="css/navbar.css">
</head>
<body>
<!-- alert box -->
<div id="alertBox">
<div id="alertBoxInfo">
</div>
</div>
<div id="mySidenav" class="sidenav">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a>
<h3 class="navMainInfo marginBottom">Grid Size</h3>
<form class="navSubInfo" id="sizePicker">
<!-- input grid height -->
Height: <input type="number" id="inputHeight" name="height" min="1" max="50" value="21">
Width: <input type="number" id="inputWidth" name="width" min="1" max="50" value="21">
<!-- input grid height-->
<input class="btn btn-success" type="submit" id="submit" value="Submit">
</form>
<div style="display: inline-block;" class="extraMargin">
<!-- pick a color -->
<h4 class="navMainInfo" id ="recentColorsHeader" style="display: inline-block;">Pick A Color:</h4><input type="color" id="colorPicker" style="display: inline-block;">
</div>
<div style="display: inline-block;" class="extraMargin">
<h4 class="navMainInfo ">Recent Colors: </h4>
<div class="recentColors" onClick="getColor(this)"></div>
<div class="recentColors" onClick="getColor(this)"></div>
<div class="recentColors" onClick="getColor(this)"></div>
<div class="recentColors" onClick="getColor(this)"></div>
</div>
<div class="extraMargin" style="display: inline-block; margin-left: 20px;">
<h4 class="navMainInfo"><i class="fas fa-eraser" onClick="eraser(this)"></i>
</h4>
<div id="eraser" onClick="eraser(this)"></div>
</div>
<div style="display: block;">
<!-- input name -->
<p class="navMainInfo">Artist Name:</p> <input type="text" id="name" name="name" placeholder="insert artist name" maxlength="15">
</div>
<!-- open modal to view image -->
<button class="btn btn-success" id="myBtn" >
View Master Piece
<span class="glyphicon glyphicon-eye-open"></span>
</button>
<!-- reset canvas color -->
<input class="btn btn-danger marginBottom" style="display: inline-block" type="button" value="Reset Canvas Color" onclick="resetGridColor()">
<!-- reset grid -->
<input class="btn btn-danger marginBottom" style="display: inline-block" type="button" value="Reset Canvas to Default" onclick="resetGrid()">
</div>
<!-- main header -->
<div id="headerBackground">
<h1 id="mainHeader" onclick="openNav()"><i class="fas fa-bars fa-sm" id="navOpen"></i>Lab: Pixel Art Maker</h1>
</div>
<div id="main">
<div id="content">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<!-- canvas to capture pixel canvas -->
<div id="capture">
<table id="pixelCanvas"></table>
<h3 id="outputName"></h3>
</div>
</div>
</div>
<!-- The Modal for image -->
<div id="myModal" class="modal">
<!-- Modal content -->
<div class="modelImageContainer" id="modal-content">
<span class="close">×</span>
<button class="btn btn-success" id="downloadButton" onclick="PrintImage(); return false;">
Print/Save Your Masterpiece
<span class="glyphicon glyphicon-download-alt"></span></button>
</div>
</div>
</div>
</div>
</div>
<!-- font awesome -->
<script defer src="https://use.fontawesome.com/releases/v5.0.9/js/all.js" integrity="sha384-8iPTk2s/jMVj81dnzb/iFR2sdA7u06vHJyyLlAd4snFpCl/SnyUjRrbdJsw1pGIl" crossorigin="anonymous"></script>
<!-- designs canvas js -->
<script src="js/designs.js"></script>
<!-- jquery html2canvas plugin minified -->
<script type="text/javascript" language="javascript" src="js/html2canvas.min.js">
</script>
<!-- jquery html2canvas plugin -->
<script type="text/javascript" language="javascript" src="js/jquery.plugin.html2canvas.js">
</script
<!-- modal script from w3school.com -->
<script>
// Get the modal
var modal = document.getElementById('myModal');
// Get the button that opens the modal
var btn = document.getElementById("myBtn");
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
// create variable to hold current image
var currentImage
// When the user clicks the button, open the modal and get picture of canvas
btn.onclick = function() {
// remove old image if user already created masterpiece
$("body #modal-content img").remove();
// remove border before creating image
$("tbody td").removeClass("blackBorder");
$("tbody tr").removeClass("blackBorder");
// add clear border before creating image
$("tbody td").addClass("clearBorder");
$("tbody tr").addClass("clearBorder");
modal.style.display = "block";
// html2canvas function to create image of div
$('#capture').html2canvas({
onrendered : function(canvas) {
var img = canvas.toDataURL();
// img now contains a url
$('<img>',{src:img}).appendTo($('body #modal-content'));
// set current img
currentImage = img;
// add black border after creating image
$("tbody td").addClass("blackBorder");
$("tbody tr").addClass("blackBorder");
// remove clear border after creating image
$("tbody td").removeClass("clearBorder");
$("tbody tr").removeClass("clearBorder");
}
});
// add image to popup modal
$('body #modal-content img').attr('id', 'randomimage');
}
function closePrint () {
$('#imageDownload').attr({target: '_blank',
href : currentImage});
}
// When the user clicks on <span> (x), close the modal
span.onclick = function() {
modal.style.display = "none";
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
// image to print function
function ImagetoPrint() {
return "<html><head><script>function step1(){\n" +
"setTimeout('step2()', 10);}\n" +
"function step2(){window.print();window.close()}\n" +
"</scri" + "pt></head><body onload='step1()'>\n" +
"<img src='" + currentImage + "' /></body></html>";
}
// this will prompt image print on click
function PrintImage() {
Pagelink = "about:blank";
var pwa = window.open(Pagelink, "_new");
pwa.document.open();
pwa.document.write(ImagetoPrint(currentImage));
pwa.document.close();
}
function openNav() {
document.getElementById("mySidenav").style.width = "250px";
document.getElementById("main").style.marginLeft = "250px";
}
function closeNav() {
document.getElementById("mySidenav").style.width = "0";
document.getElementById("main").style.marginLeft= "0";
}
// open menu on page load
openNav()
</script>
</body>
</html>