Skip to content

Commit 3a543e9

Browse files
committed
Added Download and Clear buttons
1 parent d47d820 commit 3a543e9

File tree

3 files changed

+52
-74
lines changed

3 files changed

+52
-74
lines changed

index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@
116116
<input type="color" id="favcolor" name="favcolor" value="#005A78" style="padding: 0; border:none; cursor:pointer;">
117117

118118
</div>
119+
<div>
120+
<br>
121+
<button id="download" onclick="download()">Download Emoji</button>
122+
<button id="download" onclick="clearemoji()">Clear Emoji</button>
123+
</div>
119124
</div>
120125
<!--
121126
Todo List:
@@ -134,6 +139,7 @@
134139
<img id="highlights" class="highlights" src="images/nothing.png" draggable = "false">
135140
<img id="face" class="face" src="images/Face Background.png" draggable = "false">
136141
</div>
142+
<canvas id="canvas" width="500" height="500" style="display: none;"></canvas>
137143
<p style="position: absolute; bottom: 0; right: 10px" draggable="false"><a color="grey" href="https://github.com/bobjoerules/Emojisite">GitHub</a> · Emoji Site V2.0 © <a color="grey" href="https://bobjoerules.com">Bobjoerules</a> 2025</p>
138144
<script src="script.js"></script>
139145
</body>

script.js

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,44 @@ function enablemouth() {
186186
}
187187

188188
colorInput.addEventListener("input", function () {
189-
// Get the selected color value from the input element
190189
const selectedColor = colorInput.value;
191-
192-
// Update the background color of the entire page
193190
document.body.style.backgroundColor = selectedColor;
194191
});
195192

196193
dragElement(document.getElementById("settings"));
197194

195+
function clearemoji() {
196+
document.querySelectorAll('button').forEach(btn => {
197+
if (btn.textContent.trim().toLowerCase() === 'none') {
198+
btn.click();
199+
}
200+
});
201+
}
202+
203+
function download() {
204+
const canvas = document.getElementById("canvas");
205+
const ctx = canvas.getContext("2d");
206+
const images = [
207+
document.getElementById("face"),
208+
document.getElementById("mouth"),
209+
document.getElementById("leye"),
210+
document.getElementById("reye"),
211+
document.getElementById("glasses"),
212+
document.getElementById("accessories"),
213+
document.getElementById("highlights")
214+
];
215+
216+
images.forEach(img => {
217+
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
218+
});
219+
220+
const combinedImage = canvas.toDataURL("image/png");
221+
const link = document.createElement("a");
222+
link.href = combinedImage;
223+
link.download = "newemoji.png";
224+
link.click();
225+
}
226+
198227
function dragElement(elmnt) {
199228
let pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
200229

style.css

Lines changed: 14 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -6,51 +6,6 @@ div, p {
66
1px 1px 0 black;
77
}
88

9-
.mouthbutton {
10-
border: none;
11-
color: white;
12-
text-align: center;
13-
text-decoration: none;
14-
display: inline-block;
15-
cursor: pointer;
16-
}
17-
18-
.righteyebutton {
19-
border: none;
20-
color: white;
21-
text-align: center;
22-
text-decoration: none;
23-
display: inline-block;
24-
cursor: pointer;
25-
}
26-
27-
.lefteyebutton {
28-
border: none;
29-
color: white;
30-
text-align: center;
31-
text-decoration: none;
32-
display: inline-block;
33-
cursor: pointer;
34-
}
35-
36-
.accessoriesbutton {
37-
border: none;
38-
color: white;
39-
text-align: center;
40-
text-decoration: none;
41-
display: inline-block;
42-
cursor: pointer;
43-
}
44-
45-
.highlightsbutton {
46-
border: none;
47-
color: white;
48-
text-align: center;
49-
text-decoration: none;
50-
display: inline-block;
51-
cursor: pointer;
52-
}
53-
549
.settings{
5510
position: absolute;
5611
z-index: 9;
@@ -63,64 +18,52 @@ div, p {
6318
cursor:grabbing;
6419
}
6520

66-
.glasses {
21+
.glasses, .accessories, .leye, .reye, .mouth, .highlights, .face {
6722
position: absolute;
6823
left: 50%;
6924
top: 50%;
7025
transform: translate(-50%, -50%);
26+
}
27+
.glasses {
7128
z-index: 5;
7229
}
7330

74-
7531
.accessories {
76-
position: absolute;
77-
left: 50%;
78-
top: 50%;
79-
transform: translate(-50%, -50%);
8032
z-index: 5;
8133
}
8234

8335
.leye {
84-
position: absolute;
85-
left: 50%;
86-
top: 50%;
87-
transform: translate(-50%, -50%);
8836
z-index: 3;
8937
}
9038

9139
.reye {
92-
position: absolute;
93-
left: 50%;
94-
top: 50%;
95-
transform: translate(-50%, -50%);
9640
z-index: 2;
9741
}
9842

9943
.mouth {
100-
position: absolute;
101-
left: 50%;
102-
top: 50%;
103-
transform: translate(-50%, -50%);
10444
z-index: 4;
10545
}
10646

10747
.highlights {
108-
position: absolute;
109-
left: 50%;
110-
top: 50%;
111-
transform: translate(-50%, -50%);
11248
z-index: 1;
11349
}
11450

11551
.face {
116-
position: absolute;
117-
left: 50%;
118-
top: 50%;
119-
transform: translate(-50%, -50%);
12052
z-index: 0;
12153
}
12254

55+
#download {
56+
background-color: black;
57+
padding: 10px;
58+
}
59+
12360
button {
61+
border: none;
62+
color: white;
63+
text-align: center;
64+
text-decoration: none;
65+
display: inline-block;
66+
cursor: pointer;
12467
border-radius: 5px;
12568
background-color: rgba(0, 0, 0, 0.1);
12669
color: white;

0 commit comments

Comments
 (0)