hit method

LayerHit hit(
  1. int x,
  2. int y
)

Returns the top-most layer hit at (x, y).

Implementation

LayerHit hit(int x, int y) {
  final p = Position(x, y);
  for (var i = _layers.length - 1; i >= 0; i--) {
    final cl = _layers[i];
    if (cl.layer.id.isNotEmpty && cl.bounds.contains(p)) {
      return LayerHit(id: cl.layer.id, layer: cl.layer, bounds: cl.bounds);
    }
  }
  return const LayerHit();
}