Post Scriptum language

// Example 6

procedure concatprocs (proc1, proc2) 
{
	pp1 = cvlit( proc1 );
	pp2 = cvlit( proc2 );

	newproc = array( length(pp1) + length(pp2) );
	putinterval( newproc, 0, pp1 );
	putinterval( newproc, length(pp1), pp2 );
	return cvx( newproc );
}

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

procedure picstr() {
	return string( 3 );
}

// This function us used as callback argument for "image" .  
procedure readpfun () {
        // readhexstring returns 2 values on the stack, so
        // we first must encapsulate the results in array
        // and then select first item.
	ar = [ readhexstring( currentfile(), picstr() ) ];
	return ar[ 0 ];
}

procedure imageturkey() 
{
	image( 24, 23, 1, 
		[24, 0, 0, -23, 0, 23], 
		readpfun );
}

gsave();
translate( inch(3), inch(4) );
scale( inch(2), inch(2) );

procedure sub1 (x) {
	return 1-x;
}

settransfer( concatprocs( sub1, currenttransfer() ));

imageturkey();

// Include verbatim hexadecimal data here:
postscript( " 003B00 002700 002480 0E4940 114920 14B220 "
            " 3CB650 75FE88 17FF8C 175F14 1C07E2 3803C4 " 
            " 703182 F8EDFC B2BBC2 BB6F84 31BFC2 18EA3C "
            " 0E3E00 07FC00 03F800 1E1800 1FF800 " );

// NOTE:  literal strings are glued together, as in C/C++
		
grestore();
showpage();