feat(items): extract tier-1 item icons from the art sheet
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
65
tools/extract-item-icons.ps1
Normal file
65
tools/extract-item-icons.ps1
Normal file
@@ -0,0 +1,65 @@
|
||||
# tools/extract-item-icons.ps1
|
||||
# Crops the Tier-1 item icons out of art/Items.png into apps/web/public/images/items.
|
||||
# Re-runnable: overwrites its own output and touches nothing else.
|
||||
$ErrorActionPreference = 'Stop'
|
||||
Add-Type -AssemblyName System.Drawing
|
||||
|
||||
$root = Split-Path -Parent $PSScriptRoot
|
||||
$sheet = Join-Path $root 'art\Items.png'
|
||||
$ratPortrait = Join-Path $root 'art\enemies\AschenratteIcon.png'
|
||||
$outDir = Join-Path $root 'apps\web\public\images\items'
|
||||
New-Item -ItemType Directory -Force -Path $outDir | Out-Null
|
||||
|
||||
function Export-Icon {
|
||||
param(
|
||||
[System.Drawing.Image] $Source,
|
||||
[int] $X, [int] $Y, [int] $Size,
|
||||
[string] $Key
|
||||
)
|
||||
$bitmap = New-Object System.Drawing.Bitmap 256, 256
|
||||
$graphics = [System.Drawing.Graphics]::FromImage($bitmap)
|
||||
$graphics.InterpolationMode = [System.Drawing.Drawing2D.InterpolationMode]::HighQualityBicubic
|
||||
$graphics.DrawImage(
|
||||
$Source,
|
||||
(New-Object System.Drawing.Rectangle 0, 0, 256, 256),
|
||||
(New-Object System.Drawing.Rectangle $X, $Y, $Size, $Size),
|
||||
[System.Drawing.GraphicsUnit]::Pixel)
|
||||
$graphics.Dispose()
|
||||
$bitmap.Save((Join-Path $outDir "$Key.png"), [System.Drawing.Imaging.ImageFormat]::Png)
|
||||
$bitmap.Dispose()
|
||||
Write-Host "wrote $Key.png"
|
||||
}
|
||||
|
||||
$items = [System.Drawing.Image]::FromFile($sheet)
|
||||
try {
|
||||
# Rows 1-2: cells are 350 wide with a caption strip at the bottom, so the
|
||||
# artwork is the 300x300 square inset by 25px horizontally.
|
||||
$columns = 8, 366, 724, 1082
|
||||
$rowOne = 'worn-short-sword', 'bandit-blade', 'ash-blade', 'bandit-hood'
|
||||
$rowTwo = 'reinforced-leather-jacket', 'raider-gloves', 'guardsman-legs', 'ash-boots'
|
||||
|
||||
for ($i = 0; $i -lt 4; $i++) {
|
||||
Export-Icon -Source $items -X ($columns[$i] + 25) -Y 8 -Size 300 -Key $rowOne[$i]
|
||||
Export-Icon -Source $items -X ($columns[$i] + 25) -Y 364 -Size 300 -Key $rowTwo[$i]
|
||||
}
|
||||
|
||||
# Row 3 is centred and shorter: three cells, 262x262 artwork inset by 44px.
|
||||
$rowThreeColumns = 191, 549, 907
|
||||
$rowThree = 'borderwatch-sigil', 'burned-captain-pendant', 'small-healing-potion'
|
||||
for ($i = 0; $i -lt 3; $i++) {
|
||||
Export-Icon -Source $items -X ($rowThreeColumns[$i] + 44) -Y 720 -Size 262 -Key $rowThree[$i]
|
||||
}
|
||||
}
|
||||
finally {
|
||||
$items.Dispose()
|
||||
}
|
||||
|
||||
# STAND-IN ART: no Aschenfell artwork exists yet, so the pelt icon is a scorched
|
||||
# hide patch cropped from the Aschenratte portrait. Replace when real art lands.
|
||||
$rat = [System.Drawing.Image]::FromFile($ratPortrait)
|
||||
try {
|
||||
Export-Icon -Source $rat -X 760 -Y 300 -Size 320 -Key 'ash-pelt'
|
||||
}
|
||||
finally {
|
||||
$rat.Dispose()
|
||||
}
|
||||
Reference in New Issue
Block a user