forked from einaregilsson/Redirector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
icon.html
59 lines (50 loc) · 1.28 KB
/
icon.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
a {
display:block;
margin:10px auto;
padding:0px;
}
img {
margin:0;
padding:0;
border:solid 1px green;
}
</style>
</head>
<body>
<script>
function createImageLink(size, logoFontSize, logoX, logoY) {
var colors = {'#333' : 'active', '#bbb' : 'disabled'};
for (var color in colors) {
var canvas = document.createElement('canvas');
canvas.width = canvas.height = size;
ctx = canvas.getContext('2d');
ctx.fillStyle = color;
ctx.font = 'Bold ' + logoFontSize + 'px Arial';
ctx.fillText('☈', logoX, logoY);
var a = document.createElement('a');
var img = document.createElement('img');
img.src = canvas.toDataURL();
a.href = canvas.toDataURL();
a.download = 'icon-' + colors[color] + '-' + size + '.png';
a.appendChild(img);
a.style.width = size + 'px'
document.body.appendChild(a);
}
}
document.addEventListener('DOMContentLoaded', function() {
createImageLink(16, 32, 0, 16);
createImageLink(19, 35, 1, 18);
createImageLink(32, 64, 1, 32);
createImageLink(38, 75, 2, 38);
createImageLink(48, 95, 1, 48);
createImageLink(64, 125, 3, 63);
createImageLink(128, 215, 12, 116);
});
</script>
</body>
</html>