Post Scriptum language

// Example 10


pi=3.1415923;

procedure outsidecircletext( str, ptsize, centerangle, radius )
{
        xradius = radius + ptsize/4;
        gsave();

        // Note that findhalfangle uses xradius
        // (see below for findhalfangle definition)
        rotate( findhalfangle( str ) + centerangle );
        for ( charcode in str ) {
                str = " ";
                str[ 0 ] = charcode;
                outsideplacechar( str );
        }
        grestore();
}

procedure insidecircletext( str, ptsize, centerangle, radius )
{
        xradius = radius + ptsize/3;
        gsave();
        rotate( findhalfangle( str ) + centerangle );
        for ( charcode in str ) {
                str = " ";
                str[ 0 ] = charcode;
                outsideplacechar( str );
        }
        grestore();
}

procedure findhalfangle( str ) 
{
        sw = [ stringwidth(str) ];

        // The "xradius" variable is set in calling
        // procedure.  Post Scriptum allows global or external variables
        // to be read in procedure.
        return 360* ( sw[0]/2 ) / (2*pi*xradius);
}

procedure outsideplacechar( char ) 
{
        halfangle = findhalfangle( char );
        gsave();
        rotate( -halfangle );
        translate( radius, 0 );
        rotate( -90 );
        sw = [stringwidth(char)];
        moveto( -sw[0]/2, 0 );
        show( char );
        grestore();
        rotate( -2*halfangle );
}


procedure insideplacechar( char ) 
{
        halfangle = findhalfangle( char );
        gsave();
        rotate( -halfangle );
        translate( radius, 0 );
        rotate( 90 );
        sw = [stringwidth(char)];
        moveto( -sw[0]/2, 0 );
        show( char );
        grestore();
        rotate( -2*halfangle );
}

setfont( scalefont( findfont('Times-Bold'), 22 ));
translate( 306, 448 );

outsidecircletext( "Symphony No. 9 (The Choral Symphony)",
                22, 90, 140 );

setfont( scalefont( findfont('Times-Roman'), 15 ));

// The Beethoven's surname is misspelled in original Adobe example !
// Here is the correct spelling:
outsidecircletext( "Ludwig van Beethoven", 15, 90, 118 );

insidecircletext( "The New York Philharmonic Orchestra", 15, 270, 118 );

showpage();