title: How do I rotate a tetris block in p5.js?
body: <p>I'm representing tetris pieces as:</p>
  
  <pre><code>var jPiece = [
      [ true, false, false ],
      [ true, true,  true]
      ];
  </code></pre>
  
  <p>This is the L shaped piece, where false represents emptiness. Once it's rotated, it should look like</p>
  
  <pre><code>var jPiece = [
      [false, true],
      [false, true],
      [true, true],
  ]
  </code></pre>
  
  <p>I have a rotate function written like this:</p>
  
  <pre><code>function rotate1(L) {
      var result = [];
      var a;
      for (var col = 1; col &lt; (L[0].length) +1; col++) {
          //print("yeet");
          var result1 = [];
          for (var row = 0; row &lt; L.length; row++) {
              a = L[row][L.length - col];
              result1.push(a);
              print(a);
  
          }
          result.push(result1);
      }
      return result;
  }
  
  function rotateFallingPiece() {
      fallingPiece = rotate1(fallingPiece);
  
      fallingPieceCols = fallingPiece[0].length;
      if (fallingPieceIsLegal == false) {
          for (var i = 0; i &lt; 3; i ++) {
              fallingPiece = rotate1(fallingPiece);
              fallingPieceCols = fallingPiece[0].length;
          }
      }
      print(fallingPiece);
  }
  </code></pre>
  
  <p>however, when I run the rotate1(L) on a tetris piece, it doesn't rotate the entire piece, i.e, some of it is lost. please help!</p>