border.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var bezier_curve_1 = require("./bezier-curve");
  4. exports.parsePathForBorder = function (curves, borderSide) {
  5. switch (borderSide) {
  6. case 0:
  7. return createPathFromCurves(curves.topLeftBorderBox, curves.topLeftPaddingBox, curves.topRightBorderBox, curves.topRightPaddingBox);
  8. case 1:
  9. return createPathFromCurves(curves.topRightBorderBox, curves.topRightPaddingBox, curves.bottomRightBorderBox, curves.bottomRightPaddingBox);
  10. case 2:
  11. return createPathFromCurves(curves.bottomRightBorderBox, curves.bottomRightPaddingBox, curves.bottomLeftBorderBox, curves.bottomLeftPaddingBox);
  12. case 3:
  13. default:
  14. return createPathFromCurves(curves.bottomLeftBorderBox, curves.bottomLeftPaddingBox, curves.topLeftBorderBox, curves.topLeftPaddingBox);
  15. }
  16. };
  17. var createPathFromCurves = function (outer1, inner1, outer2, inner2) {
  18. var path = [];
  19. if (bezier_curve_1.isBezierCurve(outer1)) {
  20. path.push(outer1.subdivide(0.5, false));
  21. }
  22. else {
  23. path.push(outer1);
  24. }
  25. if (bezier_curve_1.isBezierCurve(outer2)) {
  26. path.push(outer2.subdivide(0.5, true));
  27. }
  28. else {
  29. path.push(outer2);
  30. }
  31. if (bezier_curve_1.isBezierCurve(inner2)) {
  32. path.push(inner2.subdivide(0.5, true).reverse());
  33. }
  34. else {
  35. path.push(inner2);
  36. }
  37. if (bezier_curve_1.isBezierCurve(inner1)) {
  38. path.push(inner1.subdivide(0.5, false).reverse());
  39. }
  40. else {
  41. path.push(inner1);
  42. }
  43. return path;
  44. };
  45. //# sourceMappingURL=border.js.map