using Godot; using System.Collections.Generic; namespace Rokojori { [Tool] [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Flash.svg") ] public partial class TemperatureGradient:GradientGenerator { [Export] public Color baseColor; [Export( PropertyHint.Range, "0,1" )] public float centerPosition = 0.5f; [Export( PropertyHint.Range, "0,1" )] public float centerAttraction = 0.25f; [Export] public float temperaturePolarBlendRadius = 60f; [ExportGroup( "Start", "start")] [Export( PropertyHint.Range, "-180,180")] public float startTemperatureShift = 0; [Export( PropertyHint.Range, "-100,100")] public float startSaturationShift = 0; [Export( PropertyHint.Range, "-100,100")] public float startLightnessShift = 0; [ExportGroup( "End", "end")] [Export( PropertyHint.Range, "-180,180")] public float endTemperatureShift = 0; [Export( PropertyHint.Range, "-100,100")] public float endSaturationShift = 0; [Export( PropertyHint.Range, "-100,100")] public float endLightnessShift = 0; [ExportGroup("Output")] [ExportToolButton( "Show Output")] public Callable showOutputButton => Callable.From( ()=> outputGradient = GetGradient() ); [Export] public Gradient outputGradient; [ExportGroup("Repeat")] [Export] public float repeat = 1f; [Export] public GradientExtensions.GradientRepeatMode repeatMode = GradientExtensions.GradientRepeatMode.Clamp; public override Gradient GetGradient() { var gradient = new Gradient(); gradient.Colors = [ baseColor.ToHSL().ShiftTemperature( startTemperatureShift, startSaturationShift / 100f, startLightnessShift / 100f, temperaturePolarBlendRadius ), baseColor, baseColor.ToHSL().ShiftTemperature( endTemperatureShift, endSaturationShift / 100f, endLightnessShift / 100f, temperaturePolarBlendRadius ), ]; gradient.Offsets = [ Mathf.Lerp( 0f, centerPosition, centerAttraction ), centerPosition, Mathf.Lerp( 1f, centerPosition, centerAttraction ), ]; return gradient; } } }