[squeak-dev] The Inbox: Graphics-kfr.529.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Jul 8 07:10:39 UTC 2022


A new version of Graphics was added to project The Inbox:
http://source.squeak.org/inbox/Graphics-kfr.529.mcz

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

Name: Graphics-kfr.529
Author: kfr
Time: 8 July 2022, 9:09:08.988763 am
UUID: c82ec469-0674-f04c-9123-0b36fb8eb7d6
Ancestors: Graphics-kfr.528

Floyd Steinberg dither for forms of 1 to 8 bit depth.

=============== Diff against Graphics-kfr.528 ===============

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.!



More information about the Squeak-dev mailing list