It’s a piece of cake right? The function we used for wrapping the plot is saveGIF, this function basically collects all the plots made and use these as frames of the GIF file. In other words, the above plot was generated/looped 100 times through the curve function, and in every iteration we increased the limits of the x axis; hence rolling all the generated plots, animates x-axis towards positive values.
The function of the above plot is, $z = sin(x\times y)$, and was generated using the codes below,
Another wave, $z = sin(x) + cos(y)$, looped both through the ranges of $x$ and $y$, and degrees of $\theta$,
You should try it.