These forums are CLOSED. Please visit the new forums HERE
looking for rgb2hex and hex2rgb |
|
|
Bobbyb30 Zohari
SL Mentor Coach
Join date: 11 Nov 2006
Posts: 466
|
03-22-2008 19:46
Is the hex format more efficient than the rgb format?
|
|
Bobbyb30 Zohari
SL Mentor Coach
Join date: 11 Nov 2006
Posts: 466
|
03-23-2008 05:54
I'd like to know what I'm doing wrong in my conversion of hex to rgb.
|
|
Kahiro Watanabe
Registered User
Join date: 28 Sep 2007
Posts: 572
|
03-23-2008 08:29
Actually it's the same, but with different representation the decimal way is have three separeate values from 0 to 255, using hex you have those three numbers in one like this:
For example, consider the color where the red/green/blue values are decimal numbers: red=36, green=104, blue=160 (a greyish-blue color). The decimal numbers 36, 104 and 160 are 24, 68 and A0 respectively in hexadecimal notation. To obtain the hex triplet, we simply write the three hex bytes together without spaces, thus: 2468A0. If a byte is less than 10 (decimal) or 16 (hex) it must be represented with a leading zero to keep the number of digits in the triplet equal to six. For example, the decimal triplet 0,1,2 would be represented by the hex triplet 000102. source: http://en.wikipedia.org/wiki/Web_colors LSL use the decimal way, and put it in a vector, so having it in hex format wont help you in anything. But if you want an hex2dec and dec2hex it can be done. |
|
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
|
03-23-2008 08:49
Actually, using normal vectors is more efficient when they're individual variables, but strings are more efficient as list elements.
Standalone vector: 18 bytes, Standalone string: 18 + <string length> bytes. List element vector: 23 bytes, List element string: 12 + <string length> bytes. Since you're always going to have some amount of characters in a RGB string, it only makes sense to use vectors standalone. But using a list of string elements is better than a list of vector elements, since you would at most use 6 characters in each string. _____________________
![]() |
|
Bobbyb30 Zohari
SL Mentor Coach
Join date: 11 Nov 2006
Posts: 466
|
03-23-2008 10:55
Actually, using normal vectors is more efficient when they're individual variables, but strings are more efficient as list elements. Standalone vector: 18 bytes, Standalone string: 18 + <string length> bytes. List element vector: 23 bytes, List element string: 12 + <string length> bytes. Since you're always going to have some amount of characters in a RGB string, it only makes sense to use vectors standalone. But using a list of string elements is better than a list of vector elements, since you would at most use 6 characters in each string. Hex can be stored as an integer, so its about 1/2 the memmory. |
|
Bobbyb30 Zohari
SL Mentor Coach
Join date: 11 Nov 2006
Posts: 466
|
03-23-2008 10:56
Also your memmory usage is quite off...see http://www.lslwiki.net/lslwiki/wakka.php?wakka=MemoryUsagefor the correct amounts.
|
|
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
|
03-23-2008 16:58
Well, that is indeed where I got my numbers, so if they don't agree, please point out how. Also, I assumed by 'hex,' you meant in string form. If you had access to that page and realized that it could easily be stored in an integer, besides the memory usages themselves, why post a thread in the first place, much less two?
_____________________
![]() |
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
03-23-2008 19:29
for most purposes it's going to be more efficient to just use the vector color, at least if your going to be applying it, because you'll have to convert to use it within SL. the only time you'd want to use the hex either in a string or a integer is if you were storing LOTS of them or wanted a friendly conversion for people that don't know the vector equivalent.
_____________________
|
| . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - |