Index · Object → RefCounted → Resource → Curve

Curve

A mathematical curve.

Class Description

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.angle_curve and Line2D.width_curve.

Properties

var bake_resolution: int = 100

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

var max_domain: float = 1.0

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

var max_value: float = 1.0

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

var min_domain: float = 0.0

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

var min_value: float = 0.0

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

var point_count: int = 0

The number of points describing the curve.

var point_{index}/left_mode: int = 0

The left TangentMode for the point at index.

Note: index is a value in the 0 .. point_count - 1 range.

var point_{index}/left_tangent: float = 0.0

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

Note: index is a value in the 0 .. point_count - 1 range.

var point_{index}/position: Vector2 = Vector2(0, 0)

The position of the point at index.

Note: index is a value in the 0 .. point_count - 1 range.

var point_{index}/right_mode: int = 0

The right TangentMode for the point at index.

Note: index is a value in the 0 .. point_count - 1 range.

var point_{index}/right_tangent: float = 0.0

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

Note: index is a value in the 0 .. point_count - 1 range.

Inherited from Resource (4)

Methods

func add_point(position: Vector2, left_tangent: float = 0, right_tangent: float = 0, left_mode: Curve.TangentMode = 0, right_mode: Curve.TangentMode = 0) -> int

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.

func bake() -> void

Recomputes the baked cache of points for the curve.

func clean_dupes() -> void

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

func clear_points() -> void

Removes all points from the curve.

func get_domain_range() -> float

Returns the difference between min_domain and max_domain.

func get_point_left_mode(index: int) -> Curve.TangentMode

Returns the left TangentMode for the point at index.

func get_point_left_tangent(index: int) -> float

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

func get_point_position(index: int) -> Vector2

Returns the curve coordinates for the point at index.

func get_point_right_mode(index: int) -> Curve.TangentMode

Returns the right TangentMode for the point at index.

func get_point_right_tangent(index: int) -> float

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

func get_value_range() -> float

Returns the difference between min_value and max_value.

func remove_point(index: int) -> void

Removes the point at index from the curve.

func sample(offset: float) -> float

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

func sample_baked(offset: float) -> float

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 set_point_left_mode(index: int, mode: Curve.TangentMode) -> void

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

func set_point_left_tangent(index: int, tangent: float) -> void

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

func set_point_offset(index: int, offset: float) -> int

Assigns the horizontal position offset to the point at index.

func set_point_right_mode(index: int, mode: Curve.TangentMode) -> void

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

func set_point_right_tangent(index: int, tangent: float) -> void

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

func set_point_value(index: int, y: float) -> void

Assigns the vertical position y to the point at index.

Inherited from Resource (18)
func _get_rid() -> RID
func _reset_state() -> void
func _set_path_cache(path: String) -> void
func _setup_local_to_scene() -> void
func copy_from_resource(resource: Resource) -> Error
func duplicate(deep: bool = false) -> Resource
func duplicate_deep(deep_subresources_mode: Resource.DeepDuplicateMode = 1) -> Resource
func emit_changed() -> void
func get_rid() -> RID
func is_built_in() -> bool
func reset_state() -> void
func set_id_for_path(path: String, id: String) -> void
func set_path_cache(path: String) -> void
func setup_local_to_scene() -> void
func take_over_path(path: String) -> void
Inherited from RefCounted (4)
func init_ref() -> bool
func reference() -> bool
func unreference() -> bool
Inherited from Object (62)
func _get(property: StringName) -> Variant
func _get_property_list() -> Dictionary[]
func _init() -> void
func _iter_get(iter: Variant) -> Variant
func _iter_init(iter: Array) -> bool
func _iter_next(iter: Array) -> bool
func _notification(what: int) -> void
func _set(property: StringName, value: Variant) -> bool
func _to_string() -> String
func _validate_property(property: Dictionary) -> void
func add_user_signal(signal: String, arguments: Array = []) -> void
func call(method: StringName) -> Variant
func callv(method: StringName, arg_array: Array) -> Variant
func cancel_free() -> void
func connect(signal: StringName, callable: Callable, flags: int = 0) -> Error
func disconnect(signal: StringName, callable: Callable) -> void
func emit_signal(signal: StringName) -> Error
func free() -> void
func get(property: StringName) -> Variant
func get_class() -> String
func get_incoming_connections() -> Dictionary[]
func get_indexed(property_path: NodePath) -> Variant
func get_meta(name: StringName, default: Variant = null) -> Variant
func get_meta_list() -> StringName[]
func get_method_list() -> Dictionary[]
func get_property_list() -> Dictionary[]
func get_signal_connection_list(signal: StringName) -> Dictionary[]
func get_signal_list() -> Dictionary[]
func has_meta(name: StringName) -> bool
func has_method(method: StringName) -> bool
func has_signal(signal: StringName) -> bool
func is_class(class: StringName) -> bool
func is_connected(signal: StringName, callable: Callable) -> bool
func notification(what: int, reversed: bool = false) -> void
func remove_meta(name: StringName) -> void
func remove_user_signal(signal: StringName) -> void
func set(property: StringName, value: Variant) -> void
func set_block_signals(enable: bool) -> void
func set_deferred(property: StringName, value: Variant) -> void
func set_indexed(property_path: NodePath, value: Variant) -> void
func set_message_translation(enable: bool) -> void
func set_meta(name: StringName, value: Variant) -> void
func set_script(script: Variant) -> void
func set_translation_domain(domain: StringName) -> void
func to_string() -> String
func tr(message: StringName, context: StringName = &"") -> String
func tr_n(message: StringName, plural_message: StringName, n: int, context: StringName = &"") -> String

Signals

signal domain_changed()

Emitted when max_domain or min_domain is changed.

signal range_changed()

Emitted when max_value or min_value is changed.

Inherited from Resource (2)
signal changed()
Inherited from Object (2)

Enums & Constants

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.