-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
108 lines (98 loc) · 3.95 KB
/
index.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
107
108
<!DOCTYPE html>
<html>
<head>
<title>MC-GIf</title>
<meta charset="utf-8">
<style>
body {
font-family: Arial, Helvetica, sans-serif;
}
</style>
</head>
<body onload="localStorage.imgcounter=2">
<script src="js/jquery.js"></script>
<!-- for downloading files -->
<script src="js/download.js"></script>
<h1>Minecraft Painting Animation</h1>
<br>
<br>
<div id="inputs">
<input type="file" id="input1" onclick="showimg(); localStorage.selectimg=1">
<img id="img1" src="eins.png" width="64px" height="64px">
<br>
<input type="file" id="input2" onclick="showimg(); localStorage.selectimg=2">
<img id="img2" src="zwei.png" width="64px" height="64px">
<br>
</div>
<br>
<button onclick="newinput()">Another Image</button>
<br>
<br>
<br>
<br>
<br>
<button onclick="klicken()">Put Together</button>
<button onclick="downloadbut()">Download</button>
<canvas id="merged"></canvas>
<iframe id="my_iframe" style="display:none;"></iframe>
<script>
// Das ausgewählte Bild wird angezigt
function showimg() {
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function(e) {
$('#img' + localStorage.selectimg).attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
$("#input" + localStorage.selectimg).change(function() {
readURL(this);
});
}
// Neuer Button um ein Bild hinzuzufügen
function newinput() {
if(localStorage.imgcounter>=3) {
localStorage.imgcounter++;
document.write(localStorage.imgcounter);
} else {
localStorage.imgcounter=3;
}
var para = document.createElement("input");
para.setAttribute("type", "file");
para.setAttribute("id", "input" + localStorage.imgcounter);
para.setAttribute("onclick", "showimg()")
var element = document.getElementById("inputs");
element.appendChild(para);
var para = document.createElement("img");
para.setAttribute("id", "img" + localStorage.imgcounter);
para.setAttribute("src", "drei.png");
para.setAttribute("width", "64px");
para.setAttribute("height", "64px");
var element = document.getElementById("inputs");
element.appendChild(para);
var para = document.createElement("br");
var element = document.getElementById("inputs");
element.appendChild(para);
}
// Ausgabe von allen Bildern in canvas als jpg
function klicken() {
var canvas = document.getElementById('merged');
canvas.width = 64;
canvas.height = (64*localStorage.imgcounter);
for(var i=1; i<=localStorage.imgcounter; i++) {
var img1 = document.getElementById('img' + i);
var context = canvas.getContext('2d');
img1.width = 64;
img1.height = 64;
context.drawImage(img1, 0, ((i-1)*64), 64, 64);
}
}
//download
function downloadbut() {
download((document.getElementById("merged")), "dlText.png", "image/png");
}
</script>
</body>
</html>