Let's create an image which looks like a target:
Obviously, whether a pixel is red or white depends solely on its distance from the center, which we know is available as r. I have chosen the width of each ring as 20, i.e. the distance between the radii of the inner circles of two neighboring red (or white) rings is 40. Hence, the expression we are looking for is periodic with a period of 40.
To solve this problem, we will use the modulo operator, which is available as %. Its value is the remainder of the division of its left operand by its right operand. As an example, 7%3 is 1 because the remainder of the division of 7 by 3 is 1. This operation is periodic. Its period is the value of its right operand (the divisor). Furthermore, the result of the operation is never greater than the right operand. So, for example, r%40 is periodic with a period of 40 and is always between 0 (inclusive) and 40 (exclusive). Let's see what this looks like:
grayColor((r%40)/40)
In order to be nice to grayColor, the value is scaled to be in the range from 0 to 1 (instead of 40). The resulting image looks like this:
You can see that the value starts out as 0 at the center of the image, climbs to 1 at 40 pixels from the center and then immediately drops to 0 again, repeating this cycle forever (well, in our case, to the boundaries of the image).
You may want to try to leave out the rescaling "/40" to see the difference.
All we have to do now is to check whether we are in the first half of a period (in which case r%40 is less than 20), or in the second. If we are in the first, the color for the pixel is red, otherwise it is white. MathMap provides a construct for such decisions:
if r%40 < 20 then rgbColor(1,0,0) else rgbColor(1,1,1) end
The indentation is used merely to make the expression easier to read. You can indent your code any way you like (or not at all).
The expression should be easy enough to understand. If the condition is fulfilled, the result is the color red, otherwise it is the color white.
Next topic: Variables