We propose a new way for computing the solid angle subtended by a planar figure. Our method uses a line-integral representation of the solid angle. The path of integration is the boundary of the planar figure. We use this formula to develop an exact expression for the solid angle subtended by a polygon. This expression is simple and easy to compute. For any other shape, we first convert it to a polygonal one and then use the formula for a polygon. We validate our approach by computing the solid angle subtended by circles and ellipses.