99 lines
4.5 KiB
PowerShell
99 lines
4.5 KiB
PowerShell
Add-Type -AssemblyName System.Drawing
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
$root = Split-Path -Parent $PSScriptRoot
|
|
$outDir = Join-Path $root 'icons'
|
|
|
|
if (-not (Test-Path -LiteralPath $outDir)) {
|
|
New-Item -ItemType Directory -Path $outDir | Out-Null
|
|
}
|
|
|
|
function New-Icon {
|
|
param(
|
|
[int] $Size,
|
|
[string] $Path
|
|
)
|
|
|
|
$scale = $Size / 128.0
|
|
$bitmap = New-Object System.Drawing.Bitmap $Size, $Size, ([System.Drawing.Imaging.PixelFormat]::Format32bppArgb)
|
|
$graphics = [System.Drawing.Graphics]::FromImage($bitmap)
|
|
$graphics.SmoothingMode = [System.Drawing.Drawing2D.SmoothingMode]::AntiAlias
|
|
$graphics.InterpolationMode = [System.Drawing.Drawing2D.InterpolationMode]::HighQualityBicubic
|
|
$graphics.PixelOffsetMode = [System.Drawing.Drawing2D.PixelOffsetMode]::HighQuality
|
|
$graphics.Clear([System.Drawing.Color]::Transparent)
|
|
|
|
function S([double] $value) { return [single]($value * $scale) }
|
|
function New-RoundedPath([System.Drawing.RectangleF] $rect, [single] $radius) {
|
|
$path = New-Object System.Drawing.Drawing2D.GraphicsPath
|
|
$diameter = $radius * 2
|
|
$path.AddArc($rect.X, $rect.Y, $diameter, $diameter, 180, 90)
|
|
$path.AddArc($rect.Right - $diameter, $rect.Y, $diameter, $diameter, 270, 90)
|
|
$path.AddArc($rect.Right - $diameter, $rect.Bottom - $diameter, $diameter, $diameter, 0, 90)
|
|
$path.AddArc($rect.X, $rect.Bottom - $diameter, $diameter, $diameter, 90, 90)
|
|
$path.CloseFigure()
|
|
return $path
|
|
}
|
|
|
|
$bgRect = New-Object System.Drawing.RectangleF (S 4), (S 4), (S 120), (S 120)
|
|
$bgPath = New-RoundedPath $bgRect (S 24)
|
|
|
|
$bgBrush = New-Object System.Drawing.Drawing2D.LinearGradientBrush $bgRect,
|
|
([System.Drawing.Color]::FromArgb(255, 24, 31, 42)),
|
|
([System.Drawing.Color]::FromArgb(255, 16, 18, 27)),
|
|
([System.Drawing.Drawing2D.LinearGradientMode]::ForwardDiagonal)
|
|
$graphics.FillPath($bgBrush, $bgPath)
|
|
|
|
$borderPen = New-Object System.Drawing.Pen ([System.Drawing.Color]::FromArgb(255, 66, 87, 108)), (S 3)
|
|
$graphics.DrawPath($borderPen, $bgPath)
|
|
|
|
$leftRect = New-Object System.Drawing.RectangleF (S 23), (S 30), (S 34), (S 46)
|
|
$rightRect = New-Object System.Drawing.RectangleF (S 71), (S 52), (S 34), (S 46)
|
|
$panelBrush = New-Object System.Drawing.Drawing2D.LinearGradientBrush $leftRect,
|
|
([System.Drawing.Color]::FromArgb(255, 53, 211, 190)),
|
|
([System.Drawing.Color]::FromArgb(255, 72, 118, 255)),
|
|
([System.Drawing.Drawing2D.LinearGradientMode]::Vertical)
|
|
$panelPen = New-Object System.Drawing.Pen ([System.Drawing.Color]::FromArgb(235, 228, 248, 255)), (S 3)
|
|
$leftPath = New-RoundedPath $leftRect (S 8)
|
|
$rightPath = New-RoundedPath $rightRect (S 8)
|
|
|
|
$graphics.FillPath($panelBrush, $leftPath)
|
|
$graphics.DrawPath($panelPen, $leftPath)
|
|
$graphics.FillPath($panelBrush, $rightPath)
|
|
$graphics.DrawPath($panelPen, $rightPath)
|
|
|
|
$arrowPen = New-Object System.Drawing.Pen ([System.Drawing.Color]::FromArgb(255, 255, 184, 77)), (S 8)
|
|
$arrowPen.StartCap = [System.Drawing.Drawing2D.LineCap]::Round
|
|
$arrowPen.EndCap = [System.Drawing.Drawing2D.LineCap]::Round
|
|
|
|
$graphics.DrawLine($arrowPen, (S 46), (S 86), (S 83), (S 86))
|
|
$arrowBrush = New-Object System.Drawing.SolidBrush ([System.Drawing.Color]::FromArgb(255, 255, 184, 77))
|
|
$arrowHead = @(
|
|
(New-Object System.Drawing.PointF (S 84), (S 72)),
|
|
(New-Object System.Drawing.PointF (S 108), (S 86)),
|
|
(New-Object System.Drawing.PointF (S 84), (S 100))
|
|
)
|
|
$graphics.FillPolygon($arrowBrush, $arrowHead)
|
|
|
|
$smallArrowPen = New-Object System.Drawing.Pen ([System.Drawing.Color]::FromArgb(230, 228, 248, 255)), (S 5)
|
|
$smallArrowPen.StartCap = [System.Drawing.Drawing2D.LineCap]::Round
|
|
$smallArrowPen.EndCap = [System.Drawing.Drawing2D.LineCap]::Round
|
|
$graphics.DrawLine($smallArrowPen, (S 81), (S 38), (S 49), (S 38))
|
|
$smallHeadBrush = New-Object System.Drawing.SolidBrush ([System.Drawing.Color]::FromArgb(230, 228, 248, 255))
|
|
$smallHead = @(
|
|
(New-Object System.Drawing.PointF (S 50), (S 28)),
|
|
(New-Object System.Drawing.PointF (S 32), (S 38)),
|
|
(New-Object System.Drawing.PointF (S 50), (S 48))
|
|
)
|
|
$graphics.FillPolygon($smallHeadBrush, $smallHead)
|
|
|
|
$bitmap.Save($Path, [System.Drawing.Imaging.ImageFormat]::Png)
|
|
|
|
$graphics.Dispose()
|
|
$bitmap.Dispose()
|
|
}
|
|
|
|
$sizes = @(16, 32, 48, 128)
|
|
foreach ($size in $sizes) {
|
|
New-Icon -Size $size -Path (Join-Path $outDir "icon-$size.png")
|
|
}
|