%!PS
% This is a postscript file to draw a picture of pascals triangle
% Author: Helena Verrill
/N{100}def % N gives the number of rows
/m{8}def % at the moment m should be 0
/S{.7}def % change S to change scale
/k{8}def % number of colours
% if you change k, you have to make sure you add or subtract
% lines from the colour definition, so k colours are defined.
/colour{ % you can change the colours;
% these are red green blue values
0 0 0 %colour 0
1 1 .5 %colour 1
.8 0 .5 %colour 2
0 .7 0 %colour 3
.8 0 0 %colour 4
.8 .8 .3 %colour 5
.9 .4 .4 %colour 6
1 .9 0 %colour 7
3 k mul 1 add 3 k mul roll
-3 mul 3 k mul exch roll k 1 sub 3 mul{pop}repeat setrgbcolor}def
/square{8 0 translate colour 0 0 moveto
6 -6 6 2 2 6 -2 2 4{rlineto}repeat
closepath fill}def
300 600 translate
S S 1.5 mul scale
-45 rotate
N{1}repeat
N{0 -8 translate
N copy 0
N{add m mod 1 copy N 1 add 1 roll}repeat
N 2 mul 1 add N 1 add roll
N{square}repeat pop
N -8 mul 0 translate}repeat
showpage