Skip to content

Instantly share code, notes, and snippets.

@tcatm
Created March 15, 2016 11:07
Show Gist options
  • Save tcatm/2a268d4fdbd5ce5e1c81 to your computer and use it in GitHub Desktop.
Save tcatm/2a268d4fdbd5ce5e1c81 to your computer and use it in GitHub Desktop.
uint32_t ret = 0;
uint32_t Vi = float2uint8_t(myHsv->lightness);
uint32_t ti = float2uint8_t(t);
uint32_t pi = float2uint8_t(p);
uint32_t qi = float2uint8_t(q);
uint8_t Vs, ts, ps, qs;
if (hi%6 == 0){
// V t p
Vs = 16;
ts = 8;
ps = 0;
qs = 32;
}
else if (hi == 1){
// q v p
Vs = 8;
ts = 32;
ps = 0;
qs = 16;
}
else if (hi == 2){
// p V t
Vs = 8;
ts = 0;
ps = 16;
qs = 32;
}
else if (hi == 3){
// p q V
Vs = 32;
ts = 0;
ps = 16;
qs = 8;
}
else if (hi == 4){
// tpV
Vs = 0;
ts = 16;
ps = 8;
qs = 32;
}
else if (hi == 5){
// V p q
Vs = 16;
ts = 32;
ps = 8;
qs = 0;
}
ret = (Vi << Vs) | (ti << ts) | (pi << ps) | (qi << qs);
return ret;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment