Class ColorGradient
ENGINE LAYER - Generic color gradient interpolation system
Responsibilities:
- Interpolate between color stops based on normalized value (0.0 to 1.0)
- Support any number of color stops (minimum 2)
- Smooth transitions between stops
Architecture:
- Pure mechanism, no game knowledge
- Reusable across any map mode that needs gradient visualization
- Game layer defines color stops and provides values to normalize
Performance:
- O(1) evaluation with 2-5 color stops (typical usage)
- No allocations during gradient evaluation
- Color stops stored in managed array (small, infrequent access)
public class ColorGradient
- Inheritance
-
objectColorGradient
Constructors
ColorGradient(params Color32[])
Create a color gradient with specified color stops
public ColorGradient(params Color32[] stops)
Parameters
stopsColor32[]Color stops from low (0.0) to high (1.0). Minimum 2 required.
Properties
StopCount
Get the number of color stops in this gradient
public int StopCount { get; }
Property Value
- int
Methods
Evaluate(float)
Evaluate gradient at normalized value (0.0 to 1.0)
public Color32 Evaluate(float normalizedValue)
Parameters
normalizedValuefloatValue from 0.0 (first color stop) to 1.0 (last color stop)
Returns
- Color32
Interpolated color at the specified position
LightToDeepBlue()
Create a blue gradient (useful for water/naval related values)
public static ColorGradient LightToDeepBlue()
Returns
RedToYellow()
Create a common red-to-yellow gradient (useful for development/economy visualization)
public static ColorGradient RedToYellow()
Returns
WhiteToGreen()
Create a green gradient (useful for positive values like manpower)
public static ColorGradient WhiteToGreen()