[futurebasic] Re: [FB] RGB to HTML COLOR

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : December 2003 : Group Archive : Group : All Groups

From: Robert Covington <artlythere@...>
Date: Tue, 16 Dec 2003 17:48:56 -0500
On Tuesday, December 16, 2003, at 04:42  PM, David A. Bailey wrote:

> Anybody know how to convert to and from RGB and HTML color.
>
> Such as
>
> red = 24123
> green = 12000
> blue = 32000
>
> How would you convert this to something like #ccfodd  (not the correct
> conversion of the numbers above)
>
> Any thing I try results in a 12 place string for the HTML color 
> instead of
> the six character format.
>
> Thanks
>
> David


I think them puppies are sampled at Quantum Potato Hotspots, such that 
you will be doing Thus:

red = 24123\256

r$ = Right$(Hex$(red),2)

Demo (Fb3 Console)


DIM red   as long
DIM green as long
DIM blue  as long

DIM r$,g$,b$,htmlrgb$

red   = 24123 >> 8 // Convert to 0-255
green = 12000 >> 8
blue  = 32000 >> 8

print red
print green
print blue

r$ = Right$(Hex$(red),2)
print r$
g$ = Right$(Hex$(green),2)
print g$
b$ = Right$(Hex$(blue),2)
print b$

htmlrgb$ = r$+g$+b$

print htmlrgb$