home > notes > PostScript > Music Staff [ printer-friendly version ]
Calendar
Bass Staff
Music Staff
Symbol

Musical Staff

staff.ps

This little PostScript file creates one sheet of lined music paper. Once the Staff object is defined, it's just a matter of positioning the object on the page over and over.

%!PS-Adobe-2.0 EPSF-2.0
%%Title: staff.ps
%%Pages: 1
%%Page: 1 1
% 10-staff music paper (8.5 x 11)
%-----------------------------------------------
/Inch { 72 mul } def

% Draw a 4-bar staff given X and Y locations of the bottom left corner
/Staff { /Y exch def    /X exch def
    /Width { 7.25 Inch } def
    % staff lines
    X Y moveto          Width 0 rlineto stroke newpath
    X Y 7 sub moveto    Width 0 rlineto stroke newpath
    X Y 14 sub moveto   Width 0 rlineto stroke newpath
    X Y 21 sub moveto   Width 0 rlineto stroke newpath
    X Y 28 sub moveto   Width 0 rlineto stroke newpath
    % bar lines
    X Y moveto                          0 -28 rlineto stroke newpath
    Width 4 div X add Y moveto          0 -28 rlineto stroke newpath
    Width 2 mul 4 div X add Y moveto    0 -28 rlineto stroke newpath
    Width 3 mul 4 div X add Y moveto    0 -28 rlineto stroke newpath
    Width X add Y moveto                0 -28 rlineto stroke newpath
} def


%-----------------------------------------------
newpath

0.5 Inch 1.375 Inch Staff
0.5 Inch 1.375 1 add Inch Staff
0.5 Inch 1.375 2 add Inch Staff
0.5 Inch 1.375 3 add Inch Staff
0.5 Inch 1.375 4 add Inch Staff
0.5 Inch 1.375 5 add Inch Staff
0.5 Inch 1.375 6 add Inch Staff
0.5 Inch 1.375 7 add Inch Staff
0.5 Inch 1.375 8 add Inch Staff
0.5 Inch 1.375 9 add Inch Staff

showpage
quit

See how easy that was?


home Learn from the mistakes of others. You won't live long enough to make all of them yourself. privacy