[squeak-dev] The Inbox: Graphics-kfr.530.mcz
commits at source.squeak.org
commits at source.squeak.org
Tue Aug 9 05:12:31 UTC 2022
A new version of Graphics was added to project The Inbox:
http://source.squeak.org/inbox/Graphics-kfr.530.mcz
==================== Summary ====================
Name: Graphics-kfr.530
Author: kfr
Time: 9 August 2022, 7:12:20.983085 am
UUID: ee4a3ab4-fc38-f349-b0bc-f6f109ba9d01
Ancestors: Graphics-kfr.529
Avoid call to allButFirstDo: in Rectangle class>>encompassing: and Rectangle class>>merging:.
But keep the call to Rectangle class>>origin: corner: so subclasses can use these methods
=============== Diff against Graphics-kfr.529 ===============
Item was changed:
----- Method: Rectangle class>>encompassing: (in category 'instance creation') -----
encompassing: listOfPoints
"A number of callers of encompass: should use this method."
| topLeft bottomRight |
+ topLeft := bottomRight := nil.
+ listOfPoints do:
+ [:p | topLeft == nil
+ ifTrue: [topLeft := bottomRight := p]
+ ifFalse: [topLeft := topLeft min: p.
+ bottomRight := bottomRight max: p]].
+ ^self origin: topLeft corner: bottomRight!
- topLeft := bottomRight := listOfPoints first.
- listOfPoints allButFirstDo:
- [:p |topLeft := topLeft min: p.
- bottomRight := bottomRight max: p].
- ^self origin: topLeft corner: bottomRight
- !
Item was changed:
----- Method: Rectangle class>>merging: (in category 'instance creation') -----
merging: listOfRects
"A number of callers of merge: should use this method."
+ | minX minY maxX maxY |
- | bottomRight topLeft |
- topLeft := listOfRects first topLeft.
- bottomRight := listOfRects first bottomRight.
listOfRects
+ do: [:r | minX
+ ifNil: [minX := r topLeft x. minY := r topLeft y.
+ maxX := r bottomRight x. maxY := r bottomRight y]
+ ifNotNil: [minX := minX min: r topLeft x. minY := minY min: r topLeft y.
+ maxX := maxX max: r bottomRight x. maxY := maxY max: r bottomRight y]].
+ ^self origin: minX at minY corner: maxX at maxY!
- allButFirstDo: [:r | topLeft := topLeft min: r topLeft.
- bottomRight := bottomRight max: r bottomRight].
- ^self origin: topLeft corner: bottomRight.
- !
More information about the Squeak-dev
mailing list
|