-
Notifications
You must be signed in to change notification settings - Fork 1
/
fonttool.html
49 lines (38 loc) · 936 Bytes
/
fonttool.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
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<canvas id=c></canvas>
<div id=z></div>
<div id=y></div>
<script type="text/javascript">
c = c.getContext("2d");
p = (x,y,s=1) => c.fillRect(x,y,s,s)
clear = ()=> {c.fillStyle="#fff";c.fillRect(0,0,300,150);c.fillStyle="#000";}
calc = () => {
clear();
let all = document.getElementsByTagName("input");
let num = 0;
for(let i = 0; i< all.length;i++) {
let el = all[i];
if (el.checked) {
num += 1 << i;
p(parseInt(el.dataset.i)%3, ~~(parseInt(el.dataset.i)/3));
p(3*(parseInt(el.dataset.i)%3) + 5, 3*~~(parseInt(el.dataset.i)/3),3);
}
}
y.innerHTML = num + "<br>" + String.fromCharCode(num);
}
for(let i = 0; i < 15; i++) {
let el = document.createElement("input");
el.type="checkbox";
el.dataset.i=i;
el.onclick = calc;
z.appendChild(el);
if ((i+1)%3 == 0) z.appendChild(document.createElement("br"))
}
</script>
</body>
</html>