Curve

package
v0.0.0-...-20ed0ac Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 19, 2025 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

This resource describes a mathematical curve by defining a set of points and tangents at each point. By default, it ranges between 0 and 1 on the X and Y axes, but these ranges can be changed.

Please note that many resources and nodes assume they are given unit curves. A unit curve is a curve whose domain (the X axis) is between 0 and 1. Some examples of unit curve usage are CPUParticles2D.AngleCurve and Line2D.WidthCurve.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsCurve() Instance
}

type Expanded

type Expanded = MoreArgs

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension

func (*Extension[T]) AsCurve

func (self *Extension[T]) AsCurve() Instance

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

func (*Extension[T]) AsRefCounted

func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted

func (*Extension[T]) AsResource

func (self *Extension[T]) AsResource() Resource.Instance

type ID

type ID Object.ID

ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

type Instance [1]gdclass.Curve

Instance of the class with convieniently typed arguments and results.

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AddPoint

func (self Instance) AddPoint(position Vector2.XY) int

Adds a point to the curve. For each side, if the *_mode is TangentLinear, the *_tangent angle (in degrees) uses the slope of the curve halfway to the adjacent point. Allows custom assignments to the *_tangent angle if *_mode is set to TangentFree.

func (Instance) AsCurve

func (self Instance) AsCurve() Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsRefCounted

func (self Instance) AsRefCounted() [1]gd.RefCounted

func (Instance) AsResource

func (self Instance) AsResource() Resource.Instance

func (Instance) Bake

func (self Instance) Bake()

Recomputes the baked cache of points for the curve.

func (Instance) BakeResolution

func (self Instance) BakeResolution() int

The number of points to include in the baked (i.e. cached) curve data.

func (Instance) CleanDupes

func (self Instance) CleanDupes()

Removes duplicate points, i.e. points that are less than 0.00001 units (engine epsilon value) away from their neighbor on the curve.

func (Instance) ClearPoints

func (self Instance) ClearPoints()

Removes all points from the curve.

func (Instance) GetDomainRange

func (self Instance) GetDomainRange() Float.X

Returns the difference between MinDomain and MaxDomain.

func (Instance) GetPointLeftMode

func (self Instance) GetPointLeftMode(index int) TangentMode

Returns the left TangentMode for the point at 'index'.

func (Instance) GetPointLeftTangent

func (self Instance) GetPointLeftTangent(index int) Float.X

Returns the left tangent angle (in degrees) for the point at 'index'.

func (Instance) GetPointPosition

func (self Instance) GetPointPosition(index int) Vector2.XY

Returns the curve coordinates for the point at 'index'.

func (Instance) GetPointRightMode

func (self Instance) GetPointRightMode(index int) TangentMode

Returns the right TangentMode for the point at 'index'.

func (Instance) GetPointRightTangent

func (self Instance) GetPointRightTangent(index int) Float.X

Returns the right tangent angle (in degrees) for the point at 'index'.

func (Instance) GetValueRange

func (self Instance) GetValueRange() Float.X

Returns the difference between MinValue and MaxValue.

func (Instance) ID

func (self Instance) ID() ID

func (Instance) MaxDomain

func (self Instance) MaxDomain() Float.X

The maximum domain (x-coordinate) that points can have.

func (Instance) MaxValue

func (self Instance) MaxValue() Float.X

The maximum value (y-coordinate) that points can have. Tangents can cause higher values between points.

func (Instance) MinDomain

func (self Instance) MinDomain() Float.X

The minimum domain (x-coordinate) that points can have.

func (Instance) MinValue

func (self Instance) MinValue() Float.X

The minimum value (y-coordinate) that points can have. Tangents can cause lower values between points.

func (Instance) MoreArgs

func (self Instance) MoreArgs() MoreArgs

MoreArgs enables certain functions to be called with additional 'optional' arguments.

func (Instance) OnDomainChanged

func (self Instance) OnDomainChanged(cb func(), flags ...Signal.Flags)

Emitted when MaxDomain or MinDomain is changed.

func (Instance) OnRangeChanged

func (self Instance) OnRangeChanged(cb func(), flags ...Signal.Flags)

Emitted when MaxValue or MinValue is changed.

func (Instance) PointCount

func (self Instance) PointCount() int

The number of points describing the curve.

func (Instance) RemovePoint

func (self Instance) RemovePoint(index int)

Removes the point at 'index' from the curve.

func (Instance) Sample

func (self Instance) Sample(offset Float.X) Float.X

Returns the Y value for the point that would exist at the X position 'offset' along the curve.

func (Instance) SampleBaked

func (self Instance) SampleBaked(offset Float.X) Float.X

Returns the Y value for the point that would exist at the X position 'offset' along the curve using the baked cache. Bakes the curve's points if not already baked.

func (Instance) SetBakeResolution

func (self Instance) SetBakeResolution(value int)

SetBakeResolution sets the property returned by [GetBakeResolution].

func (Instance) SetMaxDomain

func (self Instance) SetMaxDomain(value Float.X)

SetMaxDomain sets the property returned by [GetMaxDomain].

func (Instance) SetMaxValue

func (self Instance) SetMaxValue(value Float.X)

SetMaxValue sets the property returned by [GetMaxValue].

func (Instance) SetMinDomain

func (self Instance) SetMinDomain(value Float.X)

SetMinDomain sets the property returned by [GetMinDomain].

func (Instance) SetMinValue

func (self Instance) SetMinValue(value Float.X)

SetMinValue sets the property returned by [GetMinValue].

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) SetPointCount

func (self Instance) SetPointCount(value int)

SetPointCount sets the property returned by [GetPointCount].

func (Instance) SetPointLeftMode

func (self Instance) SetPointLeftMode(index int, mode TangentMode)

Sets the left TangentMode for the point at 'index' to 'mode'.

func (Instance) SetPointLeftTangent

func (self Instance) SetPointLeftTangent(index int, tangent Float.X)

Sets the left tangent angle for the point at 'index' to 'tangent'.

func (Instance) SetPointOffset

func (self Instance) SetPointOffset(index int, offset Float.X) int

Sets the offset from 0.5.

func (Instance) SetPointRightMode

func (self Instance) SetPointRightMode(index int, mode TangentMode)

Sets the right TangentMode for the point at 'index' to 'mode'.

func (Instance) SetPointRightTangent

func (self Instance) SetPointRightTangent(index int, tangent Float.X)

Sets the right tangent angle for the point at 'index' to 'tangent'.

func (Instance) SetPointValue

func (self Instance) SetPointValue(index int, y Float.X)

Assigns the vertical position 'y' to the point at 'index'.

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

type MoreArgs

type MoreArgs [1]gdclass.Curve

MoreArgs is a container for Instance functions with additional 'optional' arguments.

func (MoreArgs) AddPoint

func (self MoreArgs) AddPoint(position Vector2.XY, left_tangent Float.X, right_tangent Float.X, left_mode TangentMode, right_mode TangentMode) int

Adds a point to the curve. For each side, if the *_mode is TangentLinear, the *_tangent angle (in degrees) uses the slope of the curve halfway to the adjacent point. Allows custom assignments to the *_tangent angle if *_mode is set to TangentFree.

type TangentMode

type TangentMode int //gd:Curve.TangentMode
const (
	// The tangent on this side of the point is user-defined.
	TangentFree TangentMode = 0
	// The curve calculates the tangent on this side of the point as the slope halfway towards the adjacent point.
	TangentLinear TangentMode = 1
	// The total number of available tangent modes.
	TangentModeCount TangentMode = 2
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL