Rectangle is the only primitive type supported by canvas. It has 3 functions: strokeRect(x, y, w, h); fillRect(x, y, w,…