There is an excellent guide to MRI at mriquestions.com. Most images in these notes come from that site, courtesy of Allen D. Elster, MRIquestions.com.
From the last lecture, we saw that a gradient, $G_{xy} = (G_x,G_y)$, in the transverse field would cause the precession frequency, $\omega$, to vary in the direction of $G_{xy}$: $$w(x,y) = \gamma\ (B_0 + x\ G_x + y\ G_y)$$
The gradient, $G_{xy}$, is a vector in the direction of increasing field strength with magnitude equal to the change in field strength per unit distance.
Position $(x,y)$ in the transverse field can also be written as a vector: $r = (x,y)$. At the centre of the transverse plane, $r = (0,0)$.
Since it's only the distance along $G_{xy}$ that determines the frequency of precession, the field strength at $r$ can be computed with the dot product as $r \cdot G_{xy}$
and the frequency written as $w(r) = \gamma\ (B_0 + r \cdot G_{xy})$.
The phase angle, $\theta$, of a vector is its angle with respect to a reference direction, which is usually the $x$ axis.
As a proton precesses, the phase angle of its magnetic moment in the $xy$ plane moves through the range $[-\pi,+\pi]$ with its speed determined by the precession frequency, $\omega$.
After $\Delta t$ seconds at a constant frequency $\omega$ (which is measured in "radians per second"), a proton will have travelled through $$\Theta = \omega\ \Delta t$$
radians. If $\omega(t)$ is changing with time, $t$ then $$\Theta = \int_{\Delta t} \omega(t)\ dt$$
At location $r$, $G_{xy}$ might also be changing with time, so $\omega(r,t) = \gamma\ (B_0 + r \cdot G_{xy}(t))$ and $$\Theta(r) = \int_{\Delta t} (\gamma\ (B_0 + r \cdot G_{xy}(t))\ dt$$
But we usually consider only the phase difference (or phase shift) with respect to the protons precessing at the centre ($r = (0,0)$) of the field, where the gradient is zero: $$\begin{array}{rl} \Delta\Theta(r) & = \Theta(r) - \Theta((0,0)) \\ & = \displaystyle \int_{\Delta t} \gamma\ (B_0 + r \cdot G_{xy}(t))\ dt - \int_{\Delta t} \gamma\ (B_0 + (0,0) \cdot G_{xy}(t))\ dt \\ & = \displaystyle \int_{\Delta t} \gamma\ \ r \cdot G_{xy}(t)\ dt \\ & = \displaystyle \gamma\ \ r \cdot \int_{\Delta t} G_{xy}(t)\ dt \\ \end{array}$$
There are two important ideas here:
We are ignoring the T2* de-phasing effects in the discussion above. That's because, when we use phase shifts, we'll also use a spin echo sequence to (almost) remove the T2* effects.
Gradient traces are used to describe how gradients are applied over time. Each pair of traces below has a $G_x$ and $G_y$ gradient which, combined, make $G_{xy} = (G_x,G_y)$. The horizontal axis is time. The height above the line corresponds to the strength of the gradient. A gradient shown below the line is a negative gradient: It increases in the opposite direction.
The area of one of the boxes in the $G_x$ gradient traces above has height $G_x(t)$ and width $\Delta t$. So the area corresponds to $$\int_{\Delta t} G_x(t)\ dt$$
where $G_x(t)$ happens to be constant in each interval above. But $G_x(t)$ does not have to be constant, and the boxes above could be replaced with other shapes above and below the lines.
After either of those two gradient sequences is applied, the phase shift of a proton, $$\Delta\Theta(r) = \gamma\ \int_{\Delta t} r \cdot (G_x(t),G_y(t))\ dt$$
will be the same because the two sequences have the same integrals for $G_x$ and $G_y$.
The animation below shows the application of different gradients over time:
Note that following in the animation: