REPOSITORY CODING · HARD
Repair mask coverage and dimensions
Black mask pixels with nonzero alpha should transmit coverage. Separately, a mask with matching width and a different height must be rejected before composition. Repair both algorithm and validation.
Raster processingRaster compositor
Work through a real codebase.
Choose an environment, investigate the existing implementation and use the tests to check your change. Sign in to open a workspace; execution and Ono usage follow your plan’s allowances.
Task requirements and environments
C++ · 80 minute session
- Compose bounded, straight RGBA byte images on a transparent canvas. Pixels are row-major arrays [red,green,blue,alpha]. Images have unique IDs, dimensions 1..32 and matching pixel counts; at most 20 images and 20 layers are accepted.
- Each layer masks source alpha using the matching mask alpha (RGB is irrelevant), rotates clockwise by 0/90/180/270, optionally flips horizontally, then resizes using bilinear center-coordinate sampling with edge clamping and premultiplied colors. Mask dimensions must exactly match the original source.
- Place resized layers at integer x/y offsets in -32..32, clipping source coordinates correctly. Compose in input order with source-over alpha; keep floating precision internally and round each final straight RGBA channel to the nearest byte, halves upward. A zero-alpha pixel has zero RGB.
- Return {ok:true,value:{width,height,pixels}} or a stable validation error. Invalid input is atomic, not a partially composed result. The native HTTP preview and visible grading command use this same pipeline.