import type { DisplayObject, LineStyleProps, ParsedLineStyleProps, Point, } from '../g-lite'; import { isFillOrStrokeAffected } from '../g-lite'; import { inLine } from './utils/math'; export function isPointInPath( displayObject: DisplayObject, position: Point, isClipPath: boolean, ): boolean { const { x1, y1, x2, y2, lineWidth, increasedLineWidthForHitTesting, defX: x = 0, defY: y = 0, pointerEvents, fill, stroke, } = displayObject.parsedStyle as ParsedLineStyleProps; const [, hasStroke] = isFillOrStrokeAffected(pointerEvents, fill, stroke); if ((!hasStroke && !isClipPath) || !lineWidth) { return false; } return inLine( x1, y1, x2, y2, (lineWidth || 0) + (increasedLineWidthForHitTesting || 0), position.x + x, position.y + y, ); }