[%  PROCESS ps/tiles UNLESS global.ps.loaded.tiles;
    global.ps.loaded.tilepage = 1;
-%]
% perform tiling calculations
tile-path tiles

% generate tiled pages
tiles-ny 1 sub -1 0
{
    /tilepage-y exch def
    0 1 tiles-nx 1 sub
    {
        /tilepage-x exch def
        tile-page
        gsave
            clip-box rectclip
            % translate origin to the new image rectangle
            tiles-xorg tiles-yorg translate
            tilepage-x clip-xsize mul neg 
            tilepage-y clip-ysize mul neg translate
            tile-image
            showpage
        grestore
    } for
} for
