rewrote color calculation functions using the new stuff in the math library