first commit
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
param(
|
||||
[string]$OutputDirectory = (Join-Path $PSScriptRoot '..\tests\fixtures')
|
||||
)
|
||||
|
||||
Add-Type -AssemblyName System.Drawing
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $OutputDirectory | Out-Null
|
||||
|
||||
function New-Fixture {
|
||||
param(
|
||||
[string]$Path,
|
||||
[int]$Width,
|
||||
[int]$Height,
|
||||
[int]$CellSize
|
||||
)
|
||||
|
||||
$bitmap = [System.Drawing.Bitmap]::new($Width, $Height)
|
||||
$graphics = [System.Drawing.Graphics]::FromImage($bitmap)
|
||||
$graphics.SmoothingMode = [System.Drawing.Drawing2D.SmoothingMode]::AntiAlias
|
||||
$graphics.TextRenderingHint = [System.Drawing.Text.TextRenderingHint]::AntiAliasGridFit
|
||||
|
||||
$bands = @(
|
||||
[System.Drawing.Color]::FromArgb(255, 246, 226),
|
||||
[System.Drawing.Color]::FromArgb(255, 218, 185),
|
||||
[System.Drawing.Color]::FromArgb(202, 234, 229),
|
||||
[System.Drawing.Color]::FromArgb(190, 218, 245)
|
||||
)
|
||||
$bandHeight = [math]::Ceiling($Height / $bands.Count)
|
||||
for ($index = 0; $index -lt $bands.Count; $index++) {
|
||||
$brush = [System.Drawing.SolidBrush]::new($bands[$index])
|
||||
$graphics.FillRectangle($brush, 0, $index * $bandHeight, $Width, $bandHeight)
|
||||
$brush.Dispose()
|
||||
}
|
||||
|
||||
$gridPen = [System.Drawing.Pen]::new([System.Drawing.Color]::FromArgb(125, 37, 54, 69), 2)
|
||||
for ($x = 0; $x -le $Width; $x += $CellSize) {
|
||||
$graphics.DrawLine($gridPen, $x, 0, $x, $Height)
|
||||
}
|
||||
for ($y = 0; $y -le $Height; $y += $CellSize) {
|
||||
$graphics.DrawLine($gridPen, 0, $y, $Width, $y)
|
||||
}
|
||||
$gridPen.Dispose()
|
||||
|
||||
$circleBrush = [System.Drawing.SolidBrush]::new([System.Drawing.Color]::FromArgb(215, 214, 72, 94))
|
||||
$circlePen = [System.Drawing.Pen]::new([System.Drawing.Color]::FromArgb(255, 120, 30, 58), 5)
|
||||
$circleSize = [math]::Min($Width, $Height) * 0.28
|
||||
$graphics.FillEllipse($circleBrush, $Width * 0.58, $Height * 0.18, $circleSize, $circleSize)
|
||||
$graphics.DrawEllipse($circlePen, $Width * 0.58, $Height * 0.18, $circleSize, $circleSize)
|
||||
$circleBrush.Dispose()
|
||||
$circlePen.Dispose()
|
||||
|
||||
$fontSize = [math]::Max(14, [math]::Floor($CellSize * 0.28))
|
||||
$font = [System.Drawing.Font]::new('Arial', $fontSize, [System.Drawing.FontStyle]::Bold)
|
||||
$textBrush = [System.Drawing.SolidBrush]::new([System.Drawing.Color]::FromArgb(255, 24, 44, 57))
|
||||
$columns = [math]::Ceiling($Width / $CellSize)
|
||||
$rows = [math]::Ceiling($Height / $CellSize)
|
||||
for ($row = 0; $row -lt $rows; $row++) {
|
||||
for ($column = 0; $column -lt $columns; $column++) {
|
||||
$number = $row * $columns + $column + 1
|
||||
$graphics.DrawString([string]$number, $font, $textBrush, $column * $CellSize + 8, $row * $CellSize + 7)
|
||||
}
|
||||
}
|
||||
|
||||
$bitmap.Save($Path, [System.Drawing.Imaging.ImageFormat]::Png)
|
||||
$font.Dispose()
|
||||
$textBrush.Dispose()
|
||||
$graphics.Dispose()
|
||||
$bitmap.Dispose()
|
||||
}
|
||||
|
||||
New-Fixture (Join-Path $OutputDirectory 'landscape.png') 800 400 100
|
||||
New-Fixture (Join-Path $OutputDirectory 'portrait.png') 200 800 100
|
||||
Write-Output "Created fixtures in $OutputDirectory"
|
||||
Reference in New Issue
Block a user