59 lines
5.8 KiB
JavaScript
59 lines
5.8 KiB
JavaScript
|
|
import sharp from 'sharp'
|
||
|
|
import { fileURLToPath } from 'node:url'
|
||
|
|
import { dirname, join } from 'node:path'
|
||
|
|
import { mkdir } from 'node:fs/promises'
|
||
|
|
|
||
|
|
const here = dirname(fileURLToPath(import.meta.url))
|
||
|
|
const source = join(here, '..', 'public', 'icons', 'icon.svg')
|
||
|
|
const output = join(here, '..', 'public', 'icons')
|
||
|
|
const appOutput = join(here, '..', 'public', 'app-icons')
|
||
|
|
|
||
|
|
const appIcons = [
|
||
|
|
['loutre-os','dashboard','#0a84ff','#0056b8'],['network-guardian','network','#34c759','#087d34'],
|
||
|
|
['reverse-proxy-manager','proxy','#64d2ff','#0079a8'],['codex-commander','terminal','#bf5af2','#6b25a2'],
|
||
|
|
['autonomous-dev-studio','studio','#5e5ce6','#2f2e9f'],['loutre-brain','brain','#ff2d55','#a90e30'],
|
||
|
|
['loutre-finance','finance','#30d158','#058632'],['print-pilot','printer','#ff9f0a','#c45f00'],
|
||
|
|
['loutre-home','home','#ffd60a','#d58a00'],['auto-care','car','#8e8e93','#3a3a3c'],
|
||
|
|
['smart-inventory','inventory','#0a84ff','#144ab8'],['knowledge-graph','graph','#ac8e68','#6d5035'],
|
||
|
|
['trip-organizer','trip','#5ac8fa','#0578af'],['pwa-factory','phone','#ff375f','#a80f38'],
|
||
|
|
['nasflix-media-health','media-health','#ff453a','#a91e18'],['nasflix-ai-media-curator','media-ai','#af52de','#592488'],
|
||
|
|
['pi-doctor','doctor','#32d74b','#087923'],['loutre-app-store','store','#007aff','#123fba'],
|
||
|
|
]
|
||
|
|
|
||
|
|
const symbols = {
|
||
|
|
dashboard: '<path d="M142 326a132 132 0 1 1 228 0"/><path d="m256 256 70-62"/><circle cx="256" cy="256" r="21"/><path d="M156 353h200"/>',
|
||
|
|
network: '<circle cx="256" cy="151" r="42"/><circle cx="151" cy="337" r="42"/><circle cx="361" cy="337" r="42"/><path d="m235 188-63 112m105-112 63 112M193 337h126"/>',
|
||
|
|
proxy: '<rect x="127" y="136" width="258" height="70" rx="22"/><rect x="127" y="306" width="258" height="70" rx="22"/><path d="M177 256h158m-36-36 36 36-36 36"/><circle cx="170" cy="171" r="8" fill="white"/><circle cx="170" cy="341" r="8" fill="white"/>',
|
||
|
|
terminal: '<rect x="102" y="119" width="308" height="274" rx="40"/><path d="m155 206 55 50-55 50m99 0h102"/>',
|
||
|
|
studio: '<path d="m126 357 85-85m90-90 85-85M168 119l225 225-49 49-225-225z"/><path d="m285 128 38 38m34-86 9 31 31 9-31 9-9 31-9-31-31-9 31-9z"/>',
|
||
|
|
brain: '<path d="M211 371c-55 18-98-34-74-78-43-30-25-100 28-102-4-52 65-78 91-34 26-44 95-18 91 34 53 2 71 72 28 102 24 44-19 96-74 78-12 25-78 24-90 0z"/><path d="M256 157v235m-91-201c41 7 57 31 50 70m82-70c-28 12-37 36-29 69m-131 33c33-16 61-10 79 17m159-17c-33-16-61-10-79 17"/>',
|
||
|
|
finance: '<path d="M123 377h266M153 337V236m81 101V171m81 166v-72m74 72V122"/><path d="m137 207 91-78 84 59 77-91"/>',
|
||
|
|
printer: '<rect x="126" y="101" width="260" height="166" rx="28"/><path d="M196 267v72h120v-72m-93 72-38 72h142l-38-72"/><path d="m190 190 66 38 66-38-66-38z"/>',
|
||
|
|
home: '<path d="m94 247 162-137 162 137"/><path d="M133 221v180h246V221M221 401V291h70v110"/>',
|
||
|
|
car: '<path d="m124 277 42-102c8-19 26-31 47-31h86c21 0 39 12 47 31l42 102"/><rect x="93" y="250" width="326" height="112" rx="36"/><circle cx="163" cy="362" r="30"/><circle cx="349" cy="362" r="30"/><path d="M116 293h55m170 0h55"/>',
|
||
|
|
inventory: '<path d="m256 95 143 76-143 76-143-76zM113 171v170l143 76 143-76V171M256 247v170"/><path d="m183 133 143 76"/>',
|
||
|
|
graph: '<circle cx="130" cy="263" r="40"/><circle cx="261" cy="126" r="40"/><circle cx="382" cy="246" r="40"/><circle cx="263" cy="386" r="40"/><path d="m158 234 74-78m57-2 65 66m0 55-64 82m-56 0-76-67"/>',
|
||
|
|
trip: '<path d="m81 279 350-137-137 350-36-159z"/><path d="m258 333 83-83"/>',
|
||
|
|
phone: '<rect x="158" y="72" width="196" height="368" rx="42"/><path d="M217 115h78m-66 278h54"/><path d="m93 177 17 39 39 17-39 17-17 39-17-39-39-17 39-17z"/>',
|
||
|
|
'media-health': '<rect x="94" y="118" width="324" height="276" rx="38"/><path d="M94 188h324M174 118v70m82-70v70m82-70v70"/><path d="M167 293h48l24-48 40 97 28-49h43"/>',
|
||
|
|
'media-ai': '<rect x="87" y="128" width="338" height="264" rx="38"/><path d="M87 198h338M172 128v70m84-70v70m84-70v70"/><path d="m277 256 18 43 43 18-43 18-18 43-18-43-43-18 43-18z"/>',
|
||
|
|
doctor: '<path d="M205 86h102v119h119v102H307v119H205V307H86V205h119z"/><path d="m117 355 48-43 42 43 48-86 42 61 35-36h63"/>',
|
||
|
|
store: '<path d="M135 190h242l28 228H107z"/><path d="M190 209v-37c0-88 132-88 132 0v37"/><rect x="159" y="258" width="64" height="64" rx="14" fill="white"/><rect x="289" y="258" width="64" height="64" rx="14" fill="white"/><rect x="159" y="340" width="64" height="48" rx="14" fill="white"/><rect x="289" y="340" width="64" height="48" rx="14" fill="white"/>',
|
||
|
|
}
|
||
|
|
|
||
|
|
function appSvg(symbol,top,bottom){return Buffer.from(`<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="0 0 512 512"><defs><linearGradient id="g" x1="0" y1="0" x2="1" y2="1"><stop stop-color="${top}"/><stop offset="1" stop-color="${bottom}"/></linearGradient></defs><rect width="512" height="512" rx="112" fill="url(#g)"/><circle cx="388" cy="112" r="92" fill="#fff" opacity=".12"/><g fill="none" stroke="white" stroke-width="24" stroke-linecap="round" stroke-linejoin="round">${symbols[symbol]}</g></svg>`)}
|
||
|
|
|
||
|
|
await mkdir(appOutput,{recursive:true})
|
||
|
|
|
||
|
|
await Promise.all([
|
||
|
|
sharp(source).resize(192, 192).png().toFile(join(output, 'icon-192.png')),
|
||
|
|
sharp(source).resize(512, 512).png().toFile(join(output, 'icon-512.png')),
|
||
|
|
sharp(source).resize(512, 512).extend({ top: 51, bottom: 51, left: 51, right: 51, background: '#111316' }).resize(512, 512).png().toFile(join(output, 'icon-maskable-512.png')),
|
||
|
|
sharp(source).resize(180, 180).png().toFile(join(output, 'apple-touch-icon.png')),
|
||
|
|
...appIcons.flatMap(([slug,symbol,top,bottom])=>[
|
||
|
|
sharp(appSvg(symbol,top,bottom)).resize(192,192).png().toFile(join(appOutput,`${slug}-192.png`)),
|
||
|
|
sharp(appSvg(symbol,top,bottom)).resize(512,512).png().toFile(join(appOutput,`${slug}-512.png`)),
|
||
|
|
sharp(appSvg(symbol,top,bottom)).resize(180,180).png().toFile(join(appOutput,`${slug}-apple.png`)),
|
||
|
|
]),
|
||
|
|
])
|