[comp.lang.smalltalk] text as images

peskin@caip.rutgers.edu (R. L. Peskin) (04/05/91)

Under PPS 2.5 we were able to rotate strings, because we could convert strings 
to Images. Does anyone know how this can be done under PPS Re. 4? It appears 
that Text is directly written to the display surface in the appropriate 
GraphicsContext (like it is  in X). Any ideas on how to convert a String to an 
Image (short of a set of new primitives)?

--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           
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 

bjorne@nada.kth.se (Bj|rn Eiderb{ck) (04/05/91)

In article <Apr.4.17.23.12.1991.18245@caip.rutgers.edu> peskin@caip.rutgers.edu (R. L. Peskin) writes:
>
>Under PPS 2.5 we were able to rotate strings, because we could convert strings 
>to Images. Does anyone know how this can be done under PPS Re. 4? It appears 
>that Text is directly written to the display surface in the appropriate 
>GraphicsContext (like it is  in X). Any ideas on how to convert a String to an 
>Image (short of a set of new primitives)?
>
>--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           
>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>
> 

You could for example create an instance of a Pixmap
and do the following:
1) send the message displayString:at: to the pixmaps graphicsContext
    with the string and position as arguments.

2) convert the pixmap to an image via the method asImage.

3) finally rotate and display the image via the messages rotatedByQuadrants: and 
    displayOn:.

Here is a simple example of this (in the class Pixmap):
   exampleRotatedText
      "Pixmap exampleRotatedText"

      | ext pix gc |
      ext := 400 @ 20.
      pix := self extent: ext.
      pix graphicsContext displayString: 'This is the string that should be rotated!' at: 0 @ 10.
      gc := ScheduledControllers activeController view graphicsContext.
      (pix asImage rotatedByQuadrants: 1)
            displayOn: gc

-- bjorn eiderback


***************************************************************
  Bjorn Eiderback
  Department of Numerical Analysis and Computing Science
  Royal Institute of Technology
  S-100 44 Stockholm
  Sweden
  e-mail: bjorne@nada.kt.se
  voice: +46 (8) 790 6277
***************************************************************