Post Scriptum language

// Example 13

procedure printposter( bigpictureproc, columns, rows ) 
{
        newpath();
        
        moveto( leftmargin, botmargin );
        rlineto( 0, pageheight );
        rlineto( pagewidth, 0 );
        rlineto( 0, -pageheight );
        closepath();
        clip();

        translate( leftmargin, botmargin );

        for ( rowcount=0 to rows-1 ) {
                for ( colcount=0 to columns-1 ) {
                        gsave();
                        translate( -pagewidth*colcount,
                                   -pageheight*rowcount );

                        bigpictureproc();
                        gsave(); showpage(); grestore();

                        grestore();
                }
        }
}

function inch( x ) {
        return 72 * x;
}

leftmargin = inch(0.5);
botmargin = inch(0.25);
pagewidth = inch(7.5);
pageheight = inch(10);

procedure salesign() 
{
        gsave();

        setfont( scalefont( findfont('Times-Roman'), 500));
        moveto( inch(2.5), inch(11));
        show( "SALE" );
        setfont( scalefont( findfont('Times-Roman'), 350));
        moveto( inch(1.45), inch(4));

        setgray( 0.5 );
        show( "50%" );
        setgray( 0 );
        show( " OFF" );

        newpath();
        moveto( inch(0.5), inch(18) );
        lineto( inch(22), inch(18) );
        lineto( inch(22), inch(2) );
        lineto( inch(0.5), inch(2) );
        closepath();

        gsave();
        setlinewidth( inch(0.75) );
        stroke();
        grestore();

        setlinewidth( 10 );
        setgray( 1 );
        stroke();
        grestore();
}

printposter( salesign, 3, 2 );