Rowen Stipe Posted March 2, 2022 Share Posted March 2, 2022 This function takes in a hex color code and concerts it into an RGB vector for LSL color. There is a basic check for if there's a # randomly in the string but no validation of the hexcode. //Convertes a hexcode into vector vector hex2Vec(string hex) { //remove poud sign from hexcode if(llSubStringIndex(hex, "#") == 0) { hex = llDeleteSubString(hex, 0, 0); } //sainty check to make sure there's no pound sign else if (llSubStringIndex(hex, "#") > 0) { llOwnerSay("Invalid hexcode: "+hex); return ZERO_VECTOR; } float r = (float)("0x"+llGetSubString(hex, 0, 1))/255; float g = (float)("0x"+llGetSubString(hex, 2, 3))/255; float b = (float)("0x"+llGetSubString(hex, 4, 5))/255; return <r,g,b>; } 1 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now