Providing RGB code

// Public-domain function by Darel Rex
// Finley, 2022.
//
// The input values may be from 0 to
// 1, or from 0 to 255, or any 0-based
// scale, but all three values must
// use the same scale. Returns a hue
// value from 0 to 1. (If hue is
// undefined, returns 0.)

double RGBtoHue(
double R, double G, double B) {
return
R==G && R==B ? 0. :
R>=G && R>=B ?
(B>G ? 6./6.-1./6.(B-G)/(R-G)
: 0./6.+1./6.
(G-B)/(R-B)) :
G>=R && G>=B ?
(R>B ? 2./6.-1./6.(R-B)/(G-B)
: 2./6.+1./6.
(B-R)/(G-R)) :
G>R ? 4./6.-1./6.(G-R)/(B-R)
: 4./6.+1./6.
(R-G)/(B-G) ; }