-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-icons.html
More file actions
101 lines (90 loc) · 2.56 KB
/
Copy pathcreate-icons.html
File metadata and controls
101 lines (90 loc) · 2.56 KB
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Icon Generator for Paperless-ngx Saver</title>
<style>
body {
font-family: Arial, sans-serif;
padding: 20px;
max-width: 600px;
margin: 0 auto;
}
canvas {
border: 1px solid #ccc;
margin: 10px;
}
button {
padding: 10px 20px;
margin: 5px;
font-size: 14px;
cursor: pointer;
}
</style>
</head>
<body>
<h1>Icon Generator</h1>
<p>Click the buttons below to download the extension icons:</p>
<div>
<canvas id="canvas16" width="16" height="16"></canvas>
<canvas id="canvas48" width="48" height="48"></canvas>
<canvas id="canvas128" width="128" height="128"></canvas>
</div>
<div>
<button onclick="downloadIcon(16)">Download 16x16</button>
<button onclick="downloadIcon(48)">Download 48x48</button>
<button onclick="downloadIcon(128)">Download 128x128</button>
</div>
<script>
// Draw icons
function drawIcon(size) {
const canvas = document.getElementById(`canvas${size}`);
const ctx = canvas.getContext('2d');
// Background
ctx.fillStyle = '#4CAF50';
ctx.fillRect(0, 0, size, size);
// Document icon
const padding = size * 0.15;
const docWidth = size * 0.6;
const docHeight = size * 0.7;
const docX = (size - docWidth) / 2;
const docY = (size - docHeight) / 2;
// Document body
ctx.fillStyle = '#FFFFFF';
ctx.fillRect(docX, docY, docWidth, docHeight);
// Document lines (if size is large enough)
if (size >= 48) {
ctx.strokeStyle = '#4CAF50';
ctx.lineWidth = size > 64 ? 2 : 1;
const lineSpacing = docHeight / 5;
const lineMargin = docWidth * 0.15;
for (let i = 1; i < 4; i++) {
ctx.beginPath();
ctx.moveTo(docX + lineMargin, docY + lineSpacing * i);
ctx.lineTo(docX + docWidth - lineMargin, docY + lineSpacing * i);
ctx.stroke();
}
}
return canvas;
}
// Draw all icons on load
drawIcon(16);
drawIcon(48);
drawIcon(128);
// Download function
function downloadIcon(size) {
const canvas = document.getElementById(`canvas${size}`);
canvas.toBlob(function(blob) {
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = `icon${size}.png`;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
});
}
</script>
</body>
</html>