An annulus is a disc with a hole — the 2D equivalent of a torus. The area element still grows with r, so the trick from the disc case generalises: sample r² uniformly between the squared radii. Set the inner radius to 0 and you recover the plain-disc formula.
See also: Uniform random point in a circle — the special case where the inner radius is 0.
angle = 2π · random()
r = sqrt(R_in² + random() · (R_out² - R_in²))
x = cx + r · cos(angle)
y = cy + r · sin(angle)
function uniformInAnnulus(cx, cy, rIn, rOut) {
const angle = 2 * Math.PI * Math.random()
const r = Math.sqrt(rIn * rIn + Math.random() * (rOut * rOut - rIn * rIn))
return { x: cx + r * Math.cos(angle), y: cy + r * Math.sin(angle) }
}