30 lines
642 B
C#
30 lines
642 B
C#
|
|
using Godot;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
|
||
|
|
namespace Rokojori
|
||
|
|
{
|
||
|
|
public static class CurveExtensions
|
||
|
|
{
|
||
|
|
public static Curve WithPoints( this Curve curve, params Vector2[] points )
|
||
|
|
{
|
||
|
|
curve.ClearPoints();
|
||
|
|
|
||
|
|
points.ForEach( p => curve.AddPoint( p ) );
|
||
|
|
|
||
|
|
return curve;
|
||
|
|
}
|
||
|
|
|
||
|
|
public static Curve WithValues( this Curve curve, params float[] values )
|
||
|
|
{
|
||
|
|
curve.ClearPoints();
|
||
|
|
|
||
|
|
for ( int i = 0; i < values.Length; i++ )
|
||
|
|
{
|
||
|
|
float x = i / (float) ( values.Length - 1f );
|
||
|
|
curve.AddPoint( new Vector2( x, values[ i ] ) );
|
||
|
|
}
|
||
|
|
|
||
|
|
return curve;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|