line-2-cubic.js 1.4 KB

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