167 lines
4.5 KiB
HTML
167 lines
4.5 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>PNG Icon Generator</title>
|
|
<style>
|
|
body {
|
|
font-family: system-ui, sans-serif;
|
|
max-width: 800px;
|
|
margin: 50px auto;
|
|
padding: 20px;
|
|
background: #f5f5f5;
|
|
}
|
|
.container {
|
|
background: white;
|
|
padding: 30px;
|
|
border-radius: 8px;
|
|
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
|
|
}
|
|
h1 {
|
|
color: #4f46e5;
|
|
margin-top: 0;
|
|
}
|
|
.preview {
|
|
display: flex;
|
|
gap: 20px;
|
|
margin: 20px 0;
|
|
align-items: center;
|
|
}
|
|
canvas {
|
|
border: 2px solid #e5e7eb;
|
|
border-radius: 8px;
|
|
}
|
|
button {
|
|
background: #4f46e5;
|
|
color: white;
|
|
border: none;
|
|
padding: 12px 24px;
|
|
border-radius: 6px;
|
|
font-size: 16px;
|
|
cursor: pointer;
|
|
margin: 5px;
|
|
}
|
|
button:hover {
|
|
background: #4338ca;
|
|
}
|
|
.info {
|
|
background: #eff6ff;
|
|
border-left: 4px solid #3b82f6;
|
|
padding: 12px;
|
|
margin: 20px 0;
|
|
border-radius: 4px;
|
|
}
|
|
.success {
|
|
background: #f0fdf4;
|
|
border-left-color: #22c55e;
|
|
color: #166534;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<h1>🎨 PWA Icon Generator</h1>
|
|
|
|
<div class="info">
|
|
<strong>Instructions:</strong> This tool will generate PNG icons from your SVG favicon.
|
|
Click the buttons below to download the required icon sizes for PWA support.
|
|
</div>
|
|
|
|
<div class="preview">
|
|
<div>
|
|
<h3>192x192</h3>
|
|
<canvas id="canvas192" width="192" height="192"></canvas>
|
|
<br>
|
|
<button onclick="downloadIcon(192)">📥 Download 192x192</button>
|
|
</div>
|
|
|
|
<div>
|
|
<h3>512x512</h3>
|
|
<canvas id="canvas512" width="512" height="512"></canvas>
|
|
<br>
|
|
<button onclick="downloadIcon(512)">📥 Download 512x512</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="status"></div>
|
|
|
|
<div class="info">
|
|
<strong>After downloading:</strong>
|
|
<ol>
|
|
<li>Save both files to <code>frontend/public/</code></li>
|
|
<li>Rename them to <code>icon-192.png</code> and <code>icon-512.png</code></li>
|
|
<li>Rebuild your Docker containers</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
const svgContent = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
|
|
<defs>
|
|
<linearGradient id="grad" x1="0%" y1="0%" x2="100%" y2="100%">
|
|
<stop offset="0%" style="stop-color:#6366f1;stop-opacity:1" />
|
|
<stop offset="100%" style="stop-color:#4f46e5;stop-opacity:1" />
|
|
</linearGradient>
|
|
</defs>
|
|
|
|
<!-- Dice/Box shape -->
|
|
<rect x="10" y="10" width="80" height="80" rx="12" fill="url(#grad)"/>
|
|
|
|
<!-- Dots representing game selection -->
|
|
<circle cx="30" cy="30" r="6" fill="white" opacity="0.9"/>
|
|
<circle cx="50" cy="30" r="6" fill="white" opacity="0.9"/>
|
|
<circle cx="70" cy="30" r="6" fill="white" opacity="0.9"/>
|
|
|
|
<circle cx="30" cy="50" r="6" fill="white" opacity="0.9"/>
|
|
<circle cx="50" cy="50" r="6" fill="white" opacity="1"/>
|
|
<circle cx="70" cy="50" r="6" fill="white" opacity="0.9"/>
|
|
|
|
<circle cx="30" cy="70" r="6" fill="white" opacity="0.9"/>
|
|
<circle cx="50" cy="70" r="6" fill="white" opacity="0.9"/>
|
|
<circle cx="70" cy="70" r="6" fill="white" opacity="0.9"/>
|
|
</svg>`;
|
|
|
|
function drawIcon(size) {
|
|
const canvas = document.getElementById(`canvas${size}`);
|
|
const ctx = canvas.getContext('2d');
|
|
|
|
const img = new Image();
|
|
const blob = new Blob([svgContent], { type: 'image/svg+xml' });
|
|
const url = URL.createObjectURL(blob);
|
|
|
|
img.onload = function() {
|
|
ctx.clearRect(0, 0, size, size);
|
|
ctx.drawImage(img, 0, 0, size, size);
|
|
URL.revokeObjectURL(url);
|
|
};
|
|
|
|
img.src = url;
|
|
}
|
|
|
|
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);
|
|
|
|
const status = document.getElementById('status');
|
|
status.innerHTML = `<div class="info success">✅ Downloaded icon-${size}.png! Save it to frontend/public/</div>`;
|
|
setTimeout(() => status.innerHTML = '', 3000);
|
|
});
|
|
}
|
|
|
|
// Draw icons on page load
|
|
window.addEventListener('load', () => {
|
|
drawIcon(192);
|
|
drawIcon(512);
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|
|
|