docs: function solvePositionFromXValue(xVal, x1, x2) {
    const epsilon = 1e-6;
    const maxIterations = 8; // 迭代次数
  
    if (xVal <= 0) {
      return 0;
    } else if (xVal >= 1) {
      return 1;
    }
  
    // Initial estimate of t using linear interpolation.
    let t = xVal;
  
    // Try gradient descent to solve for t. If it works, it is very fast.
    let tMin = 0;
    let tMax = 1;
    let value = 0;
    for (let i = 0; i < maxIterations; i++) {
      value = getBezierCoordinate(t, x1, x2);
      const derivative =
        (getBezierCoordinate(t + epsilon, x1, x2) - value) / epsilon;
      if (Math.abs(value - xVal) < epsilon) {
        return t;
      } else if (Math.abs(derivative) < epsilon) {
        break;
      } else {
        if (value < xVal) {
          tMin = t;
        } else {
          tMax = t;
        }
        t -= (value - xVal) / derivative;
      }
    }
  
    /*
     * If the gradient descent got stuck in a local minimum, e.g. because
     * the derivative was close to 0, use a Dichotomy refinement instead.
     * We limit the number of interations to 8.
     */
    for (let i = 0; Math.abs(value - xVal) > epsilon && i < maxIterations; i++) {
      if (value < xVal) {
        tMin = t;
        t = (t + tMax) / 2;
      } else {
        tMax = t;
        t = (t + tMin) / 2;
      }
      value = getBezierCoordinate(t, x1, x2);
    }
    return t;
  }