# PWA app icon 生成脚本:简单绿底 + 白色油枪图形 # 用 System.Drawing 渲染,无需外部依赖 Add-Type -AssemblyName System.Drawing $ErrorActionPreference = 'Stop' function New-AppIcon { param([int]$Size, [string]$OutPath) $bmp = New-Object System.Drawing.Bitmap $Size, $Size $g = [System.Drawing.Graphics]::FromImage($bmp) $g.SmoothingMode = [System.Drawing.Drawing2D.SmoothingMode]::AntiAlias $g.TextRenderingHint = [System.Drawing.Text.TextRenderingHint]::AntiAlias # 背景:深绿圆角矩形 $bgColor = [System.Drawing.Color]::FromArgb(255, 24, 160, 88) $bgBrush = New-Object System.Drawing.SolidBrush $bgColor $radius = [int]($Size * 0.18) $rect = New-Object System.Drawing.Rectangle 0, 0, $Size, $Size $path = New-Object System.Drawing.Drawing2D.GraphicsPath $path.AddArc($rect.X, $rect.Y, $radius * 2, $radius * 2, 180, 90) $path.AddArc($rect.Right - $radius * 2, $rect.Y, $radius * 2, $radius * 2, 270, 90) $path.AddArc($rect.Right - $radius * 2, $rect.Bottom - $radius * 2, $radius * 2, $radius * 2, 0, 90) $path.AddArc($rect.X, $rect.Bottom - $radius * 2, $radius * 2, $radius * 2, 90, 90) $path.CloseFigure() $g.FillPath($bgBrush, $path) $bgBrush.Dispose() # 油枪轮廓:白色矩形 + 把手 + 喷嘴 $white = [System.Drawing.Color]::FromArgb(255, 255, 255, 255) $whiteBrush = New-Object System.Drawing.SolidBrush $white $darkGreen = [System.Drawing.Color]::FromArgb(255, 14, 122, 67) $darkBrush = New-Object System.Drawing.SolidBrush $darkGreen $unit = $Size / 24.0 # 油枪主体 $bodyX = [int](8 * $unit); $bodyY = [int](3 * $unit) $bodyW = [int](10 * $unit); $bodyH = [int](15 * $unit) $g.FillRectangle($whiteBrush, $bodyX, $bodyY, $bodyW, $bodyH) # 把手(横向) $handleY = [int](6 * $unit) $handleW = [int](5 * $unit); $handleH = [int](3 * $unit) $g.FillRectangle($whiteBrush, $bodyX - $handleW, $handleY, $handleW, $handleH) # 喷嘴(右侧伸出) $nozzleW = [int](5 * $unit); $nozzleH = [int](3 * $unit) $nozzleX = $bodyX + $bodyW $nozzleY = [int](10 * $unit) $g.FillRectangle($whiteBrush, $nozzleX, $nozzleY, $nozzleW, $nozzleH) # 底座 $baseX = [int](6 * $unit); $baseY = [int](18 * $unit) $baseW = [int](12 * $unit); $baseH = [int](3 * $unit) $g.FillRectangle($darkBrush, $baseX, $baseY, $baseW, $baseH) $g.Dispose() $bmp.Save($OutPath, [System.Drawing.Imaging.ImageFormat]::Png) $bmp.Dispose() Write-Host "wrote $OutPath ($Size x $Size)" } $out = Join-Path $PSScriptRoot '..\public' New-AppIcon -Size 192 -OutPath (Join-Path $out 'pwa-192x192.png') New-AppIcon -Size 512 -OutPath (Join-Path $out 'pwa-512x512.png') # maskable:留 10% 安全边,Android adaptive icon 用 New-AppIcon -Size 512 -OutPath (Join-Path $out 'pwa-maskable-512x512.png') Write-Host 'DONE'