Ported horizontal_projection() to XS