docs: function countBlackWhiteRunTowardsPoint(origin, end, matrix, length) {
          const switchPoints = [{ x: Math.floor(origin.x), y: Math.floor(origin.y) }];
          const steep = Math.abs(end.y - origin.y) > Math.abs(end.x - origin.x);
          let fromX;
          let fromY;
          let toX;
          let toY;
          if (steep) {
              fromX = Math.floor(origin.y);
              fromY = Math.floor(origin.x);
              toX = Math.floor(end.y);
              toY = Math.floor(end.x);
          }
          else {
              fromX = Math.floor(origin.x);
              fromY = Math.floor(origin.y);
              toX = Math.floor(end.x);
              toY = Math.floor(end.y);
          }
          const dx = Math.abs(toX - fromX);
          const dy = Math.abs(toY - fromY);
          let error = Math.floor(-dx / 2);
          const xStep = fromX < toX ? 1 : -1;
          const yStep = fromY < toY ? 1 : -1;
          let currentPixel = true;
          // Loop up until x == toX, but not beyond
          for (let x = fromX, y = fromY; x !== toX + xStep; x += xStep) {
              // Does current pixel mean we have moved white to black or vice versa?
              // Scanning black in state 0,2 and white in state 1, so if we find the wrong
              // color, advance to next state or end if we are in state 2 already
              const realX = steep ? y : x;
              const realY = steep ? x : y;
              if (matrix.get(realX, realY) !== currentPixel) {
                  currentPixel = !currentPixel;
                  switchPoints.push({ x: realX, y: realY });
                  if (switchPoints.length === length + 1) {
                      break;
                  }
              }
              error += dy;
              if (error > 0) {
                  if (y === toY) {
                      break;
                  }
                  y += yStep;
                  error -= dx;
              }
          }
          const distances = [];
          for (let i = 0; i < length; i++) {
              if (switchPoints[i] && switchPoints[i + 1]) {
                  distances.push(distance(switchPoints[i], switchPoints[i + 1]));
              }
              else {
                  distances.push(0);
              }
          }
          return distances;
      }