-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate-icons.html
More file actions
53 lines (53 loc) · 1.36 KB
/
generate-icons.html
File metadata and controls
53 lines (53 loc) · 1.36 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
<!DOCTYPE html>
<html>
<body>
<canvas id="c"></canvas>
<script>
// Run this in browser to generate PNG icons, then save them to icons/
[16,48,128].forEach(size => {
const c = document.getElementById('c');
c.width = c.height = size;
const ctx = c.getContext('2d');
// Background
ctx.fillStyle = '#161b22';
ctx.beginPath();
ctx.roundRect(0, 0, size, size, size * 0.15);
ctx.fill();
// Draw branch icon (⎇ style)
ctx.strokeStyle = '#3fb950';
ctx.lineWidth = Math.max(1.5, size / 12);
ctx.lineCap = 'round';
const m = size * 0.18;
const cx = size / 2;
// Trunk
ctx.beginPath();
ctx.moveTo(cx, m);
ctx.lineTo(cx, size - m);
ctx.stroke();
// Left branch
ctx.beginPath();
ctx.moveTo(cx, size * 0.4);
ctx.lineTo(m, size * 0.65);
ctx.stroke();
// Right branch
ctx.beginPath();
ctx.moveTo(cx, size * 0.4);
ctx.lineTo(size - m, size * 0.65);
ctx.stroke();
// Dots at ends
ctx.fillStyle = '#58a6ff';
[[cx, m],[m, size*0.65],[size-m, size*0.65],[cx, size-m]].forEach(([x,y]) => {
ctx.beginPath();
ctx.arc(x, y, Math.max(1.5, size/14), 0, Math.PI*2);
ctx.fill();
});
const link = document.createElement('a');
link.download = `icon${size}.png`;
link.href = c.toDataURL();
link.textContent = `Download icon${size}.png`;
link.style.display = 'block';
document.body.appendChild(link);
});
</script>
</body>
</html>