Using line integrals (LIs) used to calculate the gravity anomaly caused by a 2D mass of complicated geometry and spatially variable density contrast is a computationally efficient algorithm, that reduces the calculation from two dimensions to one dimension. This work has developed a mechanism for defining LIs systematically for different types of density functions. Two-dimensional vector gravity potential is defined as a vector, the net circulation of which, along the closed contour bounding a 2D mass, equals the gravity anomaly caused by the 2D mass. Two representative types of LIs are defined: an LI with an arctangent kernel for any depth-dependent density-contrast function, which has been studied historically; and an LI with a simple algebraic kernel for any integrable density-contrast function. The present work offers (1) a vectorial-based derivation of formulas that do not suffer from the arbitrary sign conventions found in some historical approaches; and (2) a simple algebraic kernel in line integrals as an alternative to the historical arctangent kernel, with the possibility of extension to more general cases. The concept of 2D vector gravity potential provides a useful tool for defining LIs systematically for any mass density function, helping us understand how dimensions can be reduced in a calculating gravity anomaly, especially when the density contrast varies with space. LIs have been tested in case studies. The maximum differences in calculated gravity anomalies by different LIs for the case studies were between and . Processing time required per station per segment of the 2D polygon of a 2D mass using LIs is on a Dell Optiplex GX 620 desktop computer, almost independent of the density function. The results indicate that the two types of LIs provide very fast, efficient, and reliable algorithms in gravity modeling or inversion for various types of density-contrast functions.