#define sqr(x) ((x) * (x)) surface pkdots ( float dotsize = 0.25; float spacing = 1; color dotcolor = color "rgb" (1, 0, 0); color bgcolor = color "rgb" (1, 1, 1) ) { float ss, tt; float dist; /*divide image into grid according to the spacing. Square sides the size of spacing, and the center of circle is at the center of square. Circle is at the center of the square*/ ss = mod (s/spacing, 1.0); tt = mod (t/spacing, 1.0); /*all points w/in the radius are colored "dotcolor"*/ dist = sqrt (sqr (ss - 0.5) + sqr(tt - 0.5)); if (dist <= dotsize) { Ci = dotcolor; } /*if not w/in the radius, colored with the background color*/ else Ci = bgcolor; Oi = Os; }