feat: 初始提交——一键运行快捷轮盘工具(WPF + C#)
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
# 像素级验证轮盘扇形间隙宽度(任意半径处应恒定 ≈ 10px)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
Add-Type -AssemblyName System.Drawing
|
||||
|
||||
foreach ($name in 'wheel-light', 'wheel-dark') {
|
||||
$path = "artifacts\$name.png"
|
||||
$bmp = [System.Drawing.Bitmap]::FromFile((Resolve-Path $path))
|
||||
$cx = [int]($bmp.Width / 2); $cy = [int]($bmp.Height / 2)
|
||||
Write-Output "=== $name ($($bmp.Width)x$($bmp.Height)) ==="
|
||||
|
||||
foreach ($radius in 100, 145, 200) {
|
||||
$steps = 7200
|
||||
$transparentRuns = New-Object System.Collections.Generic.List[double]
|
||||
$opaqueRuns = New-Object System.Collections.Generic.List[double]
|
||||
$runSteps = 0; $prevTransparent = $false
|
||||
for ($i = 0; $i -le $steps; $i++) {
|
||||
$ang = ($i / $steps) * 2 * [Math]::PI
|
||||
$x = [int][Math]::Round($cx + $radius * [Math]::Cos($ang))
|
||||
$y = [int][Math]::Round($cy + $radius * [Math]::Sin($ang))
|
||||
$px = $bmp.GetPixel($x, $y)
|
||||
$transparent = $px.A -lt 30
|
||||
if ($i -gt 0 -and $transparent -ne $prevTransparent) {
|
||||
$pxArc = $runSteps / $steps * 2 * [Math]::PI * $radius
|
||||
if ($prevTransparent) { $transparentRuns.Add($pxArc) } else { $opaqueRuns.Add($pxArc) }
|
||||
$runSteps = 0
|
||||
}
|
||||
$runSteps++; $prevTransparent = $transparent
|
||||
}
|
||||
$gaps = @($transparentRuns | Where-Object { $_ -gt 1 -and $_ -lt 40 })
|
||||
$sectors = @($opaqueRuns | Where-Object { $_ -gt 40 })
|
||||
$gapAvg = -1; $gapMin = -1; $gapMax = -1
|
||||
if ($gaps.Count -gt 0) {
|
||||
$gapAvg = ($gaps | Measure-Object -Average).Average
|
||||
$gapMin = ($gaps | Measure-Object -Minimum).Minimum
|
||||
$gapMax = ($gaps | Measure-Object -Maximum).Maximum
|
||||
}
|
||||
$line = '半径 {0}: 扇形段数={1}, 间隙段数={2}, 间隙宽度 均值={3:F2}px 最小={4:F2}px 最大={5:F2}px (期望≈10px 且处处相等)' -f $radius, $sectors.Count, $gaps.Count, $gapAvg, $gapMin, $gapMax
|
||||
Write-Output $line
|
||||
}
|
||||
$bmp.Dispose()
|
||||
}
|
||||
Reference in New Issue
Block a user