docs: function scorePattern(point, ratios, matrix) {
          try {
              const horizontalRun = countBlackWhiteRun(point, { x: -1, y: point.y }, matrix, ratios.length);
              const verticalRun = countBlackWhiteRun(point, { x: point.x, y: -1 }, matrix, ratios.length);
              const topLeftPoint = {
                  x: Math.max(0, point.x - point.y) - 1,
                  y: Math.max(0, point.y - point.x) - 1,
              };
              const topLeftBottomRightRun = countBlackWhiteRun(point, topLeftPoint, matrix, ratios.length);
              const bottomLeftPoint = {
                  x: Math.min(matrix.width, point.x + point.y) + 1,
                  y: Math.min(matrix.height, point.y + point.x) + 1,
              };
              const bottomLeftTopRightRun = countBlackWhiteRun(point, bottomLeftPoint, matrix, ratios.length);
              const horzError = scoreBlackWhiteRun(horizontalRun, ratios);
              const vertError = scoreBlackWhiteRun(verticalRun, ratios);
              const diagDownError = scoreBlackWhiteRun(topLeftBottomRightRun, ratios);
              const diagUpError = scoreBlackWhiteRun(bottomLeftTopRightRun, ratios);
              const ratioError = Math.sqrt(horzError.error * horzError.error +
                  vertError.error * vertError.error +
                  diagDownError.error * diagDownError.error +
                  diagUpError.error * diagUpError.error);
              const avgSize = (horzError.averageSize + vertError.averageSize + diagDownError.averageSize + diagUpError.averageSize) / 4;
              const sizeError = (Math.pow((horzError.averageSize - avgSize), 2) +
                  Math.pow((vertError.averageSize - avgSize), 2) +
                  Math.pow((diagDownError.averageSize - avgSize), 2) +
                  Math.pow((diagUpError.averageSize - avgSize), 2)) / avgSize;
              return ratioError + sizeError;
          }
          catch (_a) {
              return Infinity;
          }
      }