Curve

Inherits: Resource < Reference < Object

A mathematic curve.

Description

A curve that can be saved and re-used for other objects. By default, it ranges between 0 and 1 on the Y axis and positions points relative to the 0.5 Y position.

Properties

intbake_resolution100
floatmax_value1.0
floatmin_value0.0

Methods

intadd_point ( Vector2 position, float left_tangent=0, float right_tangent=0, TangentMode left_mode=0, TangentMode right_mode=0 )
voidbake ( )
voidclean_dupes ( )
voidclear_points ( )
intget_point_count ( ) const
TangentModeget_point_left_mode ( int index ) const
floatget_point_left_tangent ( int index ) const
Vector2get_point_position ( int index ) const
TangentModeget_point_right_mode ( int index ) const
floatget_point_right_tangent ( int index ) const
floatinterpolate ( float offset ) const
floatinterpolate_baked ( float offset )
voidremove_point ( int index )
voidset_point_left_mode ( int index, TangentMode mode )
voidset_point_left_tangent ( int index, float tangent )
intset_point_offset ( int index, float offset )
voidset_point_right_mode ( int index, TangentMode mode )
voidset_point_right_tangent ( int index, float tangent )
voidset_point_value ( int index, float y )

Signals

  • range_changed ( )

Emitted when max_value or min_value is changed.

Enumerations

enum TangentMode:

  • TANGENT_FREE = 0 —- The tangent on this side of the point is user-defined.
  • TANGENT_LINEAR = 1 —- The curve calculates the tangent on this side of the point as the slope halfway towards the adjacent point.
  • TANGENT_MODE_COUNT = 2 —- The total number of available tangent modes.

Property Descriptions

  • int bake_resolution
Default100
Setterset_bake_resolution(value)
Getterget_bake_resolution()

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


Default1.0
Setterset_max_value(value)
Getterget_max_value()

The maximum value the curve can reach.


Default0.0
Setterset_min_value(value)
Getterget_min_value()

The minimum value the curve can reach.

Method Descriptions

Adds a point to the curve. For each side, if the *_mode is TANGENT_LINEAR, 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 TANGENT_FREE.


  • void bake ( )

Recomputes the baked cache of points for the curve.


  • void clean_dupes ( )

Removes points that are closer than CMP_EPSILON (0.00001) units to their neighbor on the curve.


  • void clear_points ( )

Removes all points from the curve.


  • int get_point_count ( ) const

Returns the number of points describing the curve.


Returns the left TangentMode for the point at index.


  • float get_point_left_tangent ( int index ) const

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


Returns the curve coordinates for the point at index.


Returns the right TangentMode for the point at index.


  • float get_point_right_tangent ( int index ) const

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


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


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.


  • void remove_point ( int index )

Removes the point at index from the curve.


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


  • void set_point_left_tangent ( int index, float tangent )

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


Sets the offset from 0.5.


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


  • void set_point_right_tangent ( int index, float tangent )

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


  • void set_point_value ( int index, float y )

Assigns the vertical position y to the point at index.