Skip to content

Instantly share code, notes, and snippets.

@Makopo
Created May 12, 2013 04:18
Show Gist options
  • Save Makopo/5562402 to your computer and use it in GitHub Desktop.
Save Makopo/5562402 to your computer and use it in GitHub Desktop.
from /indra/llmath/v3color.h
inline LLColor3::LLColor3(const char* color_string) // takes a string of format "RRGGBB" where RR is hex 00..FF
{
if (strlen(color_string) < 6) /* Flawfinder: ignore */
{
mV[0] = 0.f;
mV[1] = 0.f;
mV[2] = 0.f;
return;
}
char tempstr[7];
strncpy(tempstr,color_string,6); /* Flawfinder: ignore */
tempstr[6] = '\0';
mV[VZ] = (F32)strtol(&tempstr[4],NULL,16)/255.f;
tempstr[4] = '\0';
mV[VY] = (F32)strtol(&tempstr[2],NULL,16)/255.f;
tempstr[2] = '\0';
mV[VX] = (F32)strtol(&tempstr[0],NULL,16)/255.f;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment