Skip to content

Work out where the windows go over a region #32

Description

@KurbyDoo

Description

Create a function that takes a region height and width, a window size, and a step size, and returns the list of top left positions to place windows at. The step is smaller than the window, which is what makes them overlap.

Every cell in the region has to be covered by at least one window and no window can hang off the edge. When the step does not divide evenly, push the last window in a row or column back so it sits flush against the edge. It will overlap its neighbour more than the others, which is fine.

For example a region 8 wide with a window of 4 and a step of 3 gives columns

0 3 4

and not

0 3 6

since a window at 6 would run off the end.

Testing:

  • Assert every cell in the region is covered by at least one window
  • Assert no window extends past the region
  • Assert a region exactly one window in size returns one position
  • Assert a region whose size does not divide evenly by the step still covers the far edge

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions