Hi Ely,

I (mostly) understand the concept in your example but am getting an
error that I can't figure out for the life of me. On the line where
you assign newGreyByte its telling me "1084: Syntax error: expecting
rightparen before myGreys.".

Also, shouldn't myGreys[2] be utilized somewhere?

Thanks,
Ben


--- In [email protected], "Ely Greenfield" <[EMAIL PROTECTED]> wrote:
>
>  
> 
>  
> 
> Grey RGB values have the same byte value in each of the rbg channels.
> So your best bet is to store your grey values as single byte hex values
> 
>  
> 
> myGreys = [0xAA, 0x58, 0x22];
> 
>  
> 
> then interpolate between those values:
> 
>  
> 
> var newGreyByte:uint = ((myGreys[0] + (myGreys[1] - myGreys[0]) *
> Math.random()) as uint);
> 
>  
> 
> Then create an rgb value out if that:
> 
>  
> 
> var newGreyRGB:uint = (newGreyByte << 16) + (newGreyByte << 8) +
> newGreyByte;
> 
>  
> 
> Ely.
> 
>  
> 
>  
> 
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of ben.clinkinbeard
> Sent: Wednesday, September 12, 2007 9:59 AM
> To: [email protected]
> Subject: [flexcoders] How do I generate random colors (within a range)?
> 
>  
> 
> OK, my hex and bitwise skills are non-existent, so I am probably on
> the completely wrong track here, but... I converted a couple of hex
> values to decimal values (11776947 and 10724259) with an online
> converter. They each evaluate to a shade of gray (as expected), but
> when I generate random values that fall between the two and use them
> in the drawing API they are not shades of gray. I'm sure plenty of you
> are saying "duh", but if you could also suggest a way to randomly
> generate differing shades of gray I would be most appreciative.
> 
> I suppose the chances of someone having written a RandomGrayGenerator
> class is pretty slim, so I am open to more general courses of action
> as necessary.
> 
> Thanks,
> Ben
>


Reply via email to