addCurvePosition method

void addCurvePosition(
  1. double p,
  2. double x1,
  3. double y1,
  4. double cx1,
  5. double cy1,
  6. double cx2,
  7. double cy2,
  8. double x2,
  9. double y2,
  10. Float32List out,
  11. int o,
  12. bool tangents
)

Implementation

void addCurvePosition(
    double p,
    double x1,
    double y1,
    double cx1,
    double cy1,
    double cx2,
    double cy2,
    double x2,
    double y2,
    Float32List out,
    int o,
    bool tangents) {
  if (p == 0 || p.isNaN) p = 0.0001;
  final double tt = p * p, ttt = tt * p, u = 1 - p, uu = u * u, uuu = uu * u;
  final double ut = u * p, ut3 = ut * 3, uut3 = u * ut3, utt3 = ut3 * p;
  final double x = x1 * uuu + cx1 * uut3 + cx2 * utt3 + x2 * ttt,
      y = y1 * uuu + cy1 * uut3 + cy2 * utt3 + y2 * ttt;
  out[o] = x;
  out[o + 1] = y;
  if (tangents) {
    out[o + 2] = math.atan2(y - (y1 * uu + cy1 * ut * 2 + cy2 * tt),
        x - (x1 * uu + cx1 * ut * 2 + cx2 * tt));
  }
}