Take a flag, like this one:
-----------------------------
| | |
| | |
|=============+=============|
| | |
| | |
-----------------------------
And a number input: the "wave length"
Say the wave length was 5. Then, every 5 characters along the line from the beginning, replace the next character a -
with \
and shift all the characters after it one row down. Repeat this until the end. You end up with:
-----\
| -----\
| -----\
|===== | -----\
| ====== | -----
| ==+=== |
-----\ | ====== |
-----\ | ====|
-----\ |
-----\ |
-----
If you end up not being able to make a full wave length along at the end, the flag is finished. Just remain flat until the end.
You can assume that all the lines are of the same length and that the top and bottom lines are composed entirely of -
(0x2D) and the rest of the characters are in !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
, or is a space (). (So it's ascii value is
x
, where 31 < x < 127
)
The flag will be at least 3 tall and 3 wide.
Wave length will be a non-negative integer (>= 0).
(You can also have wave length 1 be the smallest wavelength, so the above example would have wave length 6. This is OK.)
Your i/o of flag can be as arrays of lines or a string with multiple lines.
The output flag may have trailing spaces, but can only have leading spaces so long as it is the same on every flag. Trailing space on an input flag may be deleted.
Scoring
This is code-golf, so the shortest solution, in bytes, wins.
Test cases
---
abc
---
2
--\
abc
--\
-----
| + |
-----
10
-----
| + |
-----
---------------------------------------
|&&&&&& &&&&&&|
|&&&&&& &&&&&&|
|&&&&&& &&&&&&|
|&&&&&& .\^/. &&&&&&|
|&&&&&& . | | . &&&&&&|
|&&&&&& |\| |/| &&&&&&|
|&&&&&& .--' '--. &&&&&&|
|&&&&&& \ / &&&&&&|
|&&&&&& > < &&&&&&|
|&&&&&& '~|/~~|~~\|~' &&&&&&|
|&&&&&& | &&&&&&|
|&&&&&& &&&&&&|
|&&&&&& &&&&&&|
---------------------------------------
12
------------\
|&&&&&& ------------\
|&&&&&& ------------\
|&&&&&& &&&&&&|
|&&&&&& &&&&&&|
|&&&&&& .\^/. &&&&&&|
|&&&&&& . | | . &&&&&&|
|&&&&&& . |\| |/| &&&&&&|
|&&&&&& --' '-- &&&&&&|
|&&&&&& \ /. &&&&&&|
|&&&&&& > < &&&&&&|
|&&&&&& '~|/~~|~~\|~' &&&&&&|
|&&&&&& | &&&&&&|
|&&&&&& &&&&&&|
------------\ &&&&&&|
------------\ &&&&&&|
------------\
-----------------------
|-._`-._ :| |: _.-'_.-|
| `-._`:| |:`_.-' |
|-------`-' '-'-------|
|------_.-. .-._------|
| _.-'_.:| |:._`-._ |
|-'_.-' :| |: `-._`-|
-----------------------
4
----\
|-._`----\
| `-._ :----\
|-----._`:| |: ----\
|-------`-| |:`_.-'_---
| _.--_.-' '-'_.-' .-|
|-'_.-'_.:. .-.----- |
----\-' :| |:._------|
----\| |: _`-._--|
----\ `-._ |
----\`-|
---
---------------
---------------
---------------
---------------
---------------
5
-----\
-----------\
---------------
---------------
-----\---------
-----\---
---
-------------------------------------------
|* * * * * |##########################|
| * * * * *| |
|* * * * * |##########################|
| * * * * *| |
|* * * * * |##########################|
| * * * * *| |
|* * * * * |##########################|
|--------------- |
|#########################################|
| |
|#########################################|
| |
|#########################################|
-------------------------------------------
0
\
|\
|*\
| \
|** \
| *\
|** \
| ** \
|** *\
|- ** \
|#- ** \
| #-** *\
|# #- ** \
| # #- ** \
\# # #-** *\
\# # #- ** \
\# # #- **|\
\# # #-** |#\
\# # #- **| #\
\# # #- |# #\
\# # #-**| # #\
\# # #- |# # #\
\# # #-| # # #\
\# # #-# # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # #\
\# # # # # # |
\# # # # # #|
\# # # # # |
\# # # # #|
\# # # # |
\# # # #|
\# # # |
\# # #|
\# # |
\# #|
\# |
\#|
\|
\