How do you make a Canvas background color change, when a ball hits (Well, more like bounce) off the edge?

You can set background to only one color but you can make a list of colors and when edge reached pick a different color or assing a different color to different edges

First case

Second case