int AddColor( float x, Color& color )
int AddColor( Sandbox.Gradient/ColorFrame& keyframe )

robot_2Generated
code_blocksInput

Description

The AddColor method is used to add a color stop to a gradient at a specified position. This method modifies the gradient by inserting a new color at the given position, which is represented by a floating-point value. The color is passed by reference, allowing the method to modify the color if necessary.

Usage

To use the AddColor method, you need to have an instance of the Gradient struct. Call the method with the desired position and a reference to a Color object. The method will return an integer indicating the index at which the color was added.

Example

// Create a new Gradient instance
Gradient gradient = new Gradient();

// Define a color to add
Color colorToAdd = new Color(1.0f, 0.0f, 0.0f); // Red color

// Add the color to the gradient at position 0.5
int index = gradient.AddColor(0.5f, ref colorToAdd);

// The index variable now holds the position in the gradient where the color was added