How do I reverse the animation of a drawing in P5JS (more details in post)

Source Code: p5.js Web Editor

Basically I’m trying to do a pseudo generative poster that swaps between 3 artworks that I have predesigned. The idea is to make load one artpiece, wait a few seconds then reverse (essentially wipe it away) the drawing to a blank canvas then load the next and repeat endlessly.

I’m just trying to recreate the reversal animation that I saw here: https://www.reddit.com/r/generative/comments/q6krwj/lines_p5js/

ezgif.com-gif-maker (1)

Cross posted from StackOverflow: javascript - How do I reverse the animation of a drawing in P5JS (more details in post) - Stack Overflow