98 lines
3.9 KiB
PowerShell
98 lines
3.9 KiB
PowerShell
param(
|
|
[string]$OutputPath = "build\icon.png"
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
Add-Type -AssemblyName System.Drawing
|
|
|
|
$resolvedOutput = [IO.Path]::GetFullPath($OutputPath)
|
|
New-Item -ItemType Directory -Force -Path (Split-Path -Parent $resolvedOutput) | Out-Null
|
|
|
|
$size = 512
|
|
$bitmap = New-Object System.Drawing.Bitmap $size, $size
|
|
$graphics = [System.Drawing.Graphics]::FromImage($bitmap)
|
|
$graphics.SmoothingMode = [System.Drawing.Drawing2D.SmoothingMode]::AntiAlias
|
|
$graphics.CompositingQuality = [System.Drawing.Drawing2D.CompositingQuality]::HighQuality
|
|
$graphics.Clear([System.Drawing.Color]::Transparent)
|
|
|
|
function New-RoundedRectanglePath([System.Drawing.RectangleF]$rectangle, [float]$radius) {
|
|
$diameter = $radius * 2
|
|
$path = New-Object System.Drawing.Drawing2D.GraphicsPath
|
|
$path.AddArc($rectangle.X, $rectangle.Y, $diameter, $diameter, 180, 90)
|
|
$path.AddArc($rectangle.Right - $diameter, $rectangle.Y, $diameter, $diameter, 270, 90)
|
|
$path.AddArc($rectangle.Right - $diameter, $rectangle.Bottom - $diameter, $diameter, $diameter, 0, 90)
|
|
$path.AddArc($rectangle.X, $rectangle.Bottom - $diameter, $diameter, $diameter, 90, 90)
|
|
$path.CloseFigure()
|
|
return $path
|
|
}
|
|
|
|
$bounds = New-Object System.Drawing.RectangleF 22, 22, 468, 468
|
|
$shape = New-RoundedRectanglePath $bounds 104
|
|
$background = New-Object System.Drawing.Drawing2D.LinearGradientBrush(
|
|
$bounds,
|
|
[System.Drawing.Color]::FromArgb(255, 29, 17, 59),
|
|
[System.Drawing.Color]::FromArgb(255, 33, 91, 125),
|
|
135
|
|
)
|
|
$graphics.FillPath($background, $shape)
|
|
|
|
$glow = New-Object System.Drawing.SolidBrush ([System.Drawing.Color]::FromArgb(42, 157, 112, 255))
|
|
$graphics.FillEllipse($glow, 66, 44, 330, 330)
|
|
$cyanGlow = New-Object System.Drawing.SolidBrush ([System.Drawing.Color]::FromArgb(34, 82, 229, 242))
|
|
$graphics.FillEllipse($cyanGlow, 206, 196, 262, 262)
|
|
|
|
$borderPen = New-Object System.Drawing.Pen ([System.Drawing.Color]::FromArgb(120, 221, 205, 255)), 6
|
|
$graphics.DrawPath($borderPen, $shape)
|
|
|
|
$orbitPen = New-Object System.Drawing.Pen ([System.Drawing.Color]::FromArgb(235, 239, 232, 255)), 19
|
|
$orbitPen.StartCap = [System.Drawing.Drawing2D.LineCap]::Round
|
|
$orbitPen.EndCap = [System.Drawing.Drawing2D.LineCap]::Round
|
|
$state = $graphics.Save()
|
|
$graphics.TranslateTransform(256, 256)
|
|
$graphics.RotateTransform(-38)
|
|
$graphics.DrawArc($orbitPen, -167, -103, 334, 206, 18, 212)
|
|
$graphics.DrawArc($orbitPen, -167, -103, 334, 206, 248, 92)
|
|
$graphics.Restore($state)
|
|
|
|
$coreBrush = New-Object System.Drawing.SolidBrush ([System.Drawing.Color]::FromArgb(255, 151, 235, 242))
|
|
$coreBorder = New-Object System.Drawing.Pen ([System.Drawing.Color]::FromArgb(255, 250, 247, 255)), 12
|
|
$graphics.FillEllipse($coreBrush, 202, 202, 108, 108)
|
|
$graphics.DrawEllipse($coreBorder, 202, 202, 108, 108)
|
|
|
|
$satelliteBrush = New-Object System.Drawing.SolidBrush ([System.Drawing.Color]::FromArgb(255, 241, 211, 142))
|
|
$satelliteBorder = New-Object System.Drawing.Pen ([System.Drawing.Color]::FromArgb(255, 255, 248, 228)), 8
|
|
$graphics.FillEllipse($satelliteBrush, 342, 88, 66, 66)
|
|
$graphics.DrawEllipse($satelliteBorder, 342, 88, 66, 66)
|
|
$graphics.FillEllipse($satelliteBrush, 104, 350, 54, 54)
|
|
$graphics.DrawEllipse($satelliteBorder, 104, 350, 54, 54)
|
|
|
|
$starBrush = New-Object System.Drawing.SolidBrush ([System.Drawing.Color]::FromArgb(210, 255, 255, 255))
|
|
$graphics.FillEllipse($starBrush, 124, 112, 13, 13)
|
|
$graphics.FillEllipse($starBrush, 394, 282, 10, 10)
|
|
$graphics.FillEllipse($starBrush, 286, 398, 8, 8)
|
|
|
|
try {
|
|
$bitmap.Save($resolvedOutput, [System.Drawing.Imaging.ImageFormat]::Png)
|
|
} finally {
|
|
$starBrush.Dispose()
|
|
$satelliteBorder.Dispose()
|
|
$satelliteBrush.Dispose()
|
|
$coreBorder.Dispose()
|
|
$coreBrush.Dispose()
|
|
$orbitPen.Dispose()
|
|
$borderPen.Dispose()
|
|
$cyanGlow.Dispose()
|
|
$glow.Dispose()
|
|
$background.Dispose()
|
|
$shape.Dispose()
|
|
$graphics.Dispose()
|
|
$bitmap.Dispose()
|
|
}
|
|
|
|
[pscustomobject]@{
|
|
ok = $true
|
|
width = $size
|
|
height = $size
|
|
outputPath = $resolvedOutput
|
|
} | ConvertTo-Json -Compress
|