Skip to content

LinearGradientStyle

ClassChartGuruChartGuru
public sealed class LinearGradientStyle

Reusable linear gradient definition with cached sampling data for allocation-free repeated rendering.

public void InvalidateCache()

Marks cached validity as dirty. Call after externally mutating ChartGuru.LinearGradientStyle.Gradient keys (Unity’s Gradient does not raise change events).

public LinearGradientStyle Clone()

Creates an independent copy of this Linear Gradient Style; later configuration changes do not affect the original instance.

Returns

ChartGuru.LinearGradientStyle

public Color Evaluate(Vector2 normalizedPosition)

Samples the gradient color at a normalized position from zero to one.

Parameters

Name Type
normalizedPosition UnityEngine.Vector2

Returns

UnityEngine.Color

Evaluate(Gradient, UnitPoint, UnitPoint, Vector2)

Section titled “Evaluate(Gradient, UnitPoint, UnitPoint, Vector2)”
public static Color Evaluate(Gradient gradient, UnitPoint startPoint, UnitPoint endPoint, Vector2 normalizedPosition)

Allocation-free evaluation that does not require constructing a ChartGuru.LinearGradientStyle. Use from per-vertex render paths that only carry a raw ChartGuru.LinearGradientStyle.Gradient + start/end points.

Parameters

Name Type
gradient UnityEngine.Gradient
startPoint ChartGuru.UnitPoint
endPoint ChartGuru.UnitPoint
normalizedPosition UnityEngine.Vector2

Returns

UnityEngine.Color

public void ApplyPreset(LinearGradientPreset preset)

Applies preset to the target chart while preserving unrelated data and presentation settings.

Parameters

Name Type
preset ChartGuru.LinearGradientPreset

CreatePreset(LinearGradientPreset, UnitPoint, UnitPoint)

Section titled “CreatePreset(LinearGradientPreset, UnitPoint, UnitPoint)”
public static LinearGradientStyle CreatePreset(LinearGradientPreset preset, UnitPoint startPoint = UnitPoint.BottomLeading, UnitPoint endPoint = UnitPoint.TopTrailing)

Creates a reusable linear-gradient style from a built-in color preset and explicit direction endpoints.

Parameters

Name Type
preset ChartGuru.LinearGradientPreset
startPoint ChartGuru.UnitPoint
endPoint ChartGuru.UnitPoint

Returns

ChartGuru.LinearGradientStyle

public static LinearGradientStyle FromColors(Color[] colors, UnitPoint startPoint = UnitPoint.Bottom, UnitPoint endPoint = UnitPoint.Top)

Creates an evenly spaced linear gradient from the supplied color sequence.

Parameters

Name Type
colors UnityEngine.Color[]
startPoint ChartGuru.UnitPoint
endPoint ChartGuru.UnitPoint

Returns

ChartGuru.LinearGradientStyle

FromColorsWithStops(Color[], float[], UnitPoint, UnitPoint)

Section titled “FromColorsWithStops(Color[], float[], UnitPoint, UnitPoint)”
public static LinearGradientStyle FromColorsWithStops(Color[] colors, float[] stops, UnitPoint startPoint = UnitPoint.Bottom, UnitPoint endPoint = UnitPoint.Top)

Creates a LinearGradientStyle from colors at explicit stop positions. Swift Charts equivalent: Gradient(stops: [.init(color: .red, location: 0.0), …])

Parameters

Name Type
colors UnityEngine.Color[]
stops System.Single[]
startPoint ChartGuru.UnitPoint
endPoint ChartGuru.UnitPoint

Returns

ChartGuru.LinearGradientStyle

FromStops(GradientStop[], UnitPoint, UnitPoint)

Section titled “FromStops(GradientStop[], UnitPoint, UnitPoint)”
public static LinearGradientStyle FromStops(GradientStop[] stops, UnitPoint startPoint = UnitPoint.Bottom, UnitPoint endPoint = UnitPoint.Top)

Creates a LinearGradientStyle from an array of ChartGuru.GradientStop values, each carrying its own color and position. Swift Charts equivalent: .linearGradient(stops: [Gradient.Stop(color: .green, location: 0), …], startPoint: .bottom, endPoint: .top).

Parameters

Name Type
stops ChartGuru.GradientStop[]
startPoint ChartGuru.UnitPoint
endPoint ChartGuru.UnitPoint

Returns

ChartGuru.LinearGradientStyle

public static Gradient CloneGradient(Gradient source)

Creates an independent copy of the supplied Unity gradient and its color and alpha keys.

Parameters

Name Type
source UnityEngine.Gradient

Returns

UnityEngine.Gradient

CreatePresetGradient(LinearGradientPreset)

Section titled “CreatePresetGradient(LinearGradientPreset)”
public static Gradient CreatePresetGradient(LinearGradientPreset preset)

Creates a new Unity gradient containing the color and alpha keys defined by the selected built-in preset.

Parameters

Name Type
preset ChartGuru.LinearGradientPreset

Returns

UnityEngine.Gradient

public static Vector2 ToVector2(UnitPoint point)

Converts the gradient unit point to normalized two-dimensional coordinates.

Parameters

Name Type
point ChartGuru.UnitPoint

Returns

UnityEngine.Vector2

public LinearGradientStyle()

public Gradient Gradient { get; set; }

Returns

UnityEngine.Gradient

public UnitPoint StartPoint { get; set; }

Returns

ChartGuru.UnitPoint

public UnitPoint EndPoint { get; set; }

Returns

ChartGuru.UnitPoint

public bool IsValid { get; }

Returns

System.Boolean