Let me suggest a different approach:
Let $\Omega$ be an object in 2D.
Let ${\bf x} = (x,y)$ be a point in the plane. Let ${\bf \bar{x}}=(\bar{x},\bar{y})$ be the center of mass of $\Omega$ and let $\rho(x,y)$ be mass density function (mass per unit area). The force density ${\bf F}$ can be obtained by multiplying $\rho$ by the gravitational acceleration ${\bf g}$, which points downwards. Then, since ${\bf \bar{x}}$ is the center of mass, by static equilibrium, the sum of the contributions of all the torques with respect to ${\bf \bar{x}}$ is zero. Mathematically,
$$
\begin{align}
{\bf 0} &=
\int_{\Omega} {\boldsymbol{\tau}} \,d\Omega \\
&= \int_{\Omega} \overbrace{({\bf {x}}-{\bf \bar{x}})}^{\bf r}\times
\overbrace
{
{\bf g} \, \rho(x,y)
}^{\bf F} \, d\Omega \\
& =
\int_{\Omega} ({\bf {x}}-{\bf \bar{x}})^{\perp}\,g \,\rho(x,y)\, d\Omega,
\end{align}
$$
where $({\bf {x}}-{\bf \bar{x}})^{\perp}= ((y-\bar{y}),-(x-\bar{x}),0)$ is the vector $({\bf {x}}-{\bf \bar{x}})$ rotated $\pi/2$ radians CCW.
This is a consequence of the cross product and the fact that the vector $({\bf {x}}-{\bf \bar{x}})$ is perpendicular to ${\bf g}$. Hence, equating vector component yields
$$
\begin{align}
0 &= \int_{\Omega} {(y-\bar{y})} \,\rho(x,y)\, d\Omega \\
0 &= \int_{\Omega} {(x-\bar{x})} \,\rho(x,y)\, d\Omega
\end{align}
$$
which implies that
$$
{\bar{x}} = \dfrac
{
\int_{\Omega} { {x}} \,\rho(x,y)\, d\Omega
}
{
\int_{\Omega} \,\rho(x,y)\, d\Omega
}
$$
$$
{\bar{y}} = \dfrac
{
\int_{\Omega} { {y}} \,\rho(x,y)\, d\Omega
}
{
\int_{\Omega} \,\rho(x,y)\, d\Omega
}
$$
Lastly, if your density is constant, we obtain the original result.