Adjust math for similar colors. (Fix #2532977)

Adjusts math for similar colors.

@jconniff
@davglass
@msweeney