I have a piece-wise 2-input function that I would like to repeatedly tile diagonally across a grid. See this image.
So here, I know the equations of the pink, blue and green areas in the range 0 - 2.
My problem is that I'm having trouble finding a way to tile the function diagonally across like shown in the image by transforming the inputs. I tried using $\mod (x_1 = x_1 \mod 2, x_2 = x_2 \mod 2)$ to transform the input, and it worked somewhat, but it was wrong at grids $(2-3, 1-2)$, $(1-2, 2-3)$, $(4-5, 3-4)$ and $(3-4, 4-5)$.
Any help is appreciated!