Welcome!
See related code below. Note, the example code below uses frameRate(), which slows down the animation so you can see what the program is processing every frame. This is a different approach than, but a similar result as, the code in the video.