To make the tiling period extra clear, let's draw lines around the repeating rectangular regions.
Note that the same pseudo-random features appear in the same place within each rectangle, tiled across the entire image. Furthermore, this pattern wraps smoothly around the left/right and top/bottom edges, as a well behaved texture image should.
As a convenient feature, setting either component of "p" to zero will disable the wrapping for that dimension. Setting both components to zero will make the function somewhat faster, by about 15% or so.
We don't show the source for the function "gridlines" here, because it's only used for visualisation purposes, and implicit line drawing is not the main point of this tutorial. However, feel free to look at it in the source code for this page if you want.
// Text in this pane will be dynamically replaced.