[Javascript] How do I convert "FF" to 255?

Rui Fortes RuiFortes at clix.pt
Sun Apr 22 11:09:57 CDT 2001


Thanks a lot for the Help.
Actually I managed to solve it and I'm sorry I didn't post this.
I just used eval("0xff").
Here the code I used:

function gethicolor(colorstr)
{

  red = eval("0x" + colorstr.slice(1,3));
  green = eval("0x" + colorstr.slice(3,5));
  blue = eval("0x" + colorstr.slice(5,7));

  red = red + 50;
  green = green + 50;
  blue = blue + 50;

  if(red > 255)red = 255;
  if(green > 255)green = 255;
  if(blue > 255)blue = 255;

  return ((red * 65536) + (green * 256) + blue);
}

Just adding a fixed value to color components doens't result in a good
highlight but...

Thank's again.
Bye.

----- Original Message -----
From: "TomMallard" <mallard at serv.net>
To: <javascript at LaTech.edu>
Sent: Friday, April 20, 2001 6:50 PM
Subject: Re: [Javascript] How do I convert "FF" to 255?


> This works...
>
> parseInt('0xFF')
>
> The 0x means it's a hex number.
>
> tom
> ----- Original Message -----
> From: "Peter Brunone" <peter at brunone.com>
> To: <javascript at LaTech.edu>
> Sent: Friday, April 20, 2001 10:15 AM
> Subject: Re: [Javascript] How do I convert "FF" to 255?
>
>
>
>     Unfortunately, upon closer examination, I see that this doesn't do
jack.
>
>   ----- Original Message -----
>   From: Peter Brunone
>   To: javascript at LaTech.edu
>   Sent: Friday, April 20, 2001 12:10 PM
>   Subject: Re: [Javascript] How do I convert "FF" to 255?
>
>
>
>       According to the Netscape JavaScript reference, you can use
> escape(var) to get the hexadecimal value, and unescape(var) to get the
> decimal value.
>
>     ----- Original Message -----
>     From: Rui Fortes
>     To: javascript at LaTech.edu
>     Sent: Friday, April 20, 2001 11:23 AM
>     Subject: [Javascript] How do I convert "FF" to 255?
>
>
>     Hello.
>
>     How can I get an highlighted version of a color.
>     That is, how can I find the code of a color wich is a lighter version
of
> another color.
>     I tryed to do this myself but I need, for instance, to know how to get
a
> number from a string representing an hexadecimal number.
>     I could then add some value to RGB components and use RGB(newred,
> newgreen, newblue) to get that color.
>     I found Hex function that returns a string representing the
hexadecimal
> convertion of a number.
>     Is there an inverse function to turn a string into a number?
>     Something like afunc("FF") that returns 255.
>
>     Thanks
>
>
>
>
>
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> http://www.LaTech.edu/mailman/listinfo/javascript
>





More information about the Javascript mailing list