-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.html
177 lines (155 loc) · 7.22 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Evangelion Episode Generator</title>
<link rel="stylesheet" href="index.css">
</head>
<body class="flow-0">
<main>
<article class="flow-0">
<h1>Evangelion Episode Generator</h1>
<p><strong>Create your own Evangelion title!</strong></p>
<p><em>Please note this is a complete beta that probably breaks and lacks options.</em></p>
<h2>Please fill this</h2>
<form action="" class="flow-0">
<div class="label-input-flow">
<label for="title">Title of your show</label>
<input type="text" name="title" id="title" value="Neon Genesis Evangelion">
</div>
<div class="label-input-flow">
<label for="episode">Episode number</label>
<input type="text" name="episode" id="episode" value="Episode: 1">
</div>
<div class="label-input-flow">
<label for="episodeName">Name of the episode</label>
<input type="text" name="episodeName" id="episodeName" value="Get in the robot Shinji">
</div>
<button id="generate">Generate</button>
<br>
<small>Click on the image to open it on a new page and save it.</small>
</form>
</article>
<section aria-label="Generated episode card" id="area">
</section>
</main>
<footer>
<svg width="0" height="0">
<filter id="chromatic">
<feColorMatrix type="matrix" result="red_" values="4 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 1 0" />
<feOffset in="red_" dx="1" dy="0" result="red" />
<feColorMatrix type="matrix" in="SourceGraphic" result="blue_" values="0 0 0 0 0
0 3 0 0 0
0 0 10 0 0
0 0 0 1 0" />
<feOffset in="blue_" dx="-1" dy="0" result="blue" />
<feBlend mode="screen" in="red" in2="blue" />
</filter>
</svg>
</footer>
<script>
document.addEventListener('DOMContentLoaded', function (event) {
document.querySelector('#generate').addEventListener('click', function (e) {
e.preventDefault();
const oldImage = document.querySelector('img');
if (oldImage) {
oldImage.remove();
}
ctx = document.createElement('canvas');
ctx.setAttribute("width", 640);
ctx.setAttribute("height", 480);
ctx.setAttribute('id', "canvas");
drawTitle(ctx.getContext('2d'));
drawEpisode(ctx.getContext('2d'));
drawEpisodeName(ctx.getContext('2d'));
const image = convertCanvasToImage(ctx);
const area = document.querySelector("#area");
area.appendChild(image);
});
function drawTitle(ctx) {
const title = document.querySelector("#title").value;
const x = 20;
const y = 80;
const lineheight = 60;
const fontSize = 60;
const split = title.split(' ');
for (let i = 0; i < split.length; i++) {
console.log(i, split.length)
if (i + 1 === split.length) {
ctx.font = `80px "Century-Schoolbook"`;
ctx.fillStyle = 'cyan';
ctx.fillText(split[i].toUpperCase(), x + 0.7, y + (i * lineheight) + 15);
ctx.fillStyle = 'magenta';
ctx.fillText(split[i].toUpperCase(), x - 0.7, y + (i * lineheight) + 15);
ctx.fillStyle = 'white';
ctx.fillText(split[i].toUpperCase(), x, y + (i * lineheight) + 15);
ctx.fillStyle = "rgba(255, 255, 255, 0.3)";
ctx.rotate(1 / 360);
ctx.fillText(split[i].toUpperCase(), x + 1, y + (i * lineheight) + 15 -1);
ctx.rotate(-1 / 360);
ctx.fillText(split[i].toUpperCase(), x - 1, y + (i * lineheight) + 15 - 1);
} else {
ctx.font = `60px "Century-Schoolbook"`;
ctx.fillStyle = 'cyan';
ctx.fillText(split[i].toUpperCase(), x + 0.7, y + (i * lineheight));
ctx.fillStyle = 'magenta';
ctx.fillText(split[i].toUpperCase(), x - 0.7, y + (i * lineheight));
ctx.fillStyle = 'white';
ctx.fillText(split[i].toUpperCase(), x, y + (i * lineheight));
ctx.fillStyle = "rgba(255, 255, 255, 0.3)";
ctx.rotate(1 / 360);
ctx.fillText(split[i].toUpperCase(), x + 2, y + (i * lineheight) +1);
ctx.rotate(-1 / 360);
ctx.fillText(split[i].toUpperCase(), x - 2, y + (i * lineheight) -1);
}
}
return ctx
}
function drawEpisode(ctx) {
const title = document.querySelector("#episode").value;
ctx.font = '50px "Helvetica-Condensed-Bold"';
ctx.fillStyle = 'cyan';
ctx.fillText(title.toUpperCase(), 21, 360);
ctx.fillStyle = 'magenta';
ctx.fillText(title.toUpperCase(), 19, 360);
ctx.fillStyle = 'white';
ctx.fillText(title.toUpperCase(), 20, 360);
ctx.fillStyle = "rgba(255, 255, 255, 0.3)";
ctx.rotate(1 / 360);
ctx.fillText(title.toUpperCase(), 21, 361);
ctx.rotate(-1 / 360);
ctx.fillText(title.toUpperCase(), 19, 359);
return ctx
}
function drawEpisodeName(ctx) {
const title = document.querySelector("#episodeName").value;
ctx.font = '40px "TimesNRCondensedBold"';
ctx.textAlign = "right";
ctx.fillStyle = 'cyan';
ctx.fillText(title, 620.7, 450);
ctx.fillStyle = 'magenta';
ctx.fillText(title, 619.3, 450);
ctx.fillStyle = 'white';
ctx.fillText(title, 620, 450);
ctx.fillStyle = "rgba(255, 255, 255, 0.3)";
ctx.rotate(0.3 / 360);
ctx.fillText(title, 621, 451);
ctx.rotate(-0.6 / 360);
ctx.fillText(title, 619, 449);
return ctx
}
function convertCanvasToImage(ctx) {
let image = new Image();
image.src = ctx.toDataURL('image/jpeg', 1.0);
image.setAttribute('onClick', "window.open(this.src)")
return image;
}
})
</script>
</body>
</html>