All problems

Linocut proof patterns shift sideways on successive scan rows

Level 1 · node · Data · Using visible width instead of the stored stride of padded raster rows

Scenario

A fictional linocut workshop stores grayscale proof scans in memory arrays. The storage device may add alignment cells at the end of each row. Small proofs without extra cells look correct, but proofs with extra cells display shifted patterns from the second row onward. Review the row decoder and preview entry point.

Requirements

preview(scan) accepts an object containing samples (an array of integers from 0 to 255), width (visible width), height (row count), and stride (stored row spacing). Width and height are nonnegative integers, stride is at least width, and samples has length height * stride. Return a new nested array containing only the first width values of each stored row. Do not display extra cells or mutate the input. Return an empty array for zero height and height empty rows for zero width.

Acceptance criteria

  • Restore all rows in order when stride equals visible width.
  • Restore only the actual pattern of each row even with extra cells at row ends.
  • Decode by position even when extra cells and actual pattern values are equal.
  • Handle zero height or width without changing the input array.