[squeak-dev] The Trunk: Graphics-mt.531.mcz
commits at source.squeak.org
commits at source.squeak.org
Wed Aug 10 08:15:18 UTC 2022
Marcel Taeumel uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-mt.531.mcz
==================== Summary ====================
Name: Graphics-mt.531
Author: mt
Time: 10 August 2022, 10:15:13.741587 am
UUID: d7b78221-c876-6a43-8455-dba637d950dc
Ancestors: Graphics-eem.529, Graphics-kfr.530
Merge kfr.528, kfr.529, kfr.530 from inbox.
Graphics-kfr.530:
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
Graphics-kfr.529:
Floyd Steinberg dither for forms of 1 to 8 bit depth.
Graphics-kfr.528:
Color>>at: is slow. Speed up by using variable
=============== Diff against Graphics-eem.529 ===============
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 at y).
+ newColor := Color colorFromPixelValue: (oldColor pixelValueForDepth: aDepth) depth: aDepth.
+ result colorAt: x at y put: newColor.
+ quantError := (oldColor - newColor).
+ result at: x at 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 at imageY.
+ r := r + (color red *
- r := r + ((image colorAt: imageX at imageY) red *
(filter at: filterY + 1 at: filterX + 1)).
+ g := g + (color green *
- g := g + ((image colorAt: imageX at imageY) green *
(filter at: filterY + 1 at: filterX + 1)).
+ b := b + (color blue *
- b := b + ((image colorAt: imageX at imageY) blue *
(filter at: filterY + 1 at: filterX + 1))]].
result colorAt: x at 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 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
|