Note the example was updated recently to correctly deal with colorspace issues.
You need to use the multi-image GIF file for the symbols to tile, and not the single image montage of those images which is purely for display purposes.
In memory is 17 seperate images. The enlarged image (grayscale squares) of the image to be tiled, and 16 small tiling image which are all the same size as the greyscale squares.
u[...] selects an image from whcih to get a pixel.
The pixel location is at the same position as the pixel it is replacing in the first (zeroth) greyscale tile image.
That location uses the tiled virtual-pixel so even though the location is beyond the bounds of the smaller tiling images, a valid 'tiled' pixel is retrieved.
The
floor(15.9999*u)+1 selects the tileing image. +1 to skip the first or 'zero' image,
It is based on the value of the source image color (
u)
So at some particular location, i,j somewhere in the source image, (and for each of the color channels, os essectually the whole pixel). the greyscale value 'u' is extracted from the first image. This is then used to 'index' one of the tile images, and from that image
u[index] the pixel value is transferred to the output image replacing the original greyscale value.
The Previous examples on dithering used similar techniques, but looking up from a set of images that were progressive 'whiter' in color. In this case the images are symbols that are only roughly 'lighter' in color.
Remember '
u' means the first image '
v' means the second image and '
u[x]' means the
x image (starting at zero). As such
u is equivalent to
u[0] and
v is equivalent to
u[1]