'From Squeak3.7beta of ''1 April 2004'' [latest update: #5923] on 3 June 2004 at 11:23:07 am'! "Change Set: asHtmlColor Date: 3 June 2004 Author: rsb Convert the receiver into an HTML color. Color white asHTMLColor -> '#FFFFFF' Color black asHTMLColor -> '#000000' (Color fromString: '#FF8800') -> '#FF8800' "! ClassTestCase subclass: #ColorTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Graphics-Primitives-Tests'! !Color methodsFor: 'conversions' stamp: 'md 6/3/2004 11:16'! asHTMLColor "Convert the receiver into an HTML color." |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. ] ! ! !ColorTest methodsFor: 'testing' stamp: 'md 6/3/2004 11:21'! testAsHTMLColor self assert: (Color white asHTMLColor = '#FFFFFF'). self assert: (Color black asHTMLColor = '#000000').! ! !ColorTest methodsFor: 'testing' stamp: 'md 6/3/2004 11:18'! testFromString self assert: ((Color fromString: '#FF8800') asHTMLColor = '#FF8800').! ! ColorTest removeSelector: #testasHTMLColor! !ColorTest reorganize! ('testing' testAsHTMLColor testFromString) !