138 lines
5.4 KiB
PowerShell
138 lines
5.4 KiB
PowerShell
$ErrorActionPreference = 'Stop'
|
|
|
|
$root = Split-Path -Parent $PSScriptRoot
|
|
Add-Type -AssemblyName System.Drawing
|
|
|
|
$backgrounds = @(
|
|
'static/assets/foundation/opaque/auth-header.png',
|
|
'static/assets/foundation/opaque/auth-page-paper.jpg',
|
|
'static/assets/foundation/transparent/auth-ink-scenery.png'
|
|
)
|
|
$icons = @(
|
|
'static/assets/foundation/transparent/auth-login-outline.png',
|
|
'static/assets/foundation/transparent/auth-wechat.png',
|
|
'static/assets/foundation/transparent/auth-divider-knot.png',
|
|
'static/assets/foundation/transparent/auth-title-cloud.png'
|
|
)
|
|
$buttons = @(
|
|
'static/assets/foundation/opaque/a01-primary-button.png',
|
|
'static/assets/foundation/opaque/a01-secondary-button.png'
|
|
)
|
|
$v2Buttons = @(
|
|
'static/assets/foundation/transparent/a01-primary-button-v2.png',
|
|
'static/assets/foundation/transparent/a01-secondary-button-v2.png'
|
|
)
|
|
$v3Skins = @(
|
|
'static/assets/foundation/transparent/a01-scroll-primary-v3.png',
|
|
'static/assets/foundation/transparent/a01-scroll-secondary-v3.png',
|
|
'static/assets/foundation/transparent/a01-scroll-toast-v3.png',
|
|
'static/assets/modules/auth/transparent/a01-scroll-dialog-v3.png'
|
|
)
|
|
|
|
foreach ($asset in $backgrounds + $icons + $buttons + $v2Buttons + $v3Skins) {
|
|
if (-not (Test-Path -LiteralPath (Join-Path $root $asset))) {
|
|
throw "Missing A01 asset: $asset"
|
|
}
|
|
}
|
|
|
|
foreach ($asset in $v3Skins) {
|
|
$bitmap = [System.Drawing.Bitmap]::FromFile((Join-Path $root $asset))
|
|
$width = [int]$bitmap.Width
|
|
$height = [int]$bitmap.Height
|
|
$corners = @(
|
|
$bitmap.GetPixel(0, 0).A,
|
|
$bitmap.GetPixel(($width - 1), 0).A,
|
|
$bitmap.GetPixel(0, ($height - 1)).A,
|
|
$bitmap.GetPixel(($width - 1), ($height - 1)).A
|
|
)
|
|
$bitmap.Dispose()
|
|
|
|
$expectedSize = switch ($asset) {
|
|
'static/assets/foundation/transparent/a01-scroll-primary-v3.png' { @(1866, 276) }
|
|
'static/assets/foundation/transparent/a01-scroll-secondary-v3.png' { @(1866, 300) }
|
|
'static/assets/foundation/transparent/a01-scroll-toast-v3.png' { @(1770, 246) }
|
|
'static/assets/modules/auth/transparent/a01-scroll-dialog-v3.png' { @(1860, 1560) }
|
|
}
|
|
if ($width -ne $expectedSize[0] -or $height -ne $expectedSize[1]) { throw "$asset must be $($expectedSize[0]) x $($expectedSize[1])px." }
|
|
if (($corners | Where-Object { $_ -ne 0 }).Count -ne 0) { throw "$asset must have transparent outer corners." }
|
|
Write-Output "PASS $asset transparent corners and exact v3 slot ratio"
|
|
}
|
|
|
|
foreach ($asset in $v2Buttons) {
|
|
$bitmap = [System.Drawing.Bitmap]::FromFile((Join-Path $root $asset))
|
|
$width = [int]$bitmap.Width
|
|
$height = [int]$bitmap.Height
|
|
$corners = @(
|
|
$bitmap.GetPixel(0, 0).A,
|
|
$bitmap.GetPixel(($width - 1), 0).A,
|
|
$bitmap.GetPixel(0, ($height - 1)).A,
|
|
$bitmap.GetPixel(($width - 1), ($height - 1)).A
|
|
)
|
|
$bitmap.Dispose()
|
|
|
|
$expectedSize = switch ($asset) {
|
|
'static/assets/foundation/transparent/a01-primary-button-v2.png' { @(1866, 276) }
|
|
'static/assets/foundation/transparent/a01-secondary-button-v2.png' { @(1866, 300) }
|
|
}
|
|
if ($width -ne $expectedSize[0] -or $height -ne $expectedSize[1]) { throw "$asset must be $($expectedSize[0]) x $($expectedSize[1])px." }
|
|
if (($corners | Where-Object { $_ -ne 0 }).Count -ne 0) { throw "$asset must have transparent outer corners." }
|
|
Write-Output "PASS $asset transparent corners and exact runtime ratio"
|
|
}
|
|
|
|
foreach ($asset in $icons) {
|
|
$bitmap = [System.Drawing.Bitmap]::FromFile((Join-Path $root $asset))
|
|
$width = [int]$bitmap.Width
|
|
$height = [int]$bitmap.Height
|
|
$corners = @(
|
|
$bitmap.GetPixel(0, 0).A,
|
|
$bitmap.GetPixel(($width - 1), 0).A,
|
|
$bitmap.GetPixel(0, ($height - 1)).A,
|
|
$bitmap.GetPixel(($width - 1), ($height - 1)).A
|
|
)
|
|
$visiblePixels = 0
|
|
for ($y = 0; $y -lt $height; $y++) {
|
|
for ($x = 0; $x -lt $width; $x++) {
|
|
if ($bitmap.GetPixel($x, $y).A -gt 24) { $visiblePixels++ }
|
|
}
|
|
}
|
|
$bitmap.Dispose()
|
|
|
|
$expectedSize = switch ($asset) {
|
|
'static/assets/foundation/transparent/auth-divider-knot.png' { @(160, 96) }
|
|
'static/assets/foundation/transparent/auth-title-cloud.png' { @(200, 120) }
|
|
default { @(96, 96) }
|
|
}
|
|
if ($width -ne $expectedSize[0] -or $height -ne $expectedSize[1]) { throw "$asset must be $($expectedSize[0]) x $($expectedSize[1])px." }
|
|
if (($corners | Where-Object { $_ -ne 0 }).Count -ne 0) { throw "$asset has opaque outer corners." }
|
|
if ($visiblePixels -lt 80) { throw "$asset has no usable visible artwork." }
|
|
Write-Output "PASS $asset transparent corners and visible artwork"
|
|
}
|
|
|
|
foreach ($asset in $buttons) {
|
|
$bitmap = [System.Drawing.Bitmap]::FromFile((Join-Path $root $asset))
|
|
$width = [int]$bitmap.Width
|
|
$height = [int]$bitmap.Height
|
|
$corners = @(
|
|
$bitmap.GetPixel(0, 0).A,
|
|
$bitmap.GetPixel(($width - 1), 0).A,
|
|
$bitmap.GetPixel(0, ($height - 1)).A,
|
|
$bitmap.GetPixel(($width - 1), ($height - 1)).A
|
|
)
|
|
$chromaPixels = 0
|
|
for ($y = 0; $y -lt $height; $y++) {
|
|
for ($x = 0; $x -lt $width; $x++) {
|
|
$pixel = $bitmap.GetPixel($x, $y)
|
|
if ($pixel.G - [Math]::Max($pixel.R, $pixel.B) -gt 80 -and $pixel.G -gt 120) { $chromaPixels++ }
|
|
}
|
|
}
|
|
$bitmap.Dispose()
|
|
|
|
$ratio = [double]$width / $height
|
|
if ([Math]::Abs($ratio - 4.492) -gt 0.01) { throw "$asset must keep the approved 4.492:1 button ratio." }
|
|
if (($corners | Where-Object { $_ -ne 255 }).Count -ne 0) { throw "$asset must have opaque outer corners." }
|
|
if ($chromaPixels -ne 0) { throw "$asset retains chroma-key green pixels." }
|
|
Write-Output "PASS $asset opaque corners and approved button ratio"
|
|
}
|
|
|
|
Write-Output 'A01-ASSET-ALPHA-AUDIT PASS'
|