Applying a Gradient to an Arbitrary 2D Shape Edge Inward

I need to take a ramp gradient and apply it to an arbitrary 2D shape from it’s edges inward. As an example, a special case of this would be a ramp-defined spherical gradient applied to a circle. I need to apply this many times over so anything requiring manual mapping would not be suitable.

Could anyone help me with this? I’ve run searches but I don’t appear to be using the correct terms to home in on what I’m looking for.