peskin@caip.rutgers.edu (R. L. Peskin) (04/09/91)
In answer to my own question, here is something that will work to rotate text
on PPS Rel. 4. The text is created on a Pixmap first (so it is not visible),
the Pixmap converted to an Image, the image rotated, and the new image
displayed. However, on our copies of Rel. 4, there appears to be an error in
Image >> rotateByQuadrants:to:. The statement about midway through the method
that starts with "(newImage isLike: ..............) should be removed.
Otherwise an exception will be hit if you try to rotate by an odd number of
quads.
TextRotation of: aString on: aGraphicsContext by: quads at: aPoint
| aPixmap aCtext anImage trImage |
aCtext := aString asComposedText.
aPixmap := Pixmap extent: aCtext width @ aCtext height .
aCtext displayOn: aPixmap asImage.
anImage := aPixmap asImage.
trImage := anImage rotatedByQuadrants: quads.
trImage displayOn: aGraphicsContext at: aPoint.
If you want to display the text in color, you may want to change the use of
Pixmap to a subclass of Pixmap, say UserPixmap. UserPixmap would have the
message extent:depth:paint as a class method for instance creation. (It adds
the line 'pixmap defaultPaint: aColorValue' to the extent: depth: method in
Pixmap.) It will also need to set and return 'defaultPaint' as an instance
protocol, and 'paint' should be UserPixmap's instance variable. As delivered,
Pixmap has no convenient way to set a default paint color.
--dick peskin
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Richard L. Peskin Computational Engineering Systems Lab
CAIP Center P. O. Box 1390 Rutgers University
Piscataway, N. J. 08855-1390
net: peskin@caip.rutgers.edu AppleLink: D6615
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%