ASCII rhombic grid
SOGL V0.12, 20 bytes
ā.I∫e+H╚╬8}:±№╬8╬¡∙*
Try it Here! Takes the input in the reversed order of what they are in the examples - r, s, n, m.
Explanation:
ā push an empty array - canvas
.I∫ } for each in range(input) (1-indexed)
e+ add the second input
H decrement
╚ create a diagonal of that size
╬8 insert into the canvas
: create a duplicate of the canvas
±№ reverse it vertically and horizotally
╬8 insert that into the canvas
έ quad-palindromize
∙ multiply vertically by the next input
* multiply horizontally by the next input
Charcoal, 48 39 37 bytes
UO⊕Iε\F⊖IζC¹¦¹‖ML≔⊗⁺IζIεδF⊖NCδ⁰F⊖NC⁰δ
Try it online! Link is to verbose version of code. Explanation:
UO⊕Iε\
Draw a square of size r + 1
. This is a quarter of a nested diamond of size 1.
F⊖IζC¹¦¹
Copy the square 1 square right and down s - 1
times to get it to the right size.
‖ML
Reflect it to become a full nested diamond.
≔⊗⁺IζIεδ
Compute the size of this nested diamond.
F⊖NCδ⁰
Copy the diamond to the right m - 1
times.
F⊖NC⁰δ
Copy the diamond downwards n - 1
times.
Python 2, 160 159 158 bytes
-1 byte thanks to Jonathan Frech
m,n,s,r=input()
l=~-s*' '+'/'*(r-~r)+~-s*' '
for x in range(n*2):print'\n'.join(m*(l[i:i+s+r]+l.replace(*'/\\')[i:i+s+r][::-1])for i in range(r+s))[::1-x%2*2]
Try it online!
This uses the fact that the bottom of the rhombus is the top inverted ([::-1]
), iterating over range(n*2)
and using ~x%2*2-1
to control if it is the top or the bottom.
For the top (and the bottom) the right side is just the left side inverted and replacing /
with \
-> l.replace(*'/\\')..[::-1]
To generate the pattern / nesting ~-s*' '+'/'*(1+r*2)+~-s*' '
is used to make a string like ///
that will be iterated and chopped :
'| //|/ '
' | ///| '
' |/// | '
' /|// |'