[ENH] Color>>asHTMLColor
Randy Bohn
rsbohn at rocketmail.com
Mon May 31 22:41:37 UTC 2004
!Color methodsFor: 'conversions' stamp: 'rsb 5/31/2004 10:28'!
asHTMLColor
"Convert the receiver into an HTML color.
Color white asHTMLColor -> '#FFFFFF'
Color black asHTMLColor -> '#000000'
(Color fromString: '#FF8800') -> '#FF8800'"
|n|
^ String streamContents:
[:stream |
stream nextPut: $#.
n _ (self red * 256) truncated min: 255.
stream nextPut: (n // 16) asHexDigit.
stream nextPut: (n \\ 16) asHexDigit.
n _ (self green * 256) truncated min: 255.
stream nextPut: (n // 16) asHexDigit.
stream nextPut: (n \\ 16) asHexDigit.
n _ (self blue * 256) truncated min: 255.
stream nextPut: (n // 16) asHexDigit.
stream nextPut: (n \\ 16) asHexDigit.
]! !
__________________________________
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/
More information about the Squeak-dev
mailing list
|