Description
The LerpProperty
method is a virtual method in the BaseStyles
class within the Sandbox.UI
namespace. It is used to interpolate between two sets of style properties, from
and to
, based on a given delta
value. This method is particularly useful for creating smooth transitions between styles over time.
Usage
To use the LerpProperty
method, you need to provide the name of the property you want to interpolate, the starting style properties (from
), the ending style properties (to
), and a delta
value that represents the interpolation factor. The delta
should be a float between 0 and 1, where 0 represents the start state and 1 represents the end state.
Example
// Example usage of LerpProperty
BaseStyles currentStyles = new BaseStyles();
BaseStyles startStyles = new BaseStyles();
BaseStyles endStyles = new BaseStyles();
// Set some example properties
startStyles.Width = new Length(100, LengthUnit.Pixel);
endStyles.Width = new Length(200, LengthUnit.Pixel);
// Interpolate the 'Width' property from startStyles to endStyles
currentStyles.LerpProperty("Width", startStyles, endStyles, 0.5f);
// After this, currentStyles.Width should be 150px, halfway between start and end.