MixWith

const Rgba &otherColor, float factor ) const;

Returns a mixed color between this and otherColor using the given factor.

The factor should be between 0.0 and 1.0. If factor is zero, InterpolateWith returns the calling color and if factor is 1.0 it returns the given otherColor. But if the factor is between 0.0 and 1.0 it returns a mix of the two colors.

The lower the factor, the closer the returned color is to the calling color and higher the factor, the closer the returned color is to the given otherColor.

The old name of this function is InterpolateWith, which can still be used as well.

Examples

// Get a color half way between red and blue //
Rgba magneta = Rgba::RED.InterpolateWith( Rgba::BLUE, 0.5 );

// Get a slightly darker blue color //
Rgba darkerBlue = Rgba::BLUE.InterpolateWith( Rgba::BLACK, 0.2 );

// Get a mixed color between magneta and darkerBlue which is slightly closer to darkerBlue than magneta //
Rgba mixedColor = magneta.InterpolateWith( darkerBlue, 0.6 );


Other functions of the class Rgba
MixWith
Mixes two colors together with the given factor
WithAlpha
Creates a new color with the same color components but a different alpha value

Advanced functions

Packed
Returns the color packed in an integer
Select
Selects the color as the active OpenGL color


Questions about MixWith? Click here.