How to sample color from spriteRenderer texture?

i have a raycast and I want to get the color of the sprite pixel it hit
i found this unity - How can I sample objects color based on position and apply to an object in a shader? - Game Development Stack Exchange

but it seems to be only for 3d raycasting