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.

Summary

Public constructors

Cmn

Public functions

operator Boolean
contains(position: Offset)

Queries whether the specified position is inside this Path.

Cmn
Unit
updatePath(path: Path, tolerance: @FloatRange(from = 0.0) Float)

Sets the Path to run queries against.

Cmn

Public constructors

PathHitTester

PathHitTester()

Public functions

contains

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
position: Offset

The x/y coordinates of the point to test.

Returns
Boolean

True if position is inside this path, false otherwise.

updatePath

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

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
path: Path

The Path to run queries against.

tolerance: @FloatRange(from = 0.0) Float = 0.5f

When path contains conic curves, defines the maximum distance between the original conic curve and its quadratic approximations. Set to 0.5 by default.