Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

What is the meaning for format #%02x%02x%02x

3,435 views
Skip to first unread message

parag...@hotmail.com

unread,
Sep 30, 2007, 8:50:20 AM9/30/07
to
when you say

format #%02x%02x%02x [<some input command>] [same] [same]

What is the purpose of the above

Neil Madden

unread,
Sep 30, 2007, 9:56:24 AM9/30/07
to

It formats three numbers as 2 digit hexadecimal strings with leading 0s
used if the number only consists of a single digit in hex. The '#' is
just a literal character. Read the format man page for more information:
http://tmml.sourceforge.net/doc/tcl/format.html . For example, suppose
your input commands returned the numbers 255, 100, and 37, then you'd
get back a string "#ff6425", where FF in hex = 255 in decimal, 64 hex =
100 decimal, and 25 hex = 37 decimal.

At a guess, I'd say the code is producing RGB colour values for use in
HTML/CSS.

-- Neil

parag...@hotmail.com

unread,
Oct 1, 2007, 5:39:51 AM10/1/07
to
You are correct Neil
For RGB usage :)

There is no dearth of expertise in this world !!

Jeff Hobbs

unread,
Oct 1, 2007, 1:16:42 PM10/1/07
to parag...@hotmail.com

Someone is creating an #RRGGBB triplet most likely.

Jeff

parag...@hotmail.com

unread,
Oct 3, 2007, 7:30:13 AM10/3/07
to
hi Neil

> For example, suppose
> your input commands returned the numbers 255, 100, and 37, then you'd
> get back a string "#ff6425", where FF in hex = 255 in decimal, 64 hex

> 100 decimal, and 25 hex = 37 decimal.


You told that is will be #ff6425, but isnt it supposed to be ,
0xff6425 unless the first digit is a 0

suchenwi

unread,
Oct 3, 2007, 9:28:31 AM10/3/07
to
parag...@hotmail.com schrieb:

That's a different specification. RGB colors in Tk, HTML and such use
the #RRGGBB format, which the discussed code delivers. Easily tested
in an interactive tclsh:

19% format #%02x%02x%02x 255 100 37
#ff6425

But if you want to mark it up with "0x" prefix, that's easy too:

20% format 0x%02x%02x%02x 255 100 37
0xff6425

0 new messages