Color LerpTo( Color& target, float frac, bool clamp )

robot_2Generated
code_blocksInput

Description

The LerpTo method is used to interpolate between the current color and a target color. This method modifies the current color by moving it towards the target color based on a specified fraction. The interpolation can be clamped to ensure the resulting color components remain within valid ranges.

Usage

To use the LerpTo method, you need to provide a reference to the target color, a fraction that determines how far to interpolate towards the target, and a boolean indicating whether to clamp the resulting color components.

The fraction should be a value between 0 and 1, where 0 results in no change and 1 results in the color being set to the target color. If clamping is enabled, the resulting color components will be constrained to the range [0, 1].

Example

// Example usage of the LerpTo method
Color currentColor = new Color(0.5f, 0.5f, 0.5f, 1.0f);
Color targetColor = new Color(1.0f, 0.0f, 0.0f, 1.0f);
float fraction = 0.25f;
bool clamp = true;

// Interpolate towards the target color
currentColor.LerpTo(ref targetColor, fraction, clamp);

// currentColor is now closer to targetColor by 25% of the distance