Results 1 to 6 of 6

Thread: Hex color

  1. #1

    Thread Starter
    Banned nareth's Avatar
    Join Date
    Jun 2004
    Posts
    1,206

    Resolved Hex color

    i noticed D3DX8 uses hex colors in this format: &HXXRRGGBB
    how do i make a function that can create that format with XX in % and RR GG BB in 255
    Last edited by nareth; Jan 22nd, 2005 at 06:13 AM.

  2. #2
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Re: Hex color

    Quote Originally Posted by nareth
    i noticed D3DX8 uses hex colors in this format: &HXXRRGGBB
    how do i make a function that can create that format with XX in % and RR GG BB in 255
    Well, for starters, you could tell us what the input to the functino might be...
    Nobody knows what software they want until after you've delivered what they originally asked for.

    Don't solve problems which don't exist.

    "If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)

    2 idiots don't make a genius.

  3. #3
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: Hex color

    Where did you see that....you can usualy use the RGB() function to convert colors to a long in DX.


    ØØ

  4. #4

    Thread Starter
    Banned nareth's Avatar
    Join Date
    Jun 2004
    Posts
    1,206

    Re: Hex color

    Quote Originally Posted by NoteMe
    Where did you see that....you can usualy use the RGB() function to convert colors to a long in DX.


    ØØ
    not in D3DX8 because it uses transperancie i tried using rgb but that failed drawing text so i need a function like
    VB Code:
    1. XRGB(ByVal X As Long, ByVal R As Long, ByVal G As Long, ByVal B As Long)
    2. 'X Should be a ratio of 1 and generate hex from 00 to FF
    3. 'R/G/B Should be 0-255 and generate hex from 00 to FF

  5. #5
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Hex color

    so you have a RGB value and you want to convert it to a hex number

    XRGB(ByVal X As Long, ByVal R As Long, ByVal G As Long, ByVal B As Long)
    VB Code:
    1. myhex = "&H" & Hex(r) & Hex(g) & Hex(b)

    just add x to that if want

    rgds pete

  6. #6

    Thread Starter
    Banned nareth's Avatar
    Join Date
    Jun 2004
    Posts
    1,206

    Re: Hex color

    thanks!

    VB Code:
    1. Public Function XRGB(X As Long, R As Long, G As Long, B As Long) As Long
    2.     Let XRGB = CLng("&H" & Hex(X) & Hex(R) & Hex(G) & Hex(B))
    3. End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width