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

book_4_sparkGenerated
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 provide a position x where the color should be added, and a reference to a Color object. The method returns an integer indicating the index at which the color was added in the gradient's internal list.

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's color list where the color was added.