tri-hex'es
Blitz3D Forums/Blitz3D Programming/tri-hex'es What's a Tri-Hex?
Non-standard word?? *shrug*
A tri-hex is a hexadecimal RGB example: $ffffff is white
They're also called hexadecimal triplets
hexadecimal info
A tri-hex is a hexadecimal RGB example: $ffffff is white
They're also called hexadecimal triplets
hexadecimal info
excuse me for being a total idiot, but how do I use those?
tri_hex_thingy% = GetRGB(10, 20, 30)
or any value. More hints?
or any value. More hints?
thanks
I think this is what he's looking for:
Example of using it:
; Ascii value for each hex digit Dim giHexDigit(15) giHexDigit(0) = 48 giHexDigit(1) = 49 giHexDigit(2) = 50 giHexDigit(3) = 51 giHexDigit(4) = 52 giHexDigit(5) = 53 giHexDigit(6) = 54 giHexDigit(7) = 55 giHexDigit(8) = 56 giHexDigit(9) = 57 giHexDigit(10) = 65 giHexDigit(11) = 66 giHexDigit(12) = 67 giHexDigit(13) = 68 giHexDigit(14) = 69 giHexDigit(15) = 70 Function RGB_To_TriHex$(iR%,iG%,iB%) Return ToHex8(iR) + ToHex8(iG) + ToHex8(iB) End Function Function FromHex8%(sHex$) Local iValue% If Len(sHex) <> 2 Then Return 0 sHex = Upper(sHex) For i = 0 To 15 If giHexDigit(i) = Asc(Right(sHex,1)) Then iValue = i Exit End If Next For i = 0 To 15 If giHexDigit(i) = Asc(Left(sHex,1)) Then iValue = iValue + i * 16 Exit End If Next Return iValue End Function Function ToHex8$(iValue%) ; iValue must be 0-255 (8-bits) If iValue > 255 Or iValue < 0 Then RuntimeError("Invalid value passed to ToHex8() function.") Local iLow% = iValue Mod 16 Local iHi% = iValue Shr 4 Return Chr(giHexDigit(iHi)) + Chr(giHexDigit(iLow)) End Function Function Set_Color_Hex(sColorHex$) Color FromHex8(Left(sColorHex,2)),FromHex8(Mid(sColorHex,3,2)),FromHex8(Right(sColorHex,2)) End Function
Example of using it:
Include "Hex8.bb" Graphics 640,480 SetBuffer BackBuffer() ; Convert RGB values to "Tri-Hex" string. Text 0,0,RGB_To_TriHex(255,200,100) ; Use a "Tri-Hex" string to set the current color. Set_Color_Hex("FFAA00") Oval 200,200,100,100,True Flip WaitKey End
thanks guys