64 lines
2.9 KiB
PowerShell
64 lines
2.9 KiB
PowerShell
# Draws the app icon (indigo/violet rounded square with a white "layers" glyph,
|
|
# same look as the dashboard logo) and writes launcher\app.ico with 16-256 px.
|
|
Add-Type -AssemblyName System.Drawing
|
|
$ErrorActionPreference = 'Stop'
|
|
$out = Join-Path $PSScriptRoot 'app.ico'
|
|
|
|
function New-IconPng([int]$size) {
|
|
$bmp = New-Object System.Drawing.Bitmap $size, $size
|
|
$g = [System.Drawing.Graphics]::FromImage($bmp)
|
|
$g.SmoothingMode = 'AntiAlias'
|
|
$g.Clear([System.Drawing.Color]::Transparent)
|
|
|
|
# rounded square with diagonal gradient
|
|
$r = [single]($size * 0.22)
|
|
$rect = New-Object System.Drawing.RectangleF 0, 0, $size, $size
|
|
$path = New-Object System.Drawing.Drawing2D.GraphicsPath
|
|
$d = $r * 2
|
|
$path.AddArc(0, 0, $d, $d, 180, 90)
|
|
$path.AddArc($size - $d, 0, $d, $d, 270, 90)
|
|
$path.AddArc($size - $d, $size - $d, $d, $d, 0, 90)
|
|
$path.AddArc(0, $size - $d, $d, $d, 90, 90)
|
|
$path.CloseFigure()
|
|
$brush = New-Object System.Drawing.Drawing2D.LinearGradientBrush $rect, ([System.Drawing.Color]::FromArgb(99, 102, 241)), ([System.Drawing.Color]::FromArgb(139, 92, 246)), 45
|
|
$g.FillPath($brush, $path)
|
|
|
|
# layers glyph: a diamond on top, two chevrons below (Lucide "layers" shape)
|
|
$s = $size / 24.0
|
|
$pen = New-Object System.Drawing.Pen ([System.Drawing.Color]::White), ([single][Math]::Max(1.2, 1.9 * $s))
|
|
$pen.LineJoin = 'Round'; $pen.StartCap = 'Round'; $pen.EndCap = 'Round'
|
|
$ox = 0; $oy = 0.6 * $s
|
|
function P($x, $y) { New-Object System.Drawing.PointF ([single]($x * $s + $ox)), ([single]($y * $s + $oy)) }
|
|
$g.DrawPolygon($pen, [System.Drawing.PointF[]]@((P 12 4.2), (P 19.5 7.6), (P 12 11), (P 4.5 7.6)))
|
|
$g.DrawLines($pen, [System.Drawing.PointF[]]@((P 4.5 11.8), (P 12 15.2), (P 19.5 11.8)))
|
|
$g.DrawLines($pen, [System.Drawing.PointF[]]@((P 4.5 15.8), (P 12 19.2), (P 19.5 15.8)))
|
|
|
|
$g.Dispose()
|
|
$ms = New-Object System.IO.MemoryStream
|
|
$bmp.Save($ms, [System.Drawing.Imaging.ImageFormat]::Png)
|
|
$bmp.Dispose()
|
|
return , $ms.ToArray()
|
|
}
|
|
|
|
# ICO container with PNG-compressed entries
|
|
$sizes = 16, 24, 32, 48, 64, 128, 256
|
|
$images = foreach ($sz in $sizes) { , (New-IconPng $sz) }
|
|
$fs = [System.IO.File]::Create($out)
|
|
$w = New-Object System.IO.BinaryWriter $fs
|
|
$w.Write([uint16]0); $w.Write([uint16]1); $w.Write([uint16]$sizes.Count)
|
|
$offset = 6 + 16 * $sizes.Count
|
|
for ($i = 0; $i -lt $sizes.Count; $i++) {
|
|
$sz = $sizes[$i]; $data = $images[$i]
|
|
$w.Write([byte]($(if ($sz -ge 256) { 0 } else { $sz })))
|
|
$w.Write([byte]($(if ($sz -ge 256) { 0 } else { $sz })))
|
|
$w.Write([byte]0); $w.Write([byte]0)
|
|
$w.Write([uint16]1); $w.Write([uint16]32)
|
|
$w.Write([uint32]$data.Length); $w.Write([uint32]$offset)
|
|
$offset += $data.Length
|
|
}
|
|
foreach ($data in $images) { $w.Write($data) }
|
|
$w.Close()
|
|
# also a PNG preview for the dashboard / README
|
|
[System.IO.File]::WriteAllBytes((Join-Path $PSScriptRoot 'app.png'), (New-IconPng 256))
|
|
Write-Host "icon -> $out"
|