$ErrorActionPreference = 'Stop' Add-Type -AssemblyName System.Drawing $root = Split-Path -Parent $PSScriptRoot $assetDir = Join-Path $root 'assets' $iconPath = Join-Path $assetDir 'dat-thang.ico' $bitmap = [System.Drawing.Bitmap]::new(64, 64, [System.Drawing.Imaging.PixelFormat]::Format32bppArgb) $graphics = [System.Drawing.Graphics]::FromImage($bitmap) $graphics.SmoothingMode = [System.Drawing.Drawing2D.SmoothingMode]::AntiAlias $graphics.Clear([System.Drawing.Color]::Transparent) $points = [System.Drawing.PointF[]]@( [System.Drawing.PointF]::new(32, 3), [System.Drawing.PointF]::new(58, 18), [System.Drawing.PointF]::new(58, 46), [System.Drawing.PointF]::new(32, 61), [System.Drawing.PointF]::new(6, 46), [System.Drawing.PointF]::new(6, 18) ) $fill = [System.Drawing.SolidBrush]::new([System.Drawing.Color]::FromArgb(255, 39, 54, 71)) $edge = [System.Drawing.Pen]::new([System.Drawing.Color]::FromArgb(255, 55, 205, 83), 4) $graphics.FillPolygon($fill, $points) $graphics.DrawPolygon($edge, $points) $png = [System.IO.MemoryStream]::new() $bitmap.Save($png, [System.Drawing.Imaging.ImageFormat]::Png) $image = $png.ToArray() $ico = [System.IO.MemoryStream]::new() $writer = [System.IO.BinaryWriter]::new($ico) $writer.Write([uint16]0) $writer.Write([uint16]1) $writer.Write([uint16]1) $writer.Write([byte]64) $writer.Write([byte]64) $writer.Write([byte]0) $writer.Write([byte]0) $writer.Write([uint16]1) $writer.Write([uint16]32) $writer.Write([uint32]$image.Length) $writer.Write([uint32]22) $writer.Write($image) [System.IO.Directory]::CreateDirectory($assetDir) | Out-Null [System.IO.File]::WriteAllBytes($iconPath, $ico.ToArray()) $writer.Dispose() $ico.Dispose() $png.Dispose() $edge.Dispose() $fill.Dispose() $graphics.Dispose() $bitmap.Dispose() Write-Host "Wrote $iconPath"