Circular draggable UI element in Unity canvas

I am trying to implement my own runtime color picker that’s easy to use for touch interfaces. I want the hue slider to be a ring, along these lines, except the whole ring texture would rotate when dragged.

I have scavenged enough code to get a raw image object rotating when dragged in a UI canvas in the manner I’m looking for:

    private float baseAngle;     private Vector2 pos;          public void OnBeginDrag(PointerEventData eventData)     {         pos = transform.position;         pos = eventData.pressPosition - pos;         baseAngle = Mathf.Atan2(pos.y, pos.x) * Mathf.Rad2Deg;         baseAngle -= Mathf.Atan2(transform.right.y, transform.right.x) * Mathf.Rad2Deg;     }      public void OnDrag(PointerEventData eventData)     {         pos = transform.position;         pos = eventData.position - pos;         float ang = Mathf.Atan2(pos.y, pos.x) * Mathf.Rad2Deg - baseAngle;         transform.rotation = Quaternion.AngleAxis(ang, Vector3.forward);     } 

Since it doesn’t use colliders, how can I limit the draggable region to a circle within the square bounds of the texture? Even better, also limit it to a ring rather than a whole circle. Will I have to implement my own check based on some pure math or is there a built in way?