[squeak-dev] The Trunk: Graphics-kfr.436.mcz

commits at source.squeak.org commits at source.squeak.org
Sat Aug 22 09:47:49 UTC 2020


Karl Ramberg uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-kfr.436.mcz

==================== Summary ====================

Name: Graphics-kfr.436
Author: kfr
Time: 22 August 2020, 11:47:40.557622 am
UUID: 50875d76-6a37-3c49-a0b7-97d9186fb2d6
Ancestors: Graphics-mt.433

I wanted to subclass Rectangle with a instance variable to carry some state, but these methodes indirected to Point>>corner: so it broke the override and returned a ordinary Rectangle instead of my fancy new subclass SuperRectangle

Updated to  use #first to get the first element and #allButFirstDo: to iterate over the rest.
(Suggested by Levente Uzonyi)

=============== Diff against Graphics-mt.433 ===============

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 := listOfPoints first.
+ 	listOfPoints allButFirstDo:
+ 		[:p |topLeft := topLeft min: p.
+ 					bottomRight := bottomRight max: p].
+ 	^self origin: topLeft corner: bottomRight
+ 	!
- 	topLeft := bottomRight := nil.
- 	listOfPoints do:
- 		[:p | topLeft == nil
- 			ifTrue: [topLeft := bottomRight := p]
- 			ifFalse: [topLeft := topLeft min: p.
- 					bottomRight := bottomRight max: p]].
- 	^ 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."
+ 	| bottomRight topLeft |
+ 	topLeft := listOfRects first topLeft.
+ 	bottomRight := listOfRects first bottomRight.
- 	| minX minY maxX maxY |
  	listOfRects
+ 		allButFirstDo: [:r | topLeft := topLeft min: r topLeft.
+ 			bottomRight := bottomRight max: r bottomRight].
+ 	^self origin: topLeft corner: bottomRight.
+ 	!
- 		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]].
- 	^ minX at minY corner: maxX at maxY!



More information about the Squeak-dev mailing list