Challenge
Given two integer values \$a \ge 2\$ and \$0 \le b < a\$, generate a \$(2a-1) \times (2a-1)\$ matrix consisting of the integers 0, 1, and 2 as follows:
- Create a checkerboard of 0s and 1s of the given size, corners being 0.
- If \$b > 0\$, overwrite the checkerboard with 2s in the X shape at the center, each leg being of length \$b\$ (not counting the center).
This pattern is directly modeled from Art Puzzle event grids (where \$a\$ is fixed at 3, \$b=0,1,2\$ represent easy/normal/hard grids, and the 0, 1, 2s in the output represent easy/normal/hard minipuzzles respectively). Blame it if you don't like the edge case of \$b=0\$ :P
Standard code-golf rules apply. The shortest code in bytes wins.
Test cases
a = 2, b = 0
[[0, 1, 0],
[1, 0, 1],
[0, 1, 0]]
a = 2, b = 1
[[2, 1, 2],
[1, 2, 1],
[2, 1, 2]]
a = 3, b = 0
[[0, 1, 0, 1, 0],
[1, 0, 1, 0, 1],
[0, 1, 0, 1, 0],
[1, 0, 1, 0, 1],
[0, 1, 0, 1, 0]]
a = 3, b = 1
[[0, 1, 0, 1, 0],
[1, 2, 1, 2, 1],
[0, 1, 2, 1, 0],
[1, 2, 1, 2, 1],
[0, 1, 0, 1, 0]]
a = 3, b = 2
[[2, 1, 0, 1, 2],
[1, 2, 1, 2, 1],
[0, 1, 2, 1, 0],
[1, 2, 1, 2, 1],
[2, 1, 0, 1, 2]]
a = 4, b = 0
[[0, 1, 0, 1, 0, 1, 0],
[1, 0, 1, 0, 1, 0, 1],
[0, 1, 0, 1, 0, 1, 0],
[1, 0, 1, 0, 1, 0, 1],
[0, 1, 0, 1, 0, 1, 0],
[1, 0, 1, 0, 1, 0, 1],
[0, 1, 0, 1, 0, 1, 0]]
a = 4, b = 1
[[0, 1, 0, 1, 0, 1, 0],
[1, 0, 1, 0, 1, 0, 1],
[0, 1, 2, 1, 2, 1, 0],
[1, 0, 1, 2, 1, 0, 1],
[0, 1, 2, 1, 2, 1, 0],
[1, 0, 1, 0, 1, 0, 1],
[0, 1, 0, 1, 0, 1, 0]]
a = 4, b = 2
[[0, 1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