class_curve.rst 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/Curve.xml.
  6. .. _class_Curve:
  7. Curve
  8. =====
  9. **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. A mathematical curve.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. 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 Y axis and positions points relative to the ``0.5`` Y position.
  15. See also :ref:`Gradient<class_Gradient>` which is designed for color interpolation. See also :ref:`Curve2D<class_Curve2D>` and :ref:`Curve3D<class_Curve3D>`.
  16. .. rst-class:: classref-reftable-group
  17. Properties
  18. ----------
  19. .. table::
  20. :widths: auto
  21. +---------------------------+--------------------------------------------------------------+---------+
  22. | :ref:`int<class_int>` | :ref:`bake_resolution<class_Curve_property_bake_resolution>` | ``100`` |
  23. +---------------------------+--------------------------------------------------------------+---------+
  24. | :ref:`float<class_float>` | :ref:`max_value<class_Curve_property_max_value>` | ``1.0`` |
  25. +---------------------------+--------------------------------------------------------------+---------+
  26. | :ref:`float<class_float>` | :ref:`min_value<class_Curve_property_min_value>` | ``0.0`` |
  27. +---------------------------+--------------------------------------------------------------+---------+
  28. | :ref:`int<class_int>` | :ref:`point_count<class_Curve_property_point_count>` | ``0`` |
  29. +---------------------------+--------------------------------------------------------------+---------+
  30. .. rst-class:: classref-reftable-group
  31. Methods
  32. -------
  33. .. table::
  34. :widths: auto
  35. +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`int<class_int>` | :ref:`add_point<class_Curve_method_add_point>`\ (\ position\: :ref:`Vector2<class_Vector2>`, left_tangent\: :ref:`float<class_float>` = 0, right_tangent\: :ref:`float<class_float>` = 0, left_mode\: :ref:`TangentMode<enum_Curve_TangentMode>` = 0, right_mode\: :ref:`TangentMode<enum_Curve_TangentMode>` = 0\ ) |
  37. +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | |void| | :ref:`bake<class_Curve_method_bake>`\ (\ ) |
  39. +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | |void| | :ref:`clean_dupes<class_Curve_method_clean_dupes>`\ (\ ) |
  41. +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | |void| | :ref:`clear_points<class_Curve_method_clear_points>`\ (\ ) |
  43. +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`TangentMode<enum_Curve_TangentMode>` | :ref:`get_point_left_mode<class_Curve_method_get_point_left_mode>`\ (\ index\: :ref:`int<class_int>`\ ) |const| |
  45. +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`float<class_float>` | :ref:`get_point_left_tangent<class_Curve_method_get_point_left_tangent>`\ (\ index\: :ref:`int<class_int>`\ ) |const| |
  47. +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`Vector2<class_Vector2>` | :ref:`get_point_position<class_Curve_method_get_point_position>`\ (\ index\: :ref:`int<class_int>`\ ) |const| |
  49. +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`TangentMode<enum_Curve_TangentMode>` | :ref:`get_point_right_mode<class_Curve_method_get_point_right_mode>`\ (\ index\: :ref:`int<class_int>`\ ) |const| |
  51. +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`float<class_float>` | :ref:`get_point_right_tangent<class_Curve_method_get_point_right_tangent>`\ (\ index\: :ref:`int<class_int>`\ ) |const| |
  53. +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | |void| | :ref:`remove_point<class_Curve_method_remove_point>`\ (\ index\: :ref:`int<class_int>`\ ) |
  55. +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`float<class_float>` | :ref:`sample<class_Curve_method_sample>`\ (\ offset\: :ref:`float<class_float>`\ ) |const| |
  57. +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`float<class_float>` | :ref:`sample_baked<class_Curve_method_sample_baked>`\ (\ offset\: :ref:`float<class_float>`\ ) |const| |
  59. +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | |void| | :ref:`set_point_left_mode<class_Curve_method_set_point_left_mode>`\ (\ index\: :ref:`int<class_int>`, mode\: :ref:`TangentMode<enum_Curve_TangentMode>`\ ) |
  61. +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | |void| | :ref:`set_point_left_tangent<class_Curve_method_set_point_left_tangent>`\ (\ index\: :ref:`int<class_int>`, tangent\: :ref:`float<class_float>`\ ) |
  63. +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | :ref:`int<class_int>` | :ref:`set_point_offset<class_Curve_method_set_point_offset>`\ (\ index\: :ref:`int<class_int>`, offset\: :ref:`float<class_float>`\ ) |
  65. +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | |void| | :ref:`set_point_right_mode<class_Curve_method_set_point_right_mode>`\ (\ index\: :ref:`int<class_int>`, mode\: :ref:`TangentMode<enum_Curve_TangentMode>`\ ) |
  67. +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | |void| | :ref:`set_point_right_tangent<class_Curve_method_set_point_right_tangent>`\ (\ index\: :ref:`int<class_int>`, tangent\: :ref:`float<class_float>`\ ) |
  69. +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | |void| | :ref:`set_point_value<class_Curve_method_set_point_value>`\ (\ index\: :ref:`int<class_int>`, y\: :ref:`float<class_float>`\ ) |
  71. +--------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. .. rst-class:: classref-section-separator
  73. ----
  74. .. rst-class:: classref-descriptions-group
  75. Signals
  76. -------
  77. .. _class_Curve_signal_range_changed:
  78. .. rst-class:: classref-signal
  79. **range_changed**\ (\ ) :ref:`🔗<class_Curve_signal_range_changed>`
  80. Emitted when :ref:`max_value<class_Curve_property_max_value>` or :ref:`min_value<class_Curve_property_min_value>` is changed.
  81. .. rst-class:: classref-section-separator
  82. ----
  83. .. rst-class:: classref-descriptions-group
  84. Enumerations
  85. ------------
  86. .. _enum_Curve_TangentMode:
  87. .. rst-class:: classref-enumeration
  88. enum **TangentMode**: :ref:`🔗<enum_Curve_TangentMode>`
  89. .. _class_Curve_constant_TANGENT_FREE:
  90. .. rst-class:: classref-enumeration-constant
  91. :ref:`TangentMode<enum_Curve_TangentMode>` **TANGENT_FREE** = ``0``
  92. The tangent on this side of the point is user-defined.
  93. .. _class_Curve_constant_TANGENT_LINEAR:
  94. .. rst-class:: classref-enumeration-constant
  95. :ref:`TangentMode<enum_Curve_TangentMode>` **TANGENT_LINEAR** = ``1``
  96. The curve calculates the tangent on this side of the point as the slope halfway towards the adjacent point.
  97. .. _class_Curve_constant_TANGENT_MODE_COUNT:
  98. .. rst-class:: classref-enumeration-constant
  99. :ref:`TangentMode<enum_Curve_TangentMode>` **TANGENT_MODE_COUNT** = ``2``
  100. The total number of available tangent modes.
  101. .. rst-class:: classref-section-separator
  102. ----
  103. .. rst-class:: classref-descriptions-group
  104. Property Descriptions
  105. ---------------------
  106. .. _class_Curve_property_bake_resolution:
  107. .. rst-class:: classref-property
  108. :ref:`int<class_int>` **bake_resolution** = ``100`` :ref:`🔗<class_Curve_property_bake_resolution>`
  109. .. rst-class:: classref-property-setget
  110. - |void| **set_bake_resolution**\ (\ value\: :ref:`int<class_int>`\ )
  111. - :ref:`int<class_int>` **get_bake_resolution**\ (\ )
  112. The number of points to include in the baked (i.e. cached) curve data.
  113. .. rst-class:: classref-item-separator
  114. ----
  115. .. _class_Curve_property_max_value:
  116. .. rst-class:: classref-property
  117. :ref:`float<class_float>` **max_value** = ``1.0`` :ref:`🔗<class_Curve_property_max_value>`
  118. .. rst-class:: classref-property-setget
  119. - |void| **set_max_value**\ (\ value\: :ref:`float<class_float>`\ )
  120. - :ref:`float<class_float>` **get_max_value**\ (\ )
  121. The maximum value the curve can reach.
  122. .. rst-class:: classref-item-separator
  123. ----
  124. .. _class_Curve_property_min_value:
  125. .. rst-class:: classref-property
  126. :ref:`float<class_float>` **min_value** = ``0.0`` :ref:`🔗<class_Curve_property_min_value>`
  127. .. rst-class:: classref-property-setget
  128. - |void| **set_min_value**\ (\ value\: :ref:`float<class_float>`\ )
  129. - :ref:`float<class_float>` **get_min_value**\ (\ )
  130. The minimum value the curve can reach.
  131. .. rst-class:: classref-item-separator
  132. ----
  133. .. _class_Curve_property_point_count:
  134. .. rst-class:: classref-property
  135. :ref:`int<class_int>` **point_count** = ``0`` :ref:`🔗<class_Curve_property_point_count>`
  136. .. rst-class:: classref-property-setget
  137. - |void| **set_point_count**\ (\ value\: :ref:`int<class_int>`\ )
  138. - :ref:`int<class_int>` **get_point_count**\ (\ )
  139. The number of points describing the curve.
  140. .. rst-class:: classref-section-separator
  141. ----
  142. .. rst-class:: classref-descriptions-group
  143. Method Descriptions
  144. -------------------
  145. .. _class_Curve_method_add_point:
  146. .. rst-class:: classref-method
  147. :ref:`int<class_int>` **add_point**\ (\ position\: :ref:`Vector2<class_Vector2>`, left_tangent\: :ref:`float<class_float>` = 0, right_tangent\: :ref:`float<class_float>` = 0, left_mode\: :ref:`TangentMode<enum_Curve_TangentMode>` = 0, right_mode\: :ref:`TangentMode<enum_Curve_TangentMode>` = 0\ ) :ref:`🔗<class_Curve_method_add_point>`
  148. Adds a point to the curve. For each side, if the ``*_mode`` is :ref:`TANGENT_LINEAR<class_Curve_constant_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<class_Curve_constant_TANGENT_FREE>`.
  149. .. rst-class:: classref-item-separator
  150. ----
  151. .. _class_Curve_method_bake:
  152. .. rst-class:: classref-method
  153. |void| **bake**\ (\ ) :ref:`🔗<class_Curve_method_bake>`
  154. Recomputes the baked cache of points for the curve.
  155. .. rst-class:: classref-item-separator
  156. ----
  157. .. _class_Curve_method_clean_dupes:
  158. .. rst-class:: classref-method
  159. |void| **clean_dupes**\ (\ ) :ref:`🔗<class_Curve_method_clean_dupes>`
  160. Removes duplicate points, i.e. points that are less than 0.00001 units (engine epsilon value) away from their neighbor on the curve.
  161. .. rst-class:: classref-item-separator
  162. ----
  163. .. _class_Curve_method_clear_points:
  164. .. rst-class:: classref-method
  165. |void| **clear_points**\ (\ ) :ref:`🔗<class_Curve_method_clear_points>`
  166. Removes all points from the curve.
  167. .. rst-class:: classref-item-separator
  168. ----
  169. .. _class_Curve_method_get_point_left_mode:
  170. .. rst-class:: classref-method
  171. :ref:`TangentMode<enum_Curve_TangentMode>` **get_point_left_mode**\ (\ index\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_Curve_method_get_point_left_mode>`
  172. Returns the left :ref:`TangentMode<enum_Curve_TangentMode>` for the point at ``index``.
  173. .. rst-class:: classref-item-separator
  174. ----
  175. .. _class_Curve_method_get_point_left_tangent:
  176. .. rst-class:: classref-method
  177. :ref:`float<class_float>` **get_point_left_tangent**\ (\ index\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_Curve_method_get_point_left_tangent>`
  178. Returns the left tangent angle (in degrees) for the point at ``index``.
  179. .. rst-class:: classref-item-separator
  180. ----
  181. .. _class_Curve_method_get_point_position:
  182. .. rst-class:: classref-method
  183. :ref:`Vector2<class_Vector2>` **get_point_position**\ (\ index\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_Curve_method_get_point_position>`
  184. Returns the curve coordinates for the point at ``index``.
  185. .. rst-class:: classref-item-separator
  186. ----
  187. .. _class_Curve_method_get_point_right_mode:
  188. .. rst-class:: classref-method
  189. :ref:`TangentMode<enum_Curve_TangentMode>` **get_point_right_mode**\ (\ index\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_Curve_method_get_point_right_mode>`
  190. Returns the right :ref:`TangentMode<enum_Curve_TangentMode>` for the point at ``index``.
  191. .. rst-class:: classref-item-separator
  192. ----
  193. .. _class_Curve_method_get_point_right_tangent:
  194. .. rst-class:: classref-method
  195. :ref:`float<class_float>` **get_point_right_tangent**\ (\ index\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_Curve_method_get_point_right_tangent>`
  196. Returns the right tangent angle (in degrees) for the point at ``index``.
  197. .. rst-class:: classref-item-separator
  198. ----
  199. .. _class_Curve_method_remove_point:
  200. .. rst-class:: classref-method
  201. |void| **remove_point**\ (\ index\: :ref:`int<class_int>`\ ) :ref:`🔗<class_Curve_method_remove_point>`
  202. Removes the point at ``index`` from the curve.
  203. .. rst-class:: classref-item-separator
  204. ----
  205. .. _class_Curve_method_sample:
  206. .. rst-class:: classref-method
  207. :ref:`float<class_float>` **sample**\ (\ offset\: :ref:`float<class_float>`\ ) |const| :ref:`🔗<class_Curve_method_sample>`
  208. Returns the Y value for the point that would exist at the X position ``offset`` along the curve.
  209. .. rst-class:: classref-item-separator
  210. ----
  211. .. _class_Curve_method_sample_baked:
  212. .. rst-class:: classref-method
  213. :ref:`float<class_float>` **sample_baked**\ (\ offset\: :ref:`float<class_float>`\ ) |const| :ref:`🔗<class_Curve_method_sample_baked>`
  214. 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.
  215. .. rst-class:: classref-item-separator
  216. ----
  217. .. _class_Curve_method_set_point_left_mode:
  218. .. rst-class:: classref-method
  219. |void| **set_point_left_mode**\ (\ index\: :ref:`int<class_int>`, mode\: :ref:`TangentMode<enum_Curve_TangentMode>`\ ) :ref:`🔗<class_Curve_method_set_point_left_mode>`
  220. Sets the left :ref:`TangentMode<enum_Curve_TangentMode>` for the point at ``index`` to ``mode``.
  221. .. rst-class:: classref-item-separator
  222. ----
  223. .. _class_Curve_method_set_point_left_tangent:
  224. .. rst-class:: classref-method
  225. |void| **set_point_left_tangent**\ (\ index\: :ref:`int<class_int>`, tangent\: :ref:`float<class_float>`\ ) :ref:`🔗<class_Curve_method_set_point_left_tangent>`
  226. Sets the left tangent angle for the point at ``index`` to ``tangent``.
  227. .. rst-class:: classref-item-separator
  228. ----
  229. .. _class_Curve_method_set_point_offset:
  230. .. rst-class:: classref-method
  231. :ref:`int<class_int>` **set_point_offset**\ (\ index\: :ref:`int<class_int>`, offset\: :ref:`float<class_float>`\ ) :ref:`🔗<class_Curve_method_set_point_offset>`
  232. Sets the offset from ``0.5``.
  233. .. rst-class:: classref-item-separator
  234. ----
  235. .. _class_Curve_method_set_point_right_mode:
  236. .. rst-class:: classref-method
  237. |void| **set_point_right_mode**\ (\ index\: :ref:`int<class_int>`, mode\: :ref:`TangentMode<enum_Curve_TangentMode>`\ ) :ref:`🔗<class_Curve_method_set_point_right_mode>`
  238. Sets the right :ref:`TangentMode<enum_Curve_TangentMode>` for the point at ``index`` to ``mode``.
  239. .. rst-class:: classref-item-separator
  240. ----
  241. .. _class_Curve_method_set_point_right_tangent:
  242. .. rst-class:: classref-method
  243. |void| **set_point_right_tangent**\ (\ index\: :ref:`int<class_int>`, tangent\: :ref:`float<class_float>`\ ) :ref:`🔗<class_Curve_method_set_point_right_tangent>`
  244. Sets the right tangent angle for the point at ``index`` to ``tangent``.
  245. .. rst-class:: classref-item-separator
  246. ----
  247. .. _class_Curve_method_set_point_value:
  248. .. rst-class:: classref-method
  249. |void| **set_point_value**\ (\ index\: :ref:`int<class_int>`, y\: :ref:`float<class_float>`\ ) :ref:`🔗<class_Curve_method_set_point_value>`
  250. Assigns the vertical position ``y`` to the point at ``index``.
  251. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  252. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  253. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  254. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  255. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  256. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  257. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  258. .. |void| replace:: :abbr:`void (No return value.)`