Calculate if circle intersects a rectangle In Euclidean 2D space I have a circle $A$ with radius $r$ and center $c(x_c,y_c)$, and a rectangle $B$ with height $h$, width $w$ which topleft corner is positioned at $d(x_d,y_d)$. The rectangle is not rotated, i.e. any vertex is parallel to either the $x$-axis or the $y$-axis. See the figure below for a simple sketch.

Given the values coordinates of $c$ and $d$ and the values of $r$, $h$ and $w$, how do I determine if the circle and the rectangle intersect, i.e. are overlapping? (The circle inside the rectangle without touching the borders of the rectangle, also counts as intersecting.
Background: I'm making a simple 2D game in which the player has to control two circles and has to avoid hitting blocks with this circles.

There is an intersection whenever the center of the circle lies in the green area.

You can detect this by checking if the center is inside the outer rectangle, but not in one of the corners at a distance larger than the radius.
Concretely, assign a code from $0$ to $4$ to the abscissa of the center, depending on its position with respect to the four verticals (left to right). And similarly for the ordinate. The codes $0*,4*,*4,*4$ get a "no". The codes $11,13,31,33$ receive a "maybe" (need to check the distance to the corresponding corner). The other codes get a "yes".
