feat: container packing simulator + Android shell

- web/packing: scan-sweep planner (bottom-up X/Y sweep, all items per cell),
  multi-direction candidates, gap fill, stack/capacity/rigid-body checks,
  theoretical fill bound with red warning, occupancy voxel metrics
- per-item params via right-click menu (upright, stack count, capacity,
  box/voxel fit, mass); simplified left panel
- 3D: pan/zoom/rotate mouse mapping, touch gestures, draggable XYZ compass
- android: offline WebView APK build pipeline (aapt2/javac/d8/apksigner)
- docs: packing preview and mobile screenshots
This commit is contained in:
OpenCode
2026-11-26 15:26:16 +08:00
parent 31301824c4
commit 20567c0781
34 changed files with 3599 additions and 0 deletions
+169
View File
@@ -0,0 +1,169 @@
# Generates Android launcher icons: isometric wireframe cube + voxel mid-planes.
# Usage: Set-ExecutionPolicy -Scope Process Bypass; .\android\tools\make-icons.ps1
$ErrorActionPreference = 'Stop'
Add-Type -AssemblyName System.Drawing
$root = (Resolve-Path "$PSScriptRoot\..").Path
$res = Join-Path $root 'app\src\main\res'
$k = [Math]::Cos([Math]::PI / 6.0)
$tmp = Join-Path $env:TEMP 'occupancy-icon'
function New-Glyph {
param([int]$Size, [double]$S)
$bmp = [System.Drawing.Bitmap]::new($Size, $Size)
$g = [System.Drawing.Graphics]::FromImage($bmp)
$g.SmoothingMode = [System.Drawing.Drawing2D.SmoothingMode]::AntiAlias
$g.Clear([System.Drawing.Color]::Transparent)
$cx = $Size / 2.0
$cy = $Size / 2.0
$project = {
param($x, $y, $z)
[System.Drawing.PointF]::new(
[float]($cx + ($x - $y) * $k * $S),
[float]($cy + (($x + $y) * 0.5 - $z) * $S))
}
$verts = @()
foreach ($x in @(-1.0, 1.0)) {
foreach ($y in @(-1.0, 1.0)) {
foreach ($z in @(-1.0, 1.0)) {
$verts += [pscustomobject]@{ X = $x; Y = $y; Z = $z }
}
}
}
$edges = @()
for ($i = 0; $i -lt $verts.Count; $i++) {
for ($j = $i + 1; $j -lt $verts.Count; $j++) {
$a = $verts[$i]
$b = $verts[$j]
$diff = 0
if ($a.X -ne $b.X) { $diff++ }
if ($a.Y -ne $b.Y) { $diff++ }
if ($a.Z -ne $b.Z) { $diff++ }
if ($diff -eq 1) { $edges += , @($a, $b) }
}
}
$cyan = [System.Drawing.Color]::FromArgb(255, 0x5F, 0xE8, 0xFF)
$glow = [System.Drawing.Pen]::new([System.Drawing.Color]::FromArgb(34, 0x5F, 0xE8, 0xFF), [float]($S * 0.20))
$main = [System.Drawing.Pen]::new($cyan, [float]($S * 0.062))
$inner = [System.Drawing.Pen]::new([System.Drawing.Color]::FromArgb(70, 0x5F, 0xE8, 0xFF), [float]($S * 0.022))
$accent = [System.Drawing.Pen]::new([System.Drawing.Color]::FromArgb(220, 0xFF, 0x8A, 0x3D), [float]($S * 0.045))
$main.LineJoin = [System.Drawing.Drawing2D.LineJoin]::Round
$inner.LineJoin = [System.Drawing.Drawing2D.LineJoin]::Round
$glow.LineJoin = [System.Drawing.Drawing2D.LineJoin]::Round
foreach ($e in $edges) {
$g.DrawLine($glow, (& $project $e[0].X $e[0].Y $e[0].Z), (& $project $e[1].X $e[1].Y $e[1].Z))
}
$rings = @(
, @(@(0.0, -1.0, -1.0), @(0.0, 1.0, -1.0), @(0.0, 1.0, 1.0), @(0.0, -1.0, 1.0))
, @(@(-1.0, 0.0, -1.0), @(1.0, 0.0, -1.0), @(1.0, 0.0, 1.0), @(-1.0, 0.0, 1.0))
, @(@(-1.0, -1.0, 0.0), @(1.0, -1.0, 0.0), @(1.0, 1.0, 0.0), @(-1.0, 1.0, 0.0))
)
foreach ($ring in $rings) {
for ($i = 0; $i -lt 4; $i++) {
$p1 = $ring[$i]
$p2 = $ring[($i + 1) % 4]
$g.DrawLine($inner, (& $project $p1[0] $p1[1] $p1[2]), (& $project $p2[0] $p2[1] $p2[2]))
}
}
foreach ($e in $edges) {
$g.DrawLine($main, (& $project $e[0].X $e[0].Y $e[0].Z), (& $project $e[1].X $e[1].Y $e[1].Z))
}
# one "occupied" voxel edge, highlighted in orange
$g.DrawLine($accent, (& $project 1.0 -1.0 1.0), (& $project 1.0 -1.0 -1.0))
$g.Dispose()
return $bmp
}
if (-not (Test-Path $tmp)) { New-Item -ItemType Directory -Path $tmp | Out-Null }
$glyph = New-Glyph -Size 1024 -S 190
$glyph.Save((Join-Path $tmp 'glyph.png'), [System.Drawing.Imaging.ImageFormat]::Png)
function New-RoundedPath {
param([int]$Size, [double]$Radius)
$p = [System.Drawing.Drawing2D.GraphicsPath]::new()
$d = $Radius * 2
$p.AddArc(0, 0, [float]$d, [float]$d, 180, 90)
$p.AddArc([float]($Size - $d), 0, [float]$d, [float]$d, 270, 90)
$p.AddArc([float]($Size - $d), [float]($Size - $d), [float]$d, [float]$d, 0, 90)
$p.AddArc(0, [float]($Size - $d), [float]$d, [float]$d, 90, 90)
$p.CloseFigure()
return $p
}
$bg = [System.Drawing.Color]::FromArgb(255, 0x0B, 0x10, 0x18)
$bgInner = [System.Drawing.Color]::FromArgb(255, 0x10, 0x1A, 0x28)
$bgEdge = [System.Drawing.Color]::FromArgb(90, 0x2A, 0x53, 0x6B)
foreach ($d in @(@('mdpi', 48), @('hdpi', 72), @('xhdpi', 96), @('xxhdpi', 144), @('xxxhdpi', 192))) {
$name = $d[0]
$size = [int]$d[1]
$bmp = [System.Drawing.Bitmap]::new($size, $size)
$g = [System.Drawing.Graphics]::FromImage($bmp)
$g.SmoothingMode = [System.Drawing.Drawing2D.SmoothingMode]::AntiAlias
$g.InterpolationMode = [System.Drawing.Drawing2D.InterpolationMode]::HighQualityBicubic
$g.Clear([System.Drawing.Color]::Transparent)
$path = New-RoundedPath -Size $size -Radius ([double]($size * 0.23))
$rect = [System.Drawing.Rectangle]::new(0, 0, $size, $size)
$brush = [System.Drawing.Drawing2D.LinearGradientBrush]::new(
$rect, $bgInner, $bg, [System.Drawing.Drawing2D.LinearGradientMode]::Vertical)
$g.FillPath($brush, $path)
$pen = [System.Drawing.Pen]::new($bgEdge, [float][Math]::Max(1.0, $size * 0.012))
$g.DrawPath($pen, $path)
$side = [double]($size * 0.74)
$ox = ($size - $side) / 2.0
$g.DrawImage($glyph, [System.Drawing.RectangleF]::new([float]$ox, [float]$ox, [float]$side, [float]$side))
$dir = Join-Path $res "mipmap-$name"
New-Item -ItemType Directory -Force -Path $dir | Out-Null
$bmp.Save((Join-Path $dir 'ic_launcher.png'), [System.Drawing.Imaging.ImageFormat]::Png)
$g.Dispose(); $bmp.Dispose(); $path.Dispose(); $brush.Dispose(); $pen.Dispose()
}
foreach ($d in @(@('mdpi', 108), @('hdpi', 162), @('xhdpi', 216), @('xxhdpi', 324), @('xxxhdpi', 432))) {
$name = $d[0]
$size = [int]$d[1]
$bmp = [System.Drawing.Bitmap]::new($size, $size)
$g = [System.Drawing.Graphics]::FromImage($bmp)
$g.SmoothingMode = [System.Drawing.Drawing2D.SmoothingMode]::AntiAlias
$g.InterpolationMode = [System.Drawing.Drawing2D.InterpolationMode]::HighQualityBicubic
$g.Clear([System.Drawing.Color]::Transparent)
$side = [double]($size * 0.62)
$ox = ($size - $side) / 2.0
$g.DrawImage($glyph, [System.Drawing.RectangleF]::new([float]$ox, [float]$ox, [float]$side, [float]$side))
$dir = Join-Path $res "drawable-$name"
New-Item -ItemType Directory -Force -Path $dir | Out-Null
$bmp.Save((Join-Path $dir 'ic_launcher_foreground.png'), [System.Drawing.Imaging.ImageFormat]::Png)
$g.Dispose(); $bmp.Dispose()
}
# 1024px preview with background, for eyeballing
$preview = [System.Drawing.Bitmap]::new(1024, 1024)
$pg = [System.Drawing.Graphics]::FromImage($preview)
$pg.SmoothingMode = [System.Drawing.Drawing2D.SmoothingMode]::AntiAlias
$pg.InterpolationMode = [System.Drawing.Drawing2D.InterpolationMode]::HighQualityBicubic
$pg.Clear($bg)
$path = New-RoundedPath -Size 1024 -Radius 235
$brush = [System.Drawing.Drawing2D.LinearGradientBrush]::new(
[System.Drawing.Rectangle]::new(0, 0, 1024, 1024), $bgInner, $bg, [System.Drawing.Drawing2D.LinearGradientMode]::Vertical)
$pg.FillPath($brush, $path)
$pg.DrawImage($glyph, [System.Drawing.RectangleF]::new(128, 128, 768, 768))
$preview.Save((Join-Path $root 'icon-preview.png'), [System.Drawing.Imaging.ImageFormat]::Png)
$pg.Dispose(); $preview.Dispose(); $glyph.Dispose()
Write-Output "icons written to $res"