I have a polygon in a irregular format and I want to fill it by using gradient. However, this gradient has to be in the same contour of the polygon. This means that, the gradient is not radial since this gradient will fill a "ball" in the center of the polygon. Further, it cannot be the linear since it does not the same contour of the polygon.
This is an example of the image that I want:
I have tried it, but I really don't know how to reproduce this example. Please, I would like a solution in the illustrator or photoshop.