feat: export board as PNG image (Closes #6) #18

Closed
pawtrick wants to merge 1 commit from feat/export-board-png into main
Member

Closes #6

Changes

Server: Pure JS PNG Encoder (server/pngExport.js)

  • Zero external dependencies — uses Node.js built-in zlib for DEFLATE
  • RGBA color type (8-bit) with palette-to-pixel mapping
  • Full CRC32 chunk validation per PNG spec
  • Tested with 4x4 and 1024x1024 boards

API Endpoint

  • GET /api/board.png — generates PNG on-the-fly from current board state
  • Sets Content-Disposition: inline with filename
  • Increments board_exports metric

Client

  • Export button (📸) in header next to theme toggle
  • Downloads PNG with timestamped filename (pixel-clash-2026-05-15-00-53-22.png)
  • Loading state while generating

Testing

  • PNG encoder validated: correct signature, valid chunk structure
  • 4x4 test board generates valid 84-byte PNG
  • 1024x1024 board will produce ~200-500KB PNG (DEFLATE level 6)
Closes #6 ## Changes ### Server: Pure JS PNG Encoder (`server/pngExport.js`) - Zero external dependencies — uses Node.js built-in `zlib` for DEFLATE - RGBA color type (8-bit) with palette-to-pixel mapping - Full CRC32 chunk validation per PNG spec - Tested with 4x4 and 1024x1024 boards ### API Endpoint - `GET /api/board.png` — generates PNG on-the-fly from current board state - Sets `Content-Disposition: inline` with filename - Increments `board_exports` metric ### Client - Export button (📸) in header next to theme toggle - Downloads PNG with timestamped filename (`pixel-clash-2026-05-15-00-53-22.png`) - Loading state while generating ## Testing - PNG encoder validated: correct signature, valid chunk structure - 4x4 test board generates valid 84-byte PNG - 1024x1024 board will produce ~200-500KB PNG (DEFLATE level 6)
feat: export board as PNG image (Closes #6)
All checks were successful
CI / test (pull_request) Successful in 9s
51e83a78ed
- Add server/pngExport.js: pure JS PNG encoder (no external deps)
  - Uses Node.js built-in zlib for DEFLATE compression
  - Supports RGBA output with palette mapping
  - CRC32 chunk validation per PNG spec
- Add GET /api/board.png endpoint for server-side PNG generation
- Add export button (📸) in header with download trigger
- PNG filename includes timestamp for uniqueness
- Adds board_exports metric counter

Closes #6
pawtrick closed this pull request 2026-05-15 01:04:17 +00:00
All checks were successful
CI / test (pull_request) Successful in 9s

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
les_clankeurs/pixel-clash!18
No description provided.