Digit patterns

I got the idea for this from Buttons for Mouse. Imagine an X-Y plane from math class, and graph a Z function in the vertical dimension. In this case:
z = x2 + y2 + 2x + 2y + 1
For example, if x = 7 and y = 11, then z = 207. Only instead of having the z value popping out of the screen 207 units towards your eyeballs, imagine that the digits 2, 0 and 7 are stacked on the screen. The 7 is stuck to the screen at x =7, y = 11. The 0 is stacked on top of the 7, and the 2 is stacked on the 0. This image is 500 by 500, so there are 25,000 pixels. At each pixel, there is a stack of digits. Got that? Does your brain hurt yet? Good.
Now we’re going to slice our mess of digits parallel to the screen and take only the 3rd digit. So, for 207, we discard the 0 and 7 and keep the 2. Similarly, for 1432, we keep just the 4. Now we have a 500-by-500 array of digits, so we can replace each digit with a color.
But wait, there’s more! I didn’t do the calculations in decimal, I did them in base 5. Why base 5, you ask? I tried using decimal, but 10 colors is too many. The patterns are too busy. Like Goldilocks, I tried different bases and it turns out that for this particular function, base 5 is not too sweet, not too rancid, but just right.
And why the 3rd digit? Well. If I use the 3rd digit in base 5, and my function consists only of additions and multiplications, then the pattern has to repeat every 125 pixels. 5 to the 3rd power is 125. If you’re familiar with modular arithmetic, this is easy enough to see. 500 divided by 125 is 4, so with a 500-by-500 pixel image, I get 4 repetitions in each direction. The pattern is big enough to be interesting, but small enough that I can see that it repeats. Just about right.
As always, there are more questions than answers. I can try different functions, different bases, different digits, different color schemes. There’s no end to the experiments that can be done, and no telling what patterns are there to be discovered.