some hints to help you think:

think first in terms of a circle ( it is simpler and has many of the similar requirements as this)
the gaussian function in 2d with a diagonal covariance matrix, and equal x and y variances makes circles. the mean and variance are the parameters for this.
the differentiable color is the easiest part of the problem that i guess you’ll get quickly.

if you can solve the circle problem, i think you might get ideas for the rectangle.