Marcel Taeumel uploaded a new version of Graphics to project The Trunk: http://source.squeak.org/trunk/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.527 ===============
Item was added: + ----- Method: Form>>at:bias: (in category 'processing') ----- + at: aPoint bias: aQuantError + | x y color point oldColor | + x := aPoint x. + y := aPoint y. + + point := (x + 1 min: self width)@ y. + oldColor := self colorAt: point. + color := oldColor + (aQuantError * 0.4375). "7/16" + self colorAt: point put: color. + + point := (x - 1 max: 0)@ (y + 1 min: self height). + oldColor := self colorAt: point. + color := oldColor + (aQuantError * 0.1875)."3/16" + self colorAt: point put: color. + + point := x @ (y + 1 min: self height). + oldColor := self colorAt: point. + color := oldColor + (aQuantError * 0.3125 ) ."5/16" + self colorAt: point put: color. + + point := (x + 1 min: self width) @ (y + 1 min: self height). + oldColor := self colorAt: point. + color := oldColor + (aQuantError * 0.0625 ) ."1/16" + self colorAt: point put: color. + !
Item was added: + ----- Method: Form>>dither: (in category 'processing') ----- + dither: aDepth + | newColor oldColor quantError result | + "Floyd Steinberg dithering for depth 1 to 8 bits" + result := self copy. + (0 to: height) do:[:y| + (0 to: width) do:[:x| + oldColor := (result colorAt: x@y). + newColor := Color colorFromPixelValue: (oldColor pixelValueForDepth: aDepth) depth: aDepth. + result colorAt: x@y put: newColor. + quantError := (oldColor - newColor). + result at: x@y bias: quantError]]. + ^result.!
Item was changed: ----- Method: Form>>processUsingKernel:factor:bias: (in category 'processing') ----- processUsingKernel: filter factor: factor bias: bias + | image result color | - | image result |
image := self. result := Form extent: image extent depth: image depth.
0 to: image height - 1 do: [:y | 0 to: image width - 1 do: [:x | | r g b | r := g := b := 0.0.
0 to: filter rowCount - 1 do: [:filterY | 0 to: filter columnCount - 1 do: [:filterX | | imageX imageY | imageX := (x - (filter columnCount // 2) + filterX + image width) \ image width. imageY := (y - (filter rowCount // 2) + filterY + image height) \ image height. + color := image colorAt: imageX@imageY. + r := r + (color red * - r := r + ((image colorAt: imageX@imageY) red * (filter at: filterY + 1 at: filterX + 1)). + g := g + (color green * - g := g + ((image colorAt: imageX@imageY) green * (filter at: filterY + 1 at: filterX + 1)). + b := b + (color blue * - b := b + ((image colorAt: imageX@imageY) blue * (filter at: filterY + 1 at: filterX + 1))]].
result colorAt: x@y put: (Color r: ((factor * r + bias) min: 1.0 max: 0.0) g: ((factor * g + bias) min: 1.0 max: 0.0) b: ((factor * b + bias) min: 1.0 max: 0.0))]]. ^ result !
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@minY corner: maxX@maxY! - allButFirstDo: [:r | topLeft := topLeft min: r topLeft. - bottomRight := bottomRight max: r bottomRight]. - ^self origin: topLeft corner: bottomRight. - !
packages@lists.squeakfoundation.org