This is similar to my first version of Tetris, which I wrote many years ago when I was studying Pascal.
I recently wrote another version to experiment with Javascript.
This time I used this structure to represent tetrominones:
gameboard.colors = ['black','red','brown','cyan','orange','magenta','yellow','green']; gameboard.tetrominoes = { O: [[[0,0,0,0], [0,0,0,0], [0,0,0,0], [0,0,0,0]], [[0,1,1,0], [0,1,1,0], [0,1,1,0], [0,1,1,0]], [[0,1,1,0], [0,1,1,0], [0,1,1,0], [0,1,1,0]], [[0,0,0,0], [0,0,0,0], [0,0,0,0], [0,0,0,0]]], I: [[[0,0,0,0], [0,0,2,0], [0,0,0,0], [0,0,2,0]], [[2,2,2,2], [0,0,2,0], [2,2,2,2], [0,0,2,0]], [[0,0,0,0], [0,0,2,0], [0,0,0,0], [0,0,2,0]], [[0,0,0,0], [0,0,2,0], [0,0,0,0], [0,0,2,0]]], S: [[[0,0,0,0], [0,0,3,0], [0,0,0,0], [0,0,3,0]], [[0,0,3,3], [0,0,3,3], [0,0,3,3], [0,0,3,3]], [[0,3,3,0], [0,0,0,3], [0,3,3,0], [0,0,0,3]], [[0,0,0,0], [0,0,0,0], [0,0,0,0], [0,0,0,0]]], Z: [[[0,0,0,0], [0,0,0,4], [0,0,0,0], [0,0,0,4]], [[0,4,4,0], [0,0,4,4], [0,4,4,0], [0,0,4,4]], [[0,0,4,4], [0,0,4,0], [0,0,4,4], [0,0,4,0]], [[0,0,0,0], [0,0,0,0], [0,0,0,0], [0,0,0,0]]], L: [[[0,0,0,0], [0,0,5,0], [0,0,0,5], [0,5,5,0]], [[0,5,5,5], [0,0,5,0], [0,5,5,5], [0,0,5,0]], [[0,5,0,0], [0,0,5,5], [0,0,0,0], [0,0,5,0]], [[0,0,0,0], [0,0,0,0], [0,0,0,0], [0,0,0,0]]], J: [[[0,0,0,0], [0,0,6,6], [0,6,0,0], [0,0,6,0]], [[0,6,6,6], [0,0,6,0], [0,6,6,6], [0,0,6,0]], [[0,0,0,6], [0,0,6,0], [0,0,0,0], [0,6,6,0]], [[0,0,0,0], [0,0,0,0], [0,0,0,0], [0,0,0,0]]], T: [[[0,0,0,0], [0,0,7,0], [0,0,7,0], [0,0,7,0]], [[0,7,7,7], [0,0,7,7], [0,7,7,7], [0,7,7,0]], [[0,0,7,0], [0,0,7,0], [0,0,0,0], [0,0,7,0]], [[0,0,0,0], [0,0,0,0], [0,0,0,0], [0,0,0,0]]] };
where each number represents a color. I found it more convenient, plus I did not have to use the "rotate" function.