Point.st
changeset 3636 cba3cd259b32
parent 3562 813c3f1e99d7
child 4857 c29c6910114b
equal deleted inserted replaced
3635:3fcccef48db3 3636:cba3cd259b32
   359     ^ minX @ minY
   359     ^ minX @ minY
   360 ! !
   360 ! !
   361 
   361 
   362 !Point methodsFor:'converting'!
   362 !Point methodsFor:'converting'!
   363 
   363 
       
   364 asComplex
       
   365     "Return a complex number whose real and imaginary components are the x and y
       
   366      coordinates of the receiver."
       
   367 
       
   368     ^ x % y
       
   369 
       
   370     "Modified: / 9.7.1998 / 10:21:10 / cg"
       
   371 !
       
   372 
   364 asFractionalLayout
   373 asFractionalLayout
   365     "return a LayoutOrigin from the receiver,
   374     "return a LayoutOrigin from the receiver,
   366      treating the receiver coordinates as fractional parts 
   375      treating the receiver coordinates as fractional parts 
   367      (i.e. relative to superview).
   376      (i.e. relative to superview).
   368      Notice: in 10.5.x LayoutOrigin is not yet officially released."
   377      Notice: in 10.5.x LayoutOrigin is not yet officially released."
   618       (10 @ 10) quadrantContaining:(5 @ 15)   
   627       (10 @ 10) quadrantContaining:(5 @ 15)   
   619       (10 @ 10) quadrantContaining:(15 @ 5)  
   628       (10 @ 10) quadrantContaining:(15 @ 5)  
   620      "
   629      "
   621 !
   630 !
   622 
   631 
   623 rounded
       
   624     "return a new point with my coordinates rounded to the next integer."
       
   625 
       
   626     ^ (x rounded) @ (y rounded)
       
   627 !
       
   628 
       
   629 roundTo:aNumber
   632 roundTo:aNumber
   630     "return a new point with my coordinates rounded towards the next
   633     "return a new point with my coordinates rounded towards the next
   631      multiple of aNumber."
   634      multiple of aNumber."
   632 
   635 
   633     ^ (self / aNumber) rounded * aNumber
   636     ^ (self / aNumber) rounded * aNumber
   634 !
   637 !
   635 
   638 
   636 truncated
   639 rounded
   637     "return a new point with my coordinates truncated as integer."
   640     "return a new point with my coordinates rounded to the next integer."
   638 
   641 
   639     ^ (x truncated) @ (y truncated)
   642     ^ (x rounded) @ (y rounded)
   640 !
   643 !
   641 
   644 
   642 truncateTo:aNumber
   645 truncateTo:aNumber
   643     "return a new point with my coordinates truncated towards zero to the next
   646     "return a new point with my coordinates truncated towards zero to the next
   644      multiple of aNumber."
   647      multiple of aNumber."
   645 
   648 
   646     ^ (self quo:aNumber) rounded * aNumber
   649     ^ (self quo:aNumber) rounded * aNumber
       
   650 !
       
   651 
       
   652 truncated
       
   653     "return a new point with my coordinates truncated as integer."
       
   654 
       
   655     ^ (x truncated) @ (y truncated)
   647 ! !
   656 ! !
   648 
   657 
   649 !Point methodsFor:'point functions'!
   658 !Point methodsFor:'point functions'!
   650 
   659 
   651 dist:aPoint 
   660 dist:aPoint 
   975 ! !
   984 ! !
   976 
   985 
   977 !Point class methodsFor:'documentation'!
   986 !Point class methodsFor:'documentation'!
   978 
   987 
   979 version
   988 version
   980     ^ '$Header: /cvs/stx/stx/libbasic/Point.st,v 1.46 1998-06-12 15:53:14 cg Exp $'
   989     ^ '$Header: /cvs/stx/stx/libbasic/Point.st,v 1.47 1998-07-09 08:21:23 cg Exp $'
   981 ! !
   990 ! !
   982 Point initialize!
   991 Point initialize!