%!PS % Fill the paper with S's. % Illustrating: procedures & loops % Joseph O'Rourke /inch {72 mul} def 2 setlinewidth /red 1 def /blue 0 def /green 0 def red green blue setrgbcolor 1 setlinecap % 1=rounded cap (as opposed to 0=butt, 2=projecting square) %-------------------------------- % L is radius of 'S' arc. % arcs are 270 deg, one forward, one reverse, % both centered on (0,L) so that leftmost coord is 0, % rightmost is 2L. /L 12 def % procedure S draws one S /S {0 L L 0 270 arc 0 L neg L 90 -180 arcn stroke } def %-------------------------------- %-------------------------------- % For-loop params to fill page: % nx = number of S's that will fit horizontally % ny = number of S's that will fit vertically /nx 8.5 inch L div floor def /ny 11 inch 4 L mul div floor 1 add def % For-loop over all rows % start incr end 0 1 ny { % One row gsave % Save origin on y-axis. % Prepare for first S (move over -2L, width of S): % First step in loop translates. L neg 2 L mul translate % For-loop to fill one row: % start incr end 0 1 nx { 2 L mul 0 translate % Move over width of S S} for grestore % Reset origin on y-axis % Move up height of S. 0 4 L mul translate % Adjust the color slightly: red down, blue up. /red red 0.05 sub def /blue blue 0.05 add def red green blue setrgbcolor } for showpage