Files
snapcad-studio/scripts/generate-pwa-icons.mjs
Enes Yakıştır 33b0940012
Build and Push Docker Images / build (push) Canceled after 0s
CI / Typecheck and unit tests (push) Canceled after 0s
feat: SnapCAD Studio'yu YakHub deposuna taşı
- DWG/DXF içe aktarma ve .skf yeniden açma düzeltmeleri

- YakNet Bulut eşitlemede boş/eski kopya koruması ve yerel-only proje bildirimi

- Panelden içe aktarma duyuruları ve erişilebilir Türkçe hata mesajları

- AGPL-3.0 lisansı, README ve YakHub bağlantıları
2026-10-25 18:20:21 +03:00

119 lines
4.0 KiB
JavaScript

import fs from "fs";
import path from "path";
import sharp from "sharp";
async function generateIcons() {
const publicDir = path.resolve("apps/web/public");
const iconsDir = path.join(publicDir, "icons");
if (!fs.existsSync(iconsDir)) {
fs.mkdirSync(iconsDir, { recursive: true });
}
// Create an elegant SnapCAD SVG icon
const svgIcon = `
<svg width="512" height="512" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient id="bgGrad" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" stop-color="#0284c7" />
<stop offset="50%" stop-color="#0369a1" />
<stop offset="100%" stop-color="#0f172a" />
</linearGradient>
<linearGradient id="cubeTop" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" stop-color="#38bdf8" />
<stop offset="100%" stop-color="#0284c7" />
</linearGradient>
<linearGradient id="cubeLeft" x1="0%" y1="0%" x2="0%" y2="100%">
<stop offset="0%" stop-color="#0284c7" />
<stop offset="100%" stop-color="#0369a1" />
</linearGradient>
<linearGradient id="cubeRight" x1="0%" y1="0%" x2="0%" y2="100%">
<stop offset="0%" stop-color="#0ea5e9" />
<stop offset="100%" stop-color="#0284c7" />
</linearGradient>
<filter id="glow" x="-20%" y="-20%" width="140%" height="140%">
<feGaussianBlur stdDeviation="16" result="blur" />
<feComposite in="SourceGraphic" in2="blur" operator="over" />
</filter>
</defs>
<!-- Background rounded rect -->
<rect width="512" height="512" rx="108" fill="url(#bgGrad)" />
<!-- Subtle grid lines in background -->
<path d="M 96 160 L 416 160 M 96 256 L 416 256 M 96 352 L 416 352" stroke="#38bdf8" stroke-opacity="0.15" stroke-width="2" />
<path d="M 160 96 L 160 416 M 256 96 L 256 416 M 352 96 L 352 416" stroke="#38bdf8" stroke-opacity="0.15" stroke-width="2" />
<!-- 3D Isometric Cube Symbol representing SnapCAD -->
<g filter="url(#glow)">
<!-- Top Face -->
<polygon points="256,128 368,192 256,256 144,192" fill="url(#cubeTop)" />
<!-- Left Face -->
<polygon points="144,192 256,256 256,384 144,320" fill="url(#cubeLeft)" />
<!-- Right Face -->
<polygon points="256,256 368,192 368,320 256,384" fill="url(#cubeRight)" />
<!-- Isometric Highlight Edges -->
<polyline points="144,192 256,128 368,192" stroke="#e0f2fe" stroke-width="5" stroke-linejoin="round" />
<line x1="256" y1="256" x2="256" y2="384" stroke="#7dd3fc" stroke-width="4" />
<polyline points="144,192 256,256 368,192" stroke="#bae6fd" stroke-width="3" />
</g>
<!-- Modern Snap Indicator Dot -->
<circle cx="256" cy="256" r="10" fill="#facc15" stroke="#ffffff" stroke-width="3" />
</svg>
`;
const svgBuffer = Buffer.from(svgIcon);
// 1. icon-512.png
await sharp(svgBuffer)
.resize(512, 512)
.png()
.toFile(path.join(iconsDir, "icon-512.png"));
console.log("Generated icon-512.png");
// 2. icon-192.png
await sharp(svgBuffer)
.resize(192, 192)
.png()
.toFile(path.join(iconsDir, "icon-192.png"));
console.log("Generated icon-192.png");
// 3. icon-maskable-512.png (padded for safe zone)
await sharp(svgBuffer)
.resize(410, 410)
.extend({
top: 51,
bottom: 51,
left: 51,
right: 51,
background: "#0284c7"
})
.png()
.toFile(path.join(iconsDir, "icon-maskable-512.png"));
console.log("Generated icon-maskable-512.png");
// 4. icon-maskable-192.png
await sharp(path.join(iconsDir, "icon-maskable-512.png"))
.resize(192, 192)
.png()
.toFile(path.join(iconsDir, "icon-maskable-192.png"));
console.log("Generated icon-maskable-192.png");
// 5. apple-touch-icon.png (180x180)
await sharp(svgBuffer)
.resize(180, 180)
.png()
.toFile(path.join(iconsDir, "apple-touch-icon.png"));
console.log("Generated apple-touch-icon.png");
// 6. favicon-32.png
await sharp(svgBuffer)
.resize(32, 32)
.png()
.toFile(path.join(iconsDir, "favicon-32.png"));
console.log("Generated favicon-32.png");
}
generateIcons().catch(console.error);