def hsv2rgb_rainbow(hsv):
def nscale8x3_video(r, g, b, scale):<EOL><INDENT>nonzeroscale = <NUM_LIT:0><EOL>if scale != <NUM_LIT:0>:<EOL><INDENT>nonzeroscale = <NUM_LIT:1><EOL><DEDENT>if r != <NUM_LIT:0>:<EOL><INDENT>r = ((r * scale) >> <NUM_LIT:8>) + nonzeroscale<EOL><DEDENT>if g != <NUM_LIT:0>:<EOL><INDENT>g = ((g * scale) >> <NUM_LIT:8>) + nonzeroscale<EOL><DEDENT>if b != <NUM_LIT:0>:<EOL><INDENT>b = ((b * scale) >> <NUM_LIT:8>) + nonzeroscale<EOL><DEDENT>return (r, g, b)<EOL><DEDENT>def scale8_video_LEAVING_R1_DIRTY(i, scale):<EOL><INDENT>nonzeroscale = <NUM_LIT:0><EOL>if scale != <NUM_LIT:0>:<EOL><INDENT>nonzeroscale = <NUM_LIT:1><EOL><DEDENT>if i != <NUM_LIT:0>:<EOL><INDENT>i = ((i * scale) >> <NUM_LIT:8>) + nonzeroscale<EOL><DEDENT>return i<EOL><DEDENT>h, s, v = hsv<EOL>offset = h & <NUM_LIT>  <EOL>offset8 = offset * <NUM_LIT:8><EOL>third = (offset8 * (<NUM_LIT> // <NUM_LIT:3>)) >> <NUM_LIT:8><EOL>r, g, b = (<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>)<EOL>if not (h & <NUM_LIT>):<EOL><INDENT>if not (h & <NUM_LIT>):<EOL><INDENT>if not (h & <NUM_LIT>):<EOL><INDENT>r = <NUM_LIT:255> - third<EOL>g = third<EOL>b = <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>r = <NUM_LIT><EOL>g = <NUM_LIT> + third<EOL>b = <NUM_LIT><EOL><DEDENT><DEDENT>else:<EOL><INDENT>if not (h & <NUM_LIT>):<EOL><INDENT>twothirds = (third << <NUM_LIT:1>)<EOL>r = <NUM_LIT> - twothirds<EOL>g = <NUM_LIT> + third<EOL>b = <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>r = <NUM_LIT:0><EOL>g = <NUM_LIT:255> - third<EOL>b = third<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>if not (h & <NUM_LIT>):<EOL><INDENT>if not (h & <NUM_LIT>):<EOL><INDENT>r = <NUM_LIT><EOL>twothirds = (third << <NUM_LIT:1>)<EOL>g = <NUM_LIT> - twothirds<EOL>b = <NUM_LIT> + twothirds<EOL><DEDENT>else:<EOL><INDENT>r = third<EOL>g = <NUM_LIT:0><EOL>b = <NUM_LIT:255> - third<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if not (h & <NUM_LIT>):<EOL><INDENT>r = <NUM_LIT> + third<EOL>g = <NUM_LIT:0><EOL>b = <NUM_LIT> - third<EOL><DEDENT>else:<EOL><INDENT>r = <NUM_LIT> + third<EOL>g = <NUM_LIT><EOL>b = <NUM_LIT> - third<EOL><DEDENT><DEDENT><DEDENT>if s != <NUM_LIT:255>:<EOL><INDENT>r, g, b = nscale8x3_video(r, g, b, s)<EOL>desat = <NUM_LIT:255> - s<EOL>desat = (desat * desat) >> <NUM_LIT:8><EOL>brightness_floor = desat<EOL>r = r + brightness_floor<EOL>g = g + brightness_floor<EOL>b = b + brightness_floor<EOL><DEDENT>if v != <NUM_LIT:255>:<EOL><INDENT>v = scale8_video_LEAVING_R1_DIRTY(v, v)<EOL>r, g, b = nscale8x3_video(r, g, b, v)<EOL><DEDENT>return (r, g, b)<EOL>
Generates RGB values from HSV that have an even visual
    distribution.  Be careful as this method is only have as fast as
    hsv2rgb_spectrum.