Reduce code duplication by adjusting the array indices depending on the renderer orientation.