[squeak-dev] The Trunk: Graphics-jmg.191.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Jan 10 00:57:37 UTC 2014


Nicolas Cellier uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-jmg.191.mcz

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

Name: Graphics-jmg.191
Author: jmg
Time: 6 January 2012, 2:37:58.42 pm
UUID: 64aae19a-1a36-a346-ae1c-48f25bf77127
Ancestors: Graphics-bf.190

asColorref was using the color's green element twice, instead of red, green, and blue. Also, Color did not have a symmetrical constructor to create a Color from a colorref. Finally, converting from a float to an integer by using asInteger, rather than round seemed like the wrong thing to do. 

I tested this by iterating through Color class>>indexedColors, and converting them to colorrefs, then creating a Color from the colorref, and comparing the original with the new color.  Without rounding I received ~239 failures and with rounding I received ~21 (still to be expected as we are converting a float in the range 0.0 - 1.0 to an integer in the range 0 - 255, so there will still be some error).

=============== Diff against Graphics-bf.190 ===============

Item was added:
+ ----- Method: Color class>>fromColorref: (in category 'instance creation') -----
+ fromColorref: aColorref 
+ 	| red green blue |
+ 	red := aColorref bitAnd: 255.
+ 	green := (aColorref bitAnd: 65280)
+ 				>> 8.
+ 	blue := (aColorref bitAnd: 16711680)
+ 				>> 16.
+ 	^ self r: red g: green b: blue range: 255.!

Item was changed:
  ----- Method: Color>>asColorref (in category 'conversions') -----
  asColorref
  	"Convert the receiver into a colorref"
+ 	^ (self red * 255) rounded + ((self green * 255) rounded << 8) + ((self blue * 255) rounded << 16)!
- 	^(self red * 255) asInteger + ((self green * 255) asInteger << 8) + ((self green * 255) asInteger << 16)!



More information about the Squeak-dev mailing list