line-2-cubic.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // export function getPointAtSegLength(p1x: number, p1y: number, c1x: number, c1y: number, c2x: number, c2y: number, p2x: number, p2y: number, t: number) {
  2. // const t1 = 1 - t;
  3. // return {
  4. // x: (t1 ** 3) * p1x
  5. // + t1 * t1 * 3 * t * c1x
  6. // + t1 * 3 * t * t * c2x
  7. // + (t ** 3) * p2x,
  8. // y: (t1 ** 3) * p1y
  9. // + t1 * t1 * 3 * t * c1y
  10. // + t1 * 3 * t * t * c2y
  11. // + (t ** 3) * p2y,
  12. // };
  13. // }
  14. // export function midPoint(a: number[], b: number[], t: number) {
  15. // const ax = a[0];
  16. // const ay = a[1];
  17. // const bx = b[0];
  18. // const by = b[1];
  19. // return [ax + (bx - ax) * t, ay + (by - ay) * t];
  20. // }
  21. export function lineToCubic(x1, y1, x2, y2) {
  22. return [x1, y1, x2, y2, x2, y2];
  23. // const t = 0.5;
  24. // const p0 = [x1, y1];
  25. // const p1 = [x2, y2];
  26. // const p2 = midPoint(p0, p1, t);
  27. // const p3 = midPoint(p1, p2, t);
  28. // const p4 = midPoint(p2, p3, t);
  29. // const p5 = midPoint(p3, p4, t);
  30. // const p6 = midPoint(p4, p5, t);
  31. // const cp1 = getPointAtSegLength.apply(0, p0.concat(p2, p4, p6, t));
  32. // const cp2 = getPointAtSegLength.apply(0, p6.concat(p5, p3, p1, 0));
  33. // return [cp1.x, cp1.y, cp2.x, cp2.y, x2, y2];
  34. }
  35. //# sourceMappingURL=line-2-cubic.js.map