Density of uniform distribution over two disjoint squares
The density $p_R$ of the uniform distribution over a rectangle $R$ is given by $p_R(x) = 0$ if $x \notin R$, and $p_R(x) = 1/\mathit{area}(R)$ otherwise. Indeed, up to scaling the distribution must have this form, and the choice $1/\mathit{area}(R)$ ensures that $p_R$ is a distribution.
In your case, you have a mixture of two such distributions: with probability $1/2$ you take a uniform point in $[1,2] \times [1,2]$, and with probability $1/2$ you take a uniform point in $[3,4] \times [1.5,2.5]$. The density function of the mixture is the average of the density functions of the individual distributions.