Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!rpi!metahawk From: metahawk@itsgw.rpi.edu (Wayne G Rigby) Newsgroups: comp.sys.amiga.graphics Subject: Re: 4096 in a row Message-ID: Date: 21 Mar 91 19:25:33 GMT References: Sender: Wayne Rigby Organization: Rensselaer Polytechnic Institute, Troy NY Lines: 58 Nntp-Posting-Host: jec415.its.rpi.edu In article swildner@channelz.gun.de (Sascha Wildner) writes: >Hello world! >Is there any way to get those 4096 colors of the Amiga in a row so that the >difference between color[n] and color[n+1] is only one modification of either >R, G or B? Don't understand what I mean? > > R G B >Color[0] = 0 0 0 >Color[1] = 0 0 1 >Color[2] = 0 1 1 >Color[3] = 0 1 0 would be correct, while If you mean that you want to line up all of the Amiga's 4096 colors in Gray Code order. Gray code is a binary coding scheme in which only one bit changes from one number to the next. The general algorithm for converting a binary number to a Gray number is as follows: Convert 10011 binary to Gray code. This is the same number shifted by one bit. | binary | 1 V = 1 0 + 1 = 1 MOD 2 = 1 0 + 0 = 0 MOD 2 = 0 1 + 0 = 1 MOD 2 = 1 1 + 1 = 2 MOD 2 = 0 So 10011 in binary is 11010 in Gray code. And 10100 in binary is 11110 in Gray code. The rest of the real numbers are left up to the reader to convert. A description Gray code is in Introduction to Computer Engineering by Franco P. Preparata ------------------------------------ and many other computer texts. > > R G B >Color[0] = 0 0 0 >Color[1] = 0 1 1 wouldn't be, because Color[1] differs from Color[0] by two > modifications (G & B). > >Is there a way to accomplish this for all 4096 colors? >-- > > > +---------------------------------------------------------------+ > | Sascha Wildner, Am Druvendriesch 27, W-5030 Huerth 6, Germany | > | | > | Phone : +49 2233 15571 Zerberus: S.WILDNER@TBC.ZER | > | MagicNet: DINO-BOX:BILBO UUCP : swildner@channelz.gun.de | > | Fido : 2:241/5008 | > +---------------------------------------------------------------+ Wayne Rigby metahawk@rpi.edu