Post Scriptum language

// Example 2

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

procedure centersquare() {
	newpath();
	moveto( .5, .5 );
	lineto( -.5, .5 );
	lineto( -.5, -.5 );
	lineto( .5, -.5 );
	closepath();
}

gsave();
translate( inch(2.5), inch(6) );
setlinewidth( 1/16 );

for (i=1 to 6) {
	gsave();
	scale( inch(.5 * i), inch(.5 * i) );
	centersquare();
	stroke();
	grestore();
}
grestore();

gsave();
translate( inch(6), inch(6) );
setlinewidth( 1 );
cmtx = currentmatrix( matrix() );
for (i=1 to 6) {
	gsave();
        
        // Trick: scale() takes two identical arguments
	scale( dup(inch(.5 * i)) );  

	centersquare();
	setmatrix( cmtx );
	stroke();
	grestore();
}
grestore();

showpage();