func (c Canvas) tileSelection(pp pixelPosition) *tileSelection {
	switch {
	case c.draw.unusedMin.x <= pp.x && pp.x < c.draw.unusedMin.x+len(c.board.UnusedTileIDs)*c.draw.tileLength &&
		c.draw.unusedMin.y <= pp.y && pp.y < c.draw.unusedMin.y+c.draw.tileLength:
		idx := (pp.x - c.draw.unusedMin.x) / c.draw.tileLength
		id := c.board.UnusedTileIDs[idx]
		if t, ok := c.board.UnusedTiles[id]; ok {
			var ts tileSelection
			ts.index = idx
			ts.tile = t
			return &ts
		}
	case c.draw.usedMin.x <= pp.x && pp.x < c.draw.usedMin.x+c.draw.numCols*c.draw.tileLength &&
		c.draw.usedMin.y <= pp.y && pp.y < c.draw.usedMin.y+c.draw.numRows*c.draw.tileLength:
		col := tile.X((pp.x - c.draw.usedMin.x) / c.draw.tileLength)
		row := tile.Y((pp.y - c.draw.usedMin.y) / c.draw.tileLength)
		if yUsedTileLocs, ok := c.board.UsedTileLocs[col]; ok {
			if t, ok := yUsedTileLocs[row]; ok {
				var ts tileSelection
				ts.used = true
				ts.tile = t
				ts.x = col
				ts.y = row
				return &ts
			}
		}
	}
	return nil
}
// getTileSelection returns the tile at the specified coordinates on the canvas or nil if none exists.
getTileSelection returns the tile at the specified coordinates on the canvas or nil if none exists.
// getTileSelection returns the tile at the specified coordinates on the canvas or nil if none exists .
func (c Canvas) tileSelection(pp pixelPosition) *tileSelection {
	switch {
	case c.draw.unusedMin.x <= pp.x && pp.x < c.draw.unusedMin.x+len(c.board.UnusedTileIDs)*c.draw.tileLength &&
		c.draw.unusedMin.y <= pp.y && pp.y < c.draw.unusedMin.y+c.draw.tileLength:
		idx := (pp.x - c.draw.unusedMin.x) / c.draw.tileLength
		id := c.board.UnusedTileIDs[idx]
		if t, ok := c.board.UnusedTiles[id]; ok {
			var ts tileSelection
			ts.index = idx
			ts.tile = t
			return &ts
		}
	case c.draw.usedMin.x <= pp.x && pp.x < c.draw.usedMin.x+c.draw.numCols*c.draw.tileLength &&
		c.draw.usedMin.y <= pp.y && pp.y < c.draw.usedMin.y+c.draw.numRows*c.draw.tileLength:
		col := tile.X((pp.x - c.draw.usedMin.x) / c.draw.tileLength)
		row := tile.Y((pp.y - c.draw.usedMin.y) / c.draw.tileLength)
		if yUsedTileLocs, ok := c.board.UsedTileLocs[col]; ok {
			if t, ok := yUsedTileLocs[row]; ok {
				var ts tileSelection
				ts.used = true
				ts.tile = t
				ts.x = col
				ts.y = row
				return &ts
			}
		}
	}
	return nil
}
func ( c Canvas ) tileSelection ( pp pixelPosition ) * tileSelection { switch { case c . draw . unusedMin . x <= pp . x && pp . x < c . draw . unusedMin . x + len ( c . board . UnusedTileIDs ) * c . draw . tileLength && c . draw . unusedMin . y <= pp . y && pp . y < c . draw . unusedMin . y + c . draw . tileLength : idx := ( pp . x - c . draw . unusedMin . x ) / c . draw . tileLength id := c . board . UnusedTileIDs [ idx ] if t , ok := c . board . UnusedTiles [ id ] ; ok { var ts tileSelection ts . index = idx ts . tile = t return & ts } case c . draw . usedMin . x <= pp . x && pp . x < c . draw . usedMin . x + c . draw . numCols * c . draw . tileLength && c . draw . usedMin . y <= pp . y && pp . y < c . draw . usedMin . y + c . draw . numRows * c . draw . tileLength : col := tile . X ( ( pp . x - c . draw . usedMin . x ) / c . draw . tileLength ) row := tile . Y ( ( pp . y - c . draw . usedMin . y ) / c . draw . tileLength ) if yUsedTileLocs , ok := c . board . UsedTileLocs [ col ] ; ok { if t , ok := yUsedTileLocs [ row ] ; ok { var ts tileSelection ts . used = true ts . tile = t ts . x = col ts . y = row return & ts } } } return nil }
getTileSelection returns the tile at the specified coordinates on the canvas or nil if none exists.
getTileSelection returns the tile at the specified coordinates on the canvas or nil if none exists .