PathHitTester

Class

Common
class PathHitTester

A PathHitTester is used to query whether certain x/y coordinates lie inside a given Path. A PathHitTester is optimized to perform multiple queries against a single path.

Functions

fun updatePath(path: Path, @FloatRange(from = 0.0) tolerance: Float = 0.5f)

Sets the Path to run queries against.

If path contains conic curves, they are converted to quadratic curves during the query process. This value defines the tolerance of that conversion.

The tolerance should be appropriate to the coordinate systems used by the caller. For instance if the path is defined in pixels, 0.5 (half a pixel) or 1.0 (a pixel) are appropriate tolerances. If the path is normalized and defined in the domain 0..1, the caller should choose a more appropriate tolerance close to or equal to one "query unit". The tolerance must be >= 0.

Parameters

pathThe Path to run queries against.
toleranceWhen path contains conic curves, defines the maximum distance between the original conic curve and its quadratic approximations. Set to 0.5 by default.
operator fun contains(position: Offset): Boolean

Queries whether the specified position is inside this Path. The path's fill type is taken into account to determine if the point lies inside this path or not.

Parameters

positionThe x/y coordinates of the point to test.

Returns

True if position is inside this path, false otherwise.