Ray engineering from chaos to order in two-dimensional optical cavities