Here is the unwoven warp of a 7×4 loom:
||||||| ||||||| ||||||| |||||||
There are a number of ways the weft can be woven into the warp, the simplest being the plain weave.
In the first row of a plain weave the weft starts above the first warp string, goes below the second string, then above the third string, then below the fourth, and so on.
The second weft row is identical to the first but offset to the right by one warp string, so it starts under then goes over, and so on.
On our 7×4 loom the plain weave looks like this:
-|-|-|- |-|-|-| -|-|-|- |-|-|-|
We can describe the plain weave by saying that the weft goes over the warp 1 time, then under 1 time, and each subsequent row is shifted 1 string to the right.
A generalized weave can be described by having the weft go over the warp v times, then under u times, with each subsequent row shifted by s strings to the right. (All values are integers, s may be 0 or negative, u and v must be non-negative.)
A 7×4 loom with v = 1, u = 2, s = 2, a type of twill weave:
-||-||- ||-||-| |-||-|| -||-||-
Your task is to write the shortest program (in bytes) that produces a woven pattern of bars and dashes given v, u, s, the width and height of the loom, and the initial shift.
The initial shift is the number of strings the first row in the weft is shifted to the right (0 in the examples above). Each subsequent row is shifted by s more strings.
Your program should take in these 6 numbers in some easy to use format (stdin, a function call, etc.) and output the woven grid of bars and rectangles to stdout. You may assume all input is valid. (All values are integers, width and height must be positive, initial shift may be anything.)
width = 5, height = 4, initial shift = 0, v = 1, u = 3, s = -2:
-|||- ||-|| -|||- ||-||
width = 5, height = 4, initial shift = 3, v = 1, u = 3, s = -2:
|||-| |-||| |||-| |-|||
width = 5, height = 4, initial shift = 1, v = 1, u = 1, s = 0:
|-|-| |-|-| |-|-| |-|-|
width = 5, height = 4, initial shift = 0, v = 1, u = 0, s = 0:
----- ----- ----- -----
- The pattern always starts with the weft over the warp at the top left corner of the grid (unless initially shifted).
- All the weft threads come in from the left. They do not spiral like this.
- u + v is not necessarily a multiple of the grid width.
- u and v may not both be 0