Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!cs.utexas.edu!husc6!linus!mbunix!bwk From: bwk@mitre-bedford.ARPA (Barry W. Kort) Newsgroups: comp.lang.smalltalk Subject: Color Forms in ParcPlace Smalltalk Summary: There's got to be a better way. Message-ID: <40679@linus.UUCP> Date: 5 Oct 88 19:48:25 GMT Sender: news@linus.UUCP Reply-To: bwk@mbunix (Kort) Organization: The MITRE Corporation, Bedford, Mass. Lines: 37 At OOPSLA '88, Sam Adams, Nanette Harter, and I discussed the problem of drawing bi-colored forms using the ColorDevice class. The following hack transforms an ordinary form into one that will display a foreground color over a background color. This method seems horribly inefficient. Perhaps someone can offer a better way. ------------Rape and Paste--------------------- 'From Smalltalk-80, Version 2.3 of 13 June 1988 on 5 October 1988 at 8:14:31 am'! !Form methodsFor: 'color forms'! foreColor: fcolor backColor: bcolor "Return a new form which can be displayed in color using ColorDevice. This version works only for forms of width 8, 16, and multiples of 16." | cform cindex sno cbits cno | cform _ self class new width: self width * 8 height: self height. cbits _ cform bits. cindex _ 0. 1 to: bits size do: [ :sindex | sno _ bits at: sindex. 14 to: width \\ 16 by: -2 do: [ :bindex | cindex _ cindex + 1. cno _ sno bitShift: 0 - bindex. cno _ cno bitAnd: 3. cno = 0 ifTrue: [ cbits at: cindex put: bcolor * 256 + bcolor]. cno = 1 ifTrue: [ cbits at: cindex put: bcolor * 256 + fcolor]. cno = 2 ifTrue: [ cbits at: cindex put: fcolor * 256 + bcolor]. cno = 3 ifTrue: [ cbits at: cindex put: fcolor * 256 + fcolor]]]. ^ cform! ! ------------------------------------------- --Barry Kort