seedhammer-v1-companion/image/alpha4/alpha4_test.go
mineracks 9261cf368a Lift composer substrate from upstream v1.3.0
Twelve packages lifted from seedhammer/seedhammer @ v1.3.0
(commit 2f071c1d8f23eb7fd39b15fc0acb8874113f801e):

  address/     — bitcoin address parsing
  backup/      — v1 plate dimensions + UR-coded multi-plate backup
  bc/          — Blockchain Commons: ur, fountain, bytewords, urtypes,
                 xoshiro256 (5 subpkgs)
  bip32/       — HD-key derivation
  bip39/       — mnemonic seed phrases + 2048-word wordlist
  engrave/     — text/QR → MoveTo/LineTo command stream conversion
  seedqr/      — SeedQR / CompactSeedQR encoders
  image/       — paletted, rgb565, alpha4, ninepatch image formats
  nonstandard/ — bitcoin descriptor + script parsing
  font/        — bitmap + vector font runtime
  font/{comfortaa,poppins,constant,bitmap,vector}/  — actual fonts
  driver/mjolnir/  — MarkingWay USB-serial engraver driver

Plus an earlier-aside backup_test.go restored (its deps are now lifted).

Import paths globally rewritten seedhammer.com → mineracks namespace
via single sed pass; verified no orphan refs remain. go.mod adopts
upstream's full dep set plus the replace-directive for the patched
kortschak/qr fork.

  go build ./...     clean (all 27 packages)
  go test ./...      clean (12 packages with tests, all passing)

NOT lifted in this commit:
  - driver/{wshat,drm,libcamera}  (hardware-specific GPIO/LCD/camera —
    will be platform-v1/-shaped abstractions instead)
  - gui/                (depends on the above; lifts in Phase 2)
  - cmd/{controller,...} (Pi binary entrypoints — not needed for the
    companion repo)
  - zbar/               (QR scanner — needs libcamera)

Next:
  - Write the SH1E reference encoder/decoder in engrave/wire/sh1e/
  - Lift Gangleri42's cmd/webnfc/ shell + retune to v1 plates
  - First buildable composer WASM with a working preview

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-28 18:36:40 +10:00

33 lines
926 B
Go

package alpha4
import (
"bytes"
"image"
"image/color"
"image/draw"
"testing"
)
func TestExhausting(t *testing.T) {
r := Rectangle{10, 10, 12, 12}
img1 := image.NewAlpha(r.Rect())
a4 := New(r)
img2 := image.NewAlpha(img1.Rect)
for a1 := byte(0); a1 <= 0b1111; a1++ {
for a2 := byte(0); a2 <= 0b1111; a2++ {
for a3 := byte(0); a3 <= 0b1111; a3++ {
img1.SetAlpha(10, 10, color.Alpha{A: a1<<4 | a1})
img1.SetAlpha(11, 10, color.Alpha{A: a2<<4 | a2})
img1.SetAlpha(10, 11, color.Alpha{A: a3<<4 | a3})
draw.Draw(a4, a4.Bounds(), img1, img1.Bounds().Min, draw.Src)
draw.Draw(img2, img2.Bounds(), a4, a4.Bounds().Min, draw.Src)
if !bytes.Equal(img1.Pix, img2.Pix) {
t.Errorf("%.8b %.8b %.8b roundtripped to %.8b %.8b %.8b",
img1.AlphaAt(10, 10), img1.AlphaAt(11, 10), img1.AlphaAt(10, 11),
img2.AlphaAt(10, 10), img2.AlphaAt(11, 10), img2.AlphaAt(11, 10))
}
}
}
}
}