quadratic.js 555 B

123456789101112131415
  1. import { quadraticProjectPoint } from '../core/curve.js';
  2. export function containStroke(x0, y0, x1, y1, x2, y2, 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)
  8. || (y < y0 - _l && y < y1 - _l && y < y2 - _l)
  9. || (x > x0 + _l && x > x1 + _l && x > x2 + _l)
  10. || (x < x0 - _l && x < x1 - _l && x < x2 - _l)) {
  11. return false;
  12. }
  13. var d = quadraticProjectPoint(x0, y0, x1, y1, x2, y2, x, y, null);
  14. return d <= _l / 2;
  15. }