refactor float_to_rgb into a cdef function