Refactor animation code to shapes