[comp.sys.amiga.graphics] 4096 in a row

swildner@channelz.gun.de (Sascha Wildner) (03/21/91)

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

           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                                          |
       +---------------------------------------------------------------+

tomb@hplsla.HP.COM (Tom Bruhns) (03/22/91)

swildner@channelz.gun.de (Sascha Wildner) writes:
>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?

The explanation did not make it absolutely clear:  is a transition in a
given color allowed to be more than one level at a time (in what you want)?
If so, one answer to your question is to gray-code the 12 bits; in gray
(or maybe Gray ;-) code, only one bit changes each step, all the way
around a circle till you get back where you started.  I believe this
also would be allowed in HAM (though I have to admit I'm only marginally
familiar with HAM's limitations).  You should be able to find documentation
on Gray code in any library with a techinical section.  

e.g.:   Bin   Gray         Bin   Gray
       0000   0000        1000   1100
       0001   0001        1001   1101
       0010   0011        1010   1111
       0011   0010        1011   1110
       0100   0110        1100   1010
       0101   0111        1101   1011
       0110   0101        1110   1001
       0111   0100        1111   1000

A symmetry should be apparent in the Gray code.  You can generate
Gray code from straight binary through appropriate XOR op's, I believe.
Gray is used for things like optical encoders to insure that transitions
from one word to the next don't generate outputs that appear to come from
a "long ways away".

metahawk@itsgw.rpi.edu (Wayne G Rigby) (03/22/91)

In article <swildner.3264@channelz.gun.de> 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

pashdown@javelin.es.com (Pete Ashdown) (03/22/91)

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?

Umm, I believe this is what is commonly known as "HAM" mode.
-- 
		  "Why can't I be you?" - Robert Smith
		  "Why can't he be you?" - Patsy Cline
		  "Why can't you be you?" - `Seven Faces of Eve'
Pete Ashdown  pashdown@javelin.sim.es.com ...uunet!javelin.sim.es.com!pashdown