Clamp camera within bounds of a Polygon Collider?

Hi I am making a 2d platformer game and right now I am working on the camera.
while I succeeded in clamping the camera inside a rectangular shape, my game involves slopes, so I want my camera to be able to clamp inside a curved shaped too.
Can anyone help me find an idea for the code?

So I’ve been looking into this - I’ve not yet worked out a ‘manual’ way of coding this but if you use the Cinemachine & Polygon Collider I think that will work.

video tutorial - Cinemachine Confiner - Camera Bounding Box Unity Tutorial - YouTube