:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/Curve.xml. .. _class_Curve: Curve ===== **Inherits:** :ref:`Resource` **<** :ref:`Reference` **<** :ref:`Object` A mathematic curve. .. rst-class:: classref-introduction-group 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. See also :ref:`Gradient` which is designed for color interpolation. See also :ref:`Curve2D` and :ref:`Curve3D`. .. rst-class:: classref-reftable-group Properties ---------- .. table:: :widths: auto +---------------------------+--------------------------------------------------------------+---------+ | :ref:`int` | :ref:`bake_resolution` | ``100`` | +---------------------------+--------------------------------------------------------------+---------+ | :ref:`float` | :ref:`max_value` | ``1.0`` | +---------------------------+--------------------------------------------------------------+---------+ | :ref:`float` | :ref:`min_value` | ``0.0`` | +---------------------------+--------------------------------------------------------------+---------+ .. rst-class:: classref-reftable-group Methods ------- .. table:: :widths: auto +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`add_point` **(** :ref:`Vector2` position, :ref:`float` left_tangent=0, :ref:`float` right_tangent=0, :ref:`TangentMode` left_mode=0, :ref:`TangentMode` right_mode=0 **)** | +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`bake` **(** **)** | +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`clean_dupes` **(** **)** | +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`clear_points` **(** **)** | +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_point_count` **(** **)** |const| | +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`TangentMode` | :ref:`get_point_left_mode` **(** :ref:`int` index **)** |const| | +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`get_point_left_tangent` **(** :ref:`int` index **)** |const| | +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`get_point_position` **(** :ref:`int` index **)** |const| | +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`TangentMode` | :ref:`get_point_right_mode` **(** :ref:`int` index **)** |const| | +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`get_point_right_tangent` **(** :ref:`int` index **)** |const| | +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`interpolate` **(** :ref:`float` offset **)** |const| | +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`interpolate_baked` **(** :ref:`float` offset **)** | +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`remove_point` **(** :ref:`int` index **)** | +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_point_left_mode` **(** :ref:`int` index, :ref:`TangentMode` mode **)** | +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_point_left_tangent` **(** :ref:`int` index, :ref:`float` tangent **)** | +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`set_point_offset` **(** :ref:`int` index, :ref:`float` offset **)** | +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_point_right_mode` **(** :ref:`int` index, :ref:`TangentMode` mode **)** | +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_point_right_tangent` **(** :ref:`int` index, :ref:`float` tangent **)** | +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_point_value` **(** :ref:`int` index, :ref:`float` y **)** | +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Signals ------- .. _class_Curve_signal_range_changed: .. rst-class:: classref-signal **range_changed** **(** **)** Emitted when :ref:`max_value` or :ref:`min_value` is changed. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Enumerations ------------ .. _enum_Curve_TangentMode: .. rst-class:: classref-enumeration enum **TangentMode**: .. _class_Curve_constant_TANGENT_FREE: .. rst-class:: classref-enumeration-constant :ref:`TangentMode` **TANGENT_FREE** = ``0`` The tangent on this side of the point is user-defined. .. _class_Curve_constant_TANGENT_LINEAR: .. rst-class:: classref-enumeration-constant :ref:`TangentMode` **TANGENT_LINEAR** = ``1`` The curve calculates the tangent on this side of the point as the slope halfway towards the adjacent point. .. _class_Curve_constant_TANGENT_MODE_COUNT: .. rst-class:: classref-enumeration-constant :ref:`TangentMode` **TANGENT_MODE_COUNT** = ``2`` The total number of available tangent modes. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Property Descriptions --------------------- .. _class_Curve_property_bake_resolution: .. rst-class:: classref-property :ref:`int` **bake_resolution** = ``100`` .. rst-class:: classref-property-setget - void **set_bake_resolution** **(** :ref:`int` value **)** - :ref:`int` **get_bake_resolution** **(** **)** The number of points to include in the baked (i.e. cached) curve data. .. rst-class:: classref-item-separator ---- .. _class_Curve_property_max_value: .. rst-class:: classref-property :ref:`float` **max_value** = ``1.0`` .. rst-class:: classref-property-setget - void **set_max_value** **(** :ref:`float` value **)** - :ref:`float` **get_max_value** **(** **)** The maximum value the curve can reach. .. rst-class:: classref-item-separator ---- .. _class_Curve_property_min_value: .. rst-class:: classref-property :ref:`float` **min_value** = ``0.0`` .. rst-class:: classref-property-setget - void **set_min_value** **(** :ref:`float` value **)** - :ref:`float` **get_min_value** **(** **)** The minimum value the curve can reach. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Method Descriptions ------------------- .. _class_Curve_method_add_point: .. rst-class:: classref-method :ref:`int` **add_point** **(** :ref:`Vector2` position, :ref:`float` left_tangent=0, :ref:`float` right_tangent=0, :ref:`TangentMode` left_mode=0, :ref:`TangentMode` right_mode=0 **)** Adds a point to the curve. For each side, if the ``*_mode`` is :ref:`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 :ref:`TANGENT_FREE`. .. rst-class:: classref-item-separator ---- .. _class_Curve_method_bake: .. rst-class:: classref-method void **bake** **(** **)** Recomputes the baked cache of points for the curve. .. rst-class:: classref-item-separator ---- .. _class_Curve_method_clean_dupes: .. rst-class:: classref-method void **clean_dupes** **(** **)** Removes points that are closer than ``CMP_EPSILON`` (0.00001) units to their neighbor on the curve. .. rst-class:: classref-item-separator ---- .. _class_Curve_method_clear_points: .. rst-class:: classref-method void **clear_points** **(** **)** Removes all points from the curve. .. rst-class:: classref-item-separator ---- .. _class_Curve_method_get_point_count: .. rst-class:: classref-method :ref:`int` **get_point_count** **(** **)** |const| Returns the number of points describing the curve. .. rst-class:: classref-item-separator ---- .. _class_Curve_method_get_point_left_mode: .. rst-class:: classref-method :ref:`TangentMode` **get_point_left_mode** **(** :ref:`int` index **)** |const| Returns the left :ref:`TangentMode` for the point at ``index``. .. rst-class:: classref-item-separator ---- .. _class_Curve_method_get_point_left_tangent: .. rst-class:: classref-method :ref:`float` **get_point_left_tangent** **(** :ref:`int` index **)** |const| Returns the left tangent angle (in degrees) for the point at ``index``. .. rst-class:: classref-item-separator ---- .. _class_Curve_method_get_point_position: .. rst-class:: classref-method :ref:`Vector2` **get_point_position** **(** :ref:`int` index **)** |const| Returns the curve coordinates for the point at ``index``. .. rst-class:: classref-item-separator ---- .. _class_Curve_method_get_point_right_mode: .. rst-class:: classref-method :ref:`TangentMode` **get_point_right_mode** **(** :ref:`int` index **)** |const| Returns the right :ref:`TangentMode` for the point at ``index``. .. rst-class:: classref-item-separator ---- .. _class_Curve_method_get_point_right_tangent: .. rst-class:: classref-method :ref:`float` **get_point_right_tangent** **(** :ref:`int` index **)** |const| Returns the right tangent angle (in degrees) for the point at ``index``. .. rst-class:: classref-item-separator ---- .. _class_Curve_method_interpolate: .. rst-class:: classref-method :ref:`float` **interpolate** **(** :ref:`float` offset **)** |const| Returns the Y value for the point that would exist at the X position ``offset`` along the curve. .. rst-class:: classref-item-separator ---- .. _class_Curve_method_interpolate_baked: .. rst-class:: classref-method :ref:`float` **interpolate_baked** **(** :ref:`float` offset **)** 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. .. rst-class:: classref-item-separator ---- .. _class_Curve_method_remove_point: .. rst-class:: classref-method void **remove_point** **(** :ref:`int` index **)** Removes the point at ``index`` from the curve. .. rst-class:: classref-item-separator ---- .. _class_Curve_method_set_point_left_mode: .. rst-class:: classref-method void **set_point_left_mode** **(** :ref:`int` index, :ref:`TangentMode` mode **)** Sets the left :ref:`TangentMode` for the point at ``index`` to ``mode``. .. rst-class:: classref-item-separator ---- .. _class_Curve_method_set_point_left_tangent: .. rst-class:: classref-method void **set_point_left_tangent** **(** :ref:`int` index, :ref:`float` tangent **)** Sets the left tangent angle for the point at ``index`` to ``tangent``. .. rst-class:: classref-item-separator ---- .. _class_Curve_method_set_point_offset: .. rst-class:: classref-method :ref:`int` **set_point_offset** **(** :ref:`int` index, :ref:`float` offset **)** Sets the offset from ``0.5``. .. rst-class:: classref-item-separator ---- .. _class_Curve_method_set_point_right_mode: .. rst-class:: classref-method void **set_point_right_mode** **(** :ref:`int` index, :ref:`TangentMode` mode **)** Sets the right :ref:`TangentMode` for the point at ``index`` to ``mode``. .. rst-class:: classref-item-separator ---- .. _class_Curve_method_set_point_right_tangent: .. rst-class:: classref-method void **set_point_right_tangent** **(** :ref:`int` index, :ref:`float` tangent **)** Sets the right tangent angle for the point at ``index`` to ``tangent``. .. rst-class:: classref-item-separator ---- .. _class_Curve_method_set_point_value: .. rst-class:: classref-method void **set_point_value** **(** :ref:`int` index, :ref:`float` y **)** Assigns the vertical position ``y`` to the point at ``index``. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`