cubic.js 618 B

123456789101112131415
  1. import * as curve from '../core/curve.js';
  2. export function containStroke(x0, y0, x1, y1, x2, y2, x3, y3, lineWidth, x, y) {
  3. if (lineWidth === 0) {
  4. return false;
  5. }
  6. var _l = lineWidth;
  7. if ((y > y0 + _l && y > y1 + _l && y > y2 + _l && y > y3 + _l)
  8. || (y < y0 - _l && y < y1 - _l && y < y2 - _l && y < y3 - _l)
  9. || (x > x0 + _l && x > x1 + _l && x > x2 + _l && x > x3 + _l)
  10. || (x < x0 - _l && x < x1 - _l && x < x2 - _l && x < x3 - _l)) {
  11. return false;
  12. }
  13. var d = curve.cubicProjectPoint(x0, y0, x1, y1, x2, y2, x3, y3, x, y, null);
  14. return d <= _l / 2;
  15. }