WindowingTransformation.st
changeset 7059 2cfbbee08eb4
parent 7038 94deb70cb1cd
child 8595 7f9b84978a2e
child 8717 b40981a26bbd
equal deleted inserted replaced
7058:086498ec51e4 7059:2cfbbee08eb4
       
     1 "{ Encoding: utf8 }"
       
     2 
     1 "
     3 "
     2  COPYRIGHT (c) 1992 by Claus Gittinger
     4  COPYRIGHT (c) 1992 by Claus Gittinger
     3 	      All Rights Reserved
     5 	      All Rights Reserved
     4 
     6 
     5  This software is furnished under a license and may be used
     7  This software is furnished under a license and may be used
   511         ^ p * scale
   513         ^ p * scale
   512     ].
   514     ].
   513     ^ (p * scale + translation)
   515     ^ (p * scale + translation)
   514 !
   516 !
   515 
   517 
   516 transformRectangle:rect 
   518 transformRectangle:aRectangle 
   517     "Apply the receiver to a point, returning a new point."
   519     "Apply the receiver to a rectangle, returning a new rectangle."
   518 
   520 
   519     scale isNil ifTrue:[
   521     ^ aRectangle scaledBy:scale translatedBy:translation.
   520         translation isNil ifTrue:[
       
   521             ^ rect.
       
   522         ].
       
   523         ^ rect + translation
       
   524     ].
       
   525     translation isNil ifTrue:[
       
   526         ^ rect scaledBy: scale
       
   527     ].
       
   528     ^ (rect scaledBy: scale) + translation
       
   529 ! !
   522 ! !
   530 
   523 
   531 !WindowingTransformation methodsFor:'printing & storing'!
   524 !WindowingTransformation methodsFor:'printing & storing'!
   532 
   525 
   533 printOn:aStream
   526 printOn:aStream
   542 ! !
   535 ! !
   543 
   536 
   544 !WindowingTransformation methodsFor:'private'!
   537 !WindowingTransformation methodsFor:'private'!
   545 
   538 
   546 inverseTranslation
   539 inverseTranslation
   547     "return with a Point representing the inverse of my
   540     "return with a Point or Number representing the inverse of my
   548      translation."
   541      translation."
   549 
   542 
   550     |trans|
   543     translation isNil ifTrue:[
   551 
   544         ^ nil.
   552     trans := translation asPoint.
   545     ].
   553     ^ Point x:(trans x negated) y:(trans y negated)
   546     ^ translation negated.
   554 ! !
   547 ! !
   555 
   548 
   556 !WindowingTransformation methodsFor:'testing'!
   549 !WindowingTransformation methodsFor:'testing'!
   557 
   550 
   558 isIdentityTransformation
   551 isIdentityTransformation