# Raster core - `src/raster/index.cjs` exposes the synchronous CommonJS API. It composites in back-to-front call order, places and rescales transparent layers, and applies a shared warm varnish, seeded fine craquelure, and soft aperture shadow. - `src/raster/png.cjs` decodes PNG using Node built-ins, including packed, indexed, 16-bit, and Adam7 inputs. It emits deterministic, non-interlaced RGBA8 PNG with fixed filtering and compression settings. - `test/raster/core.test.cjs` generates PNG and raster fixtures in memory and verifies the codec, compositing, placement, finish, and cross-process reproducibility. ## API Load `src/raster/index.cjs` using `require`. A raster is `{ width, height, data: Uint8Array }`, with `Buffer` accepted for `data`. Each pixel occupies four bytes in straight, unpremultiplied RGBA order. Rows are tightly packed. The top-left pixel is the origin, x increases rightward, and y increases downward. | Call | Behavior | | --- | --- | | `createImage(width = 2048, height = 2560)` | Returns a transparent raster. | | `decodePNG(bytes, target?)` | Returns a raster from PNG bytes. An optional exact-size `Uint8Array` becomes its data buffer. | | `composite(destination, source, rect?)` | Applies source-over in place and returns the destination. The default placement is the source size at the origin. | | `finish(image, seed)` | Mutates RGB in place, preserves alpha, and returns the image. Pass nonempty seed bytes as a `Uint8Array` or `Buffer`. | | `encodePNG(image)` | Returns a PNG `Buffer`. | Read and decode one selected layer at a time. A single 20 MiB decode target serves consecutive master-sized layers. Apply each layer before reusing that target. Keep the target, destination, and PNG input storage disjoint. Call `finish` once on the complete composite, then encode. The core accepts the caller's derived seed bytes directly. ## Alignment and integration - The exported `MASTER_WIDTH` and `MASTER_HEIGHT` are 2048 and 2560. `FRAME_APERTURE` is `{ x: 144, y: 144, width: 1760, height: 2224 }` and excludes the right and bottom boundaries. The shadow fades over the first 44 master pixels inside the opening. - Reuse one shield raster at `{ x: 1500, y: 340, width: 240, height: 288 }` and `{ x: 974, y: 2404, width: 100, height: 120 }`. Rectangles use integer pixels, exclude the bottom and right edges, and apply alpha-weighted bilinear sampling when scaled. The rail shield should be placed above the frame in the stack if the frame art is opaque there. - Export all layers in a common sRGB space. The decoder reads stored samples without applying embedded color profiles and the encoder omits ancillary metadata. The integration worker can inspect the actual frame edge and shield padding when the painted assets land. Byte identity was checked on the installed Node/zlib build. ## Checks - `node --check src/raster/index.cjs` and `node --check src/raster/png.cjs` both exited 0. - `node --test test/raster/core.test.cjs` on Node v24.21.0 passed all 8 tests. The suite checked straight-alpha ordering, transparent edges, reusable decode storage, indexed and 16-bit transparency, interlaced decoding, both shield placements, seeded finish repeatability, preserved alpha, and the aperture shadow. Two fresh Node processes produced identical 2048×2560 PNG buffers. - `git diff --no-index --check /dev/null ` reported no whitespace errors on the four deliverables. `git status --short --untracked-files=all` listed only the two source files and the test. The named result was checked separately. Staging the three code and test files was blocked by the read-only Git index, so they remain in the checkout and this result remains untracked for upload.