Update index.html
Browse files- index.html +40 -30
index.html
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
<!doctype html>
|
2 |
<html lang="ja" class="h-100">
|
|
|
3 |
<head>
|
4 |
<meta charset="utf-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1">
|
@@ -25,9 +26,7 @@
|
|
25 |
background-size: contain;
|
26 |
}
|
27 |
|
28 |
-
body {
|
29 |
-
|
30 |
-
}
|
31 |
|
32 |
#edit {
|
33 |
/*background: url('ClipBoard.png');*/
|
@@ -128,7 +127,12 @@
|
|
128 |
font-family: "Noto Sans JP";
|
129 |
}
|
130 |
</style>
|
131 |
-
<style id="text-shadow">
|
|
|
|
|
|
|
|
|
|
|
132 |
<link href="https://getbootstrap.jp/docs/5.0/examples/sticky-footer-navbar/sticky-footer-navbar.css"
|
133 |
rel="stylesheet">
|
134 |
</head>
|
@@ -206,7 +210,8 @@
|
|
206 |
</div>
|
207 |
<div class="input-group">
|
208 |
<span class="input-group-text">TopAlpha</span>
|
209 |
-
<input type="range" class="form-control form-range" id="topAlpha" value="0.7" step="0.01"
|
|
|
210 |
</div>
|
211 |
<div class="input-group">
|
212 |
<span class="input-group-text">BtmColor</span>
|
@@ -214,7 +219,8 @@
|
|
214 |
</div>
|
215 |
<div class="input-group">
|
216 |
<span class="input-group-text">BtmAlpha</span>
|
217 |
-
<input type="range" class="form-control form-range" id="btmAlpha" value="0.9" step="0.01"
|
|
|
218 |
</div>
|
219 |
<h6>Font</h6>
|
220 |
<div class="input-group">
|
@@ -223,7 +229,8 @@
|
|
223 |
</div>
|
224 |
<div class="input-group">
|
225 |
<span class="input-group-text">font-size</span>
|
226 |
-
<input type="range" class="form-control form-range" id="fontSizeInput" value="0.8" step="0.01"
|
|
|
227 |
</div>
|
228 |
<div class="input-group">
|
229 |
<button id="textShadowToggle" type="button" class="btn btn-primary">TEXT-STROKE</button>
|
@@ -277,41 +284,43 @@
|
|
277 |
let naturalAspect = image.naturalWidth / image.naturalHeight;
|
278 |
let width = window.document.documentElement.clientHeight * naturalAspect
|
279 |
let height = window.document.documentElement.clientHeight;
|
280 |
-
//edit.style.width = image.naturalWidth + "px";
|
281 |
-
//edit.style.height = image.naturalHeight + "px";
|
282 |
-
edit.style.width = width + "px";
|
283 |
-
edit.style.height = height + "px";
|
284 |
-
edit.style.position = "absolute";
|
285 |
result.classList.remove("d-none");
|
286 |
-
|
287 |
-
el.classList.remove("d-none");
|
288 |
-
el.style.fontSize = (el.parentNode.offsetHeight * document.querySelector("#fontSizeInput").value * 0.65) + "px";
|
289 |
-
el.textContent = el.parentNode.querySelector("input").value;
|
290 |
-
});
|
291 |
createEditor();
|
292 |
setTimeout(function () {
|
293 |
html2canvas(document.getElementById("edit"), {
|
294 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
295 |
}).then(canvas => {
|
296 |
result.textContent = "";
|
297 |
-
canvas.style.margin = 0;
|
298 |
-
canvas.style.padding = 0;
|
299 |
result.appendChild(canvas);
|
300 |
-
edit.style.position = "inherit";
|
301 |
let caption = document.createElement("span");
|
302 |
caption.classList.add("caption");
|
303 |
caption.textContent = "Rendered";
|
304 |
result.appendChild(caption);
|
305 |
-
document.querySelectorAll(".shadow-text").forEach(el => {
|
306 |
-
el.classList.add("d-none");
|
307 |
-
});
|
308 |
let scale = Math.min.apply(null, [window.document.documentElement.clientWidth / width, window.document.documentElement.clientHeight / height, 1])
|
309 |
canvas.style.transform = "scale(" + scale + ")";
|
310 |
});
|
311 |
}, 1);
|
312 |
}
|
313 |
document.getElementById("result").addEventListener("click", function (e) {
|
314 |
-
console.log(e.target);
|
315 |
document.getElementById("result").classList.add("d-none");
|
316 |
document.getElementById("controller").classList.remove("d-none");
|
317 |
let image = document.getElementById("image");
|
@@ -376,20 +385,21 @@
|
|
376 |
document.getElementById("fontFamilyInput").addEventListener("change", function () {
|
377 |
let f = document.getElementById("fontFamily");
|
378 |
let i = this;
|
379 |
-
if(!i.value){
|
380 |
f.textContent = 'body { font-family: "Noto Sans JP"; }';
|
381 |
-
}else{
|
382 |
-
f.textContent = 'body { font-family: "'+i.value.trim()+'"; }';
|
383 |
}
|
384 |
});
|
385 |
document.getElementById("textShadowToggle").addEventListener("click", function () {
|
386 |
this.classList.toggle("opacity-50");
|
387 |
-
if(this.classList.contains("opacity-50")){
|
388 |
document.getElementById("text-shadow").textContent = "";
|
389 |
-
}else{
|
390 |
document.getElementById("text-shadow").textContent = 'input, .shadow-text {text-shadow: 1px -0px 0 rgba(0, 0, 0, 0.8), 1px 0px 0 rgba(0, 0, 0, 0.8), 1px 1px 0 rgba(0, 0, 0, 0.8), 0px 1px 0 rgba(0, 0, 0, 0.8), -1px -1px 0 rgba(0, 0, 0, 0.8), -1px 0px 0 rgba(0, 0, 0, 0.8), -1px -1px 0 rgba(0, 0, 0, 0.8);}';
|
391 |
}
|
392 |
});
|
393 |
</script>
|
394 |
</body>
|
|
|
395 |
</html>
|
|
|
1 |
<!doctype html>
|
2 |
<html lang="ja" class="h-100">
|
3 |
+
|
4 |
<head>
|
5 |
<meta charset="utf-8">
|
6 |
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
|
26 |
background-size: contain;
|
27 |
}
|
28 |
|
29 |
+
body {}
|
|
|
|
|
30 |
|
31 |
#edit {
|
32 |
/*background: url('ClipBoard.png');*/
|
|
|
127 |
font-family: "Noto Sans JP";
|
128 |
}
|
129 |
</style>
|
130 |
+
<style id="text-shadow">
|
131 |
+
input,
|
132 |
+
.shadow-text {
|
133 |
+
text-shadow: 1px -0px 0 rgba(0, 0, 0, 0.8), 1px 0px 0 rgba(0, 0, 0, 0.8), 1px 1px 0 rgba(0, 0, 0, 0.8), 0px 1px 0 rgba(0, 0, 0, 0.8), -1px -1px 0 rgba(0, 0, 0, 0.8), -1px 0px 0 rgba(0, 0, 0, 0.8), -1px -1px 0 rgba(0, 0, 0, 0.8);
|
134 |
+
}
|
135 |
+
</style>
|
136 |
<link href="https://getbootstrap.jp/docs/5.0/examples/sticky-footer-navbar/sticky-footer-navbar.css"
|
137 |
rel="stylesheet">
|
138 |
</head>
|
|
|
210 |
</div>
|
211 |
<div class="input-group">
|
212 |
<span class="input-group-text">TopAlpha</span>
|
213 |
+
<input type="range" class="form-control form-range" id="topAlpha" value="0.7" step="0.01"
|
214 |
+
max="1">
|
215 |
</div>
|
216 |
<div class="input-group">
|
217 |
<span class="input-group-text">BtmColor</span>
|
|
|
219 |
</div>
|
220 |
<div class="input-group">
|
221 |
<span class="input-group-text">BtmAlpha</span>
|
222 |
+
<input type="range" class="form-control form-range" id="btmAlpha" value="0.9" step="0.01"
|
223 |
+
max="1">
|
224 |
</div>
|
225 |
<h6>Font</h6>
|
226 |
<div class="input-group">
|
|
|
229 |
</div>
|
230 |
<div class="input-group">
|
231 |
<span class="input-group-text">font-size</span>
|
232 |
+
<input type="range" class="form-control form-range" id="fontSizeInput" value="0.8" step="0.01"
|
233 |
+
min="0.5" max="1">
|
234 |
</div>
|
235 |
<div class="input-group">
|
236 |
<button id="textShadowToggle" type="button" class="btn btn-primary">TEXT-STROKE</button>
|
|
|
284 |
let naturalAspect = image.naturalWidth / image.naturalHeight;
|
285 |
let width = window.document.documentElement.clientHeight * naturalAspect
|
286 |
let height = window.document.documentElement.clientHeight;
|
|
|
|
|
|
|
|
|
|
|
287 |
result.classList.remove("d-none");
|
288 |
+
|
|
|
|
|
|
|
|
|
289 |
createEditor();
|
290 |
setTimeout(function () {
|
291 |
html2canvas(document.getElementById("edit"), {
|
292 |
+
scale: 2,
|
293 |
+
windowWidth: image.naturalWidth * 2,
|
294 |
+
windowHeight: image.naturalHeight * 2,
|
295 |
+
width: image.naturalWidth,
|
296 |
+
height: image.naturalHeight,
|
297 |
+
onclone: (x) => {
|
298 |
+
console.log(x);
|
299 |
+
x.getElementById("edit").style.width = image.naturalWidth + "px";
|
300 |
+
x.getElementById("edit").style.height = image.naturalHeight + "px";
|
301 |
+
x.getElementById("edit").classList.add("m-0");
|
302 |
+
x.getElementById("edit").classList.add("p-0");
|
303 |
+
x.querySelectorAll(".shadow-text").forEach(el => {
|
304 |
+
el.classList.remove("d-none");
|
305 |
+
el.style.fontSize = (el.parentNode.offsetHeight * document.querySelector("#fontSizeInput").value) + "px";
|
306 |
+
el.textContent = el.parentNode.querySelector("input").value;
|
307 |
+
el.parentNode.querySelector("input").classList.add("d-none");
|
308 |
+
});
|
309 |
+
return x;
|
310 |
+
}
|
311 |
}).then(canvas => {
|
312 |
result.textContent = "";
|
|
|
|
|
313 |
result.appendChild(canvas);
|
|
|
314 |
let caption = document.createElement("span");
|
315 |
caption.classList.add("caption");
|
316 |
caption.textContent = "Rendered";
|
317 |
result.appendChild(caption);
|
|
|
|
|
|
|
318 |
let scale = Math.min.apply(null, [window.document.documentElement.clientWidth / width, window.document.documentElement.clientHeight / height, 1])
|
319 |
canvas.style.transform = "scale(" + scale + ")";
|
320 |
});
|
321 |
}, 1);
|
322 |
}
|
323 |
document.getElementById("result").addEventListener("click", function (e) {
|
|
|
324 |
document.getElementById("result").classList.add("d-none");
|
325 |
document.getElementById("controller").classList.remove("d-none");
|
326 |
let image = document.getElementById("image");
|
|
|
385 |
document.getElementById("fontFamilyInput").addEventListener("change", function () {
|
386 |
let f = document.getElementById("fontFamily");
|
387 |
let i = this;
|
388 |
+
if (!i.value) {
|
389 |
f.textContent = 'body { font-family: "Noto Sans JP"; }';
|
390 |
+
} else {
|
391 |
+
f.textContent = 'body { font-family: "' + i.value.trim() + '"; }';
|
392 |
}
|
393 |
});
|
394 |
document.getElementById("textShadowToggle").addEventListener("click", function () {
|
395 |
this.classList.toggle("opacity-50");
|
396 |
+
if (this.classList.contains("opacity-50")) {
|
397 |
document.getElementById("text-shadow").textContent = "";
|
398 |
+
} else {
|
399 |
document.getElementById("text-shadow").textContent = 'input, .shadow-text {text-shadow: 1px -0px 0 rgba(0, 0, 0, 0.8), 1px 0px 0 rgba(0, 0, 0, 0.8), 1px 1px 0 rgba(0, 0, 0, 0.8), 0px 1px 0 rgba(0, 0, 0, 0.8), -1px -1px 0 rgba(0, 0, 0, 0.8), -1px 0px 0 rgba(0, 0, 0, 0.8), -1px -1px 0 rgba(0, 0, 0, 0.8);}';
|
400 |
}
|
401 |
});
|
402 |
</script>
|
403 |
</body>
|
404 |
+
|
405 |
</html>
|