Re: Confused about color

Brooke Smith (bbos@staff.cs.su.oz.au)
Thu, 27 Apr 1995 04:15:08 +0500


>
> >>Hi,
> >>Does anyone know where to get the table of the hexidecimal# for changing the
> >>text color, and the spec for changing those text color.
>
> an easy way to get the numbers for colors if you have a mac with system
> 7.5: open the labels control panel, choose more choices, select the apple
> RGB choice and this will give you the red, green, and blue percentages for
> any color you could want.
>
> Photoshop 3.0 may also have this choice in its color window palette but im
> unsure.
>
> ron
>
>

I've never used the system 7.5 label colour wheel, but have the 7.1
version. It returns 2 byte unsigned integers. Anyway, to convert
these to hex values follow this algorithm where val is the value to
be converted.

Note that the hex digits are 0..9,a,b,c,d,e,f where a..f represent
10..15

While val > 0
do
x = power of 16 <= val (so that val >= 16^x)
y = a value such that y*(16^x) <= val
output y to RHS of current output
Note that if a power of 16 is missed then output 0.
val = val - y*(16^x)
done

eg. 31706 in integer

val = 31706
x = 3
y = 7 (since 7*(16^3) <= val; 28672 <= 31706)
output = 7

val = 3034
x = 2
y = 11
output = 7b

val = 218
x = 1
y = 13
output = 7bd

val = 10
x = 0
y = 10
output = 7bda

====

So now 7*16^3 + 11*16^2 + 13*16^1 + 10*16^0 = 31706

I hope that helps,

BBOS

-- 
Brooke Benjamin Oehm Smith
Honours '95 Sydney University Computer Science
email: bbos@cs.su.oz.au
URL: <http://www.cs.su.oz.au/~bbos>

"Once somethings been approved by the government it's no longer immoral." Reverend Lovejoy, The Simpsons.