[ENH][Nit] Enhance to Color>>#printOn: to show color names

David N. Smith (IBM) dnsmith at watson.ibm.com
Sun Feb 6 21:21:41 UTC 2000


David:

There is a simpler solution; I'm surprised you missed it. Pay attention!

Dave


'From Squeak2.7 of 5 January 2000 [latest update: #1789] on 6 February 2000 at 4:15:59 pm'!

!Color methodsFor: 'printing' stamp: 'dns 2/6/2000 16:14'!
printOn: aStream  "DNS"
	| name |

	(name := self name) notNil ifTrue: [
		^ aStream
			nextPutAll: 'Color ';
			nextPutAll: name ].

	self storeOn: aStream.
! !



At 16:08 -0500 2/6/2000, David N. Smith \(IBM\) wrote:
>I got tired of naming colors only to have Color>>#printOn: not tell me the names, so here is a fix for the problem. It loops up each color name and if none match the color, then shows the colors using #r:g:b:.
>
>The code is attached and also added below.
>
>Dave
>
>
>
>'From Squeak2.7 of 5 January 2000 [latest update: #1789] on 6 February 2000 at 3:55:15 pm'!
>
>!Color methodsFor: 'printing' stamp: 'dns 2/6/2000 15:55'!
>printOn: aStream  "DNS"
>	| tryColor |
>
>	self class colorNames do: [ :aColorName |
>		tryColor := self class perform: aColorName asSymbol.
>		self = tryColor ifTrue: [
>			^ aStream
>				nextPutAll: 'Color ';
>				nextPutAll: aColorName ] ].
>
>	self storeOn: aStream.
>! !
>Attachment converted: PPC9500:Color-printOn.st (TEXT/R*ch) (00016288)
>_______________________________
>David N. Smith
>IBM T J Watson Research Center
>Hawthorne, NY
>_______________________________
>Any opinions or recommendations
>herein are those of the author 
>and not of his employer.
-------------- next part --------------
Skipped content of type multipart/appledouble-------------- next part --------------
_______________________________
David N. Smith
IBM T J Watson Research Center
Hawthorne, NY
_______________________________
Any opinions or recommendations
herein are those of the author  
and not of his employer.


More information about the Squeak-dev mailing list