-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
53 lines (45 loc) · 1.28 KB
/
test.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="txt2px.js"></script>
</head>
<body style="margin: 0px">
<canvas id="canvas" style="position: absolute; left: 0px; top: 0px"></canvas>
<script>
"use strict";
const params = new URL(document.location).searchParams;
const width = parseInt(params.get('width') || 15);
const height = parseInt(params.get('height') || 10);
const fill = (params.get('fill') || ' ').charCodeAt(0);
const text = params.get('text');
const canvas = document.getElementById('canvas');
canvas.width = width;
canvas.height = height;
const txtCanvas = new TxtCanvas(canvas, fill);
if (text) {
txtCanvas.write(text);
}
else {
const lines = [
"Lorem ipsum dolor sit amet,\n",
"consectetur adipiscing elit,\n",
"sed do eiusmod tempor incididunt\n",
"ut labore et dolore magna aliqua.\n",
"Ut enim ad minim veniam, quis nostrud\n",
"exercitation ullamco laboris nisi\n",
"ut aliquip ex ea commodo consequat.\n",
"Duis aute irure dolor in reprehenderit\n",
"in voluptate velit esse cillum\n",
"dolore eu fugiat nulla pariatur.\n",
"Excepteur sint occaecat cupidatat non\n",
"proident, sunt in culpa qui officia\n",
"deserunt mollit anim id est laborum.\n"
];
for (let line of lines) {
txtCanvas.write(line);
}
}
</script>
</body>
</html>