diff -r 84a039c64a6b -r 0f034b43ac9b Rectangle.st --- a/Rectangle.st Fri Nov 24 09:13:05 2017 +0100 +++ b/Rectangle.st Mon Nov 27 11:34:08 2017 +0100 @@ -456,12 +456,14 @@ ! extent:aPoint - "set the extent from the argument, aPoint with width taken from aPoint x - and height taken from aPoint y. + "set the extent from the argument, aPoint + with width taken from aPoint x and height taken from aPoint y. warning: destructive" width := aPoint x. height := aPoint y + + "Modified (comment): / 27-11-2017 / 10:57:46 / cg" ! height @@ -1041,20 +1043,24 @@ ! moveBy:aPoint - "destructively translate the rectangle by some distance. + "destructively translate the rectangle by some distance (keeping extent unchanged). sorry for the name inconsistency - but GNU-ST named it that way" left := left + aPoint x. top := top + aPoint y + + "Modified (comment): / 27-11-2017 / 10:42:54 / cg" ! moveTo:aPoint - "destructively translate the rectangle to have its origin at aPoint." + "destructively translate the rectangle to have its origin at aPoint (keeping extent unchanged)." |diff| diff := aPoint - self origin. self origin:aPoint corner:self corner + diff + + "Modified (comment): / 27-11-2017 / 10:42:48 / cg" ! scaleBy:scale @@ -1094,7 +1100,7 @@ translateBy:amount "translate (i.e. move) the receiver rectangle - by amount, a Point or Number. + by amount, a Point or Number (keeping extent unchanged). This is destructive (modifies the receiver, not a copy) and should only be used if you know, that you are the exclusive owner of the receiver. (use translatedBy if in doubt)" @@ -1102,12 +1108,12 @@ |amountPoint| (amount isMemberOf:Point) ifTrue:[ "type hint to stc" - left := left + amount x. - top := top + amount y + left := left + amount x. + top := top + amount y ] ifFalse:[ - amountPoint := amount asPoint. - left := left + amountPoint x. - top := top + amountPoint y + amountPoint := amount asPoint. + left := left + amountPoint x. + top := top + amountPoint y ] " @@ -1122,6 +1128,8 @@ r2 := r1 translateBy:10. r1 " + + "Modified (comment): / 27-11-2017 / 10:43:12 / cg" ! ! !Rectangle methodsFor:'displaying'!