class_curve.rst 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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 mathematic curve.
  11. Description
  12. -----------
  13. 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.
  14. See also :ref:`Gradient<class_Gradient>` which is designed for color interpolation. See also :ref:`Curve2D<class_Curve2D>` and :ref:`Curve3D<class_Curve3D>`.
  15. Properties
  16. ----------
  17. +---------------------------+--------------------------------------------------------------+---------+
  18. | :ref:`int<class_int>` | :ref:`bake_resolution<class_Curve_property_bake_resolution>` | ``100`` |
  19. +---------------------------+--------------------------------------------------------------+---------+
  20. | :ref:`float<class_float>` | :ref:`max_value<class_Curve_property_max_value>` | ``1.0`` |
  21. +---------------------------+--------------------------------------------------------------+---------+
  22. | :ref:`float<class_float>` | :ref:`min_value<class_Curve_property_min_value>` | ``0.0`` |
  23. +---------------------------+--------------------------------------------------------------+---------+
  24. | :ref:`int<class_int>` | :ref:`point_count<class_Curve_property_point_count>` | ``0`` |
  25. +---------------------------+--------------------------------------------------------------+---------+
  26. Methods
  27. -------
  28. +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`int<class_int>` | :ref:`add_point<class_Curve_method_add_point>` **(** :ref:`Vector2<class_Vector2>` position, :ref:`float<class_float>` left_tangent=0, :ref:`float<class_float>` right_tangent=0, :ref:`TangentMode<enum_Curve_TangentMode>` left_mode=0, :ref:`TangentMode<enum_Curve_TangentMode>` right_mode=0 **)** |
  30. +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | void | :ref:`bake<class_Curve_method_bake>` **(** **)** |
  32. +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | void | :ref:`clean_dupes<class_Curve_method_clean_dupes>` **(** **)** |
  34. +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | void | :ref:`clear_points<class_Curve_method_clear_points>` **(** **)** |
  36. +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`TangentMode<enum_Curve_TangentMode>` | :ref:`get_point_left_mode<class_Curve_method_get_point_left_mode>` **(** :ref:`int<class_int>` index **)** |const| |
  38. +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`float<class_float>` | :ref:`get_point_left_tangent<class_Curve_method_get_point_left_tangent>` **(** :ref:`int<class_int>` index **)** |const| |
  40. +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`Vector2<class_Vector2>` | :ref:`get_point_position<class_Curve_method_get_point_position>` **(** :ref:`int<class_int>` index **)** |const| |
  42. +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`TangentMode<enum_Curve_TangentMode>` | :ref:`get_point_right_mode<class_Curve_method_get_point_right_mode>` **(** :ref:`int<class_int>` index **)** |const| |
  44. +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`float<class_float>` | :ref:`get_point_right_tangent<class_Curve_method_get_point_right_tangent>` **(** :ref:`int<class_int>` index **)** |const| |
  46. +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | void | :ref:`remove_point<class_Curve_method_remove_point>` **(** :ref:`int<class_int>` index **)** |
  48. +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`float<class_float>` | :ref:`sample<class_Curve_method_sample>` **(** :ref:`float<class_float>` offset **)** |const| |
  50. +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`float<class_float>` | :ref:`sample_baked<class_Curve_method_sample_baked>` **(** :ref:`float<class_float>` offset **)** |const| |
  52. +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | void | :ref:`set_point_left_mode<class_Curve_method_set_point_left_mode>` **(** :ref:`int<class_int>` index, :ref:`TangentMode<enum_Curve_TangentMode>` mode **)** |
  54. +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | void | :ref:`set_point_left_tangent<class_Curve_method_set_point_left_tangent>` **(** :ref:`int<class_int>` index, :ref:`float<class_float>` tangent **)** |
  56. +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`int<class_int>` | :ref:`set_point_offset<class_Curve_method_set_point_offset>` **(** :ref:`int<class_int>` index, :ref:`float<class_float>` offset **)** |
  58. +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | void | :ref:`set_point_right_mode<class_Curve_method_set_point_right_mode>` **(** :ref:`int<class_int>` index, :ref:`TangentMode<enum_Curve_TangentMode>` mode **)** |
  60. +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | void | :ref:`set_point_right_tangent<class_Curve_method_set_point_right_tangent>` **(** :ref:`int<class_int>` index, :ref:`float<class_float>` tangent **)** |
  62. +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | void | :ref:`set_point_value<class_Curve_method_set_point_value>` **(** :ref:`int<class_int>` index, :ref:`float<class_float>` y **)** |
  64. +--------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. Signals
  66. -------
  67. .. _class_Curve_signal_range_changed:
  68. - **range_changed** **(** **)**
  69. Emitted when :ref:`max_value<class_Curve_property_max_value>` or :ref:`min_value<class_Curve_property_min_value>` is changed.
  70. Enumerations
  71. ------------
  72. .. _enum_Curve_TangentMode:
  73. .. _class_Curve_constant_TANGENT_FREE:
  74. .. _class_Curve_constant_TANGENT_LINEAR:
  75. .. _class_Curve_constant_TANGENT_MODE_COUNT:
  76. enum **TangentMode**:
  77. - **TANGENT_FREE** = **0** --- The tangent on this side of the point is user-defined.
  78. - **TANGENT_LINEAR** = **1** --- The curve calculates the tangent on this side of the point as the slope halfway towards the adjacent point.
  79. - **TANGENT_MODE_COUNT** = **2** --- The total number of available tangent modes.
  80. Property Descriptions
  81. ---------------------
  82. .. _class_Curve_property_bake_resolution:
  83. - :ref:`int<class_int>` **bake_resolution**
  84. +-----------+----------------------------+
  85. | *Default* | ``100`` |
  86. +-----------+----------------------------+
  87. | *Setter* | set_bake_resolution(value) |
  88. +-----------+----------------------------+
  89. | *Getter* | get_bake_resolution() |
  90. +-----------+----------------------------+
  91. The number of points to include in the baked (i.e. cached) curve data.
  92. ----
  93. .. _class_Curve_property_max_value:
  94. - :ref:`float<class_float>` **max_value**
  95. +-----------+----------------------+
  96. | *Default* | ``1.0`` |
  97. +-----------+----------------------+
  98. | *Setter* | set_max_value(value) |
  99. +-----------+----------------------+
  100. | *Getter* | get_max_value() |
  101. +-----------+----------------------+
  102. The maximum value the curve can reach.
  103. ----
  104. .. _class_Curve_property_min_value:
  105. - :ref:`float<class_float>` **min_value**
  106. +-----------+----------------------+
  107. | *Default* | ``0.0`` |
  108. +-----------+----------------------+
  109. | *Setter* | set_min_value(value) |
  110. +-----------+----------------------+
  111. | *Getter* | get_min_value() |
  112. +-----------+----------------------+
  113. The minimum value the curve can reach.
  114. ----
  115. .. _class_Curve_property_point_count:
  116. - :ref:`int<class_int>` **point_count**
  117. +-----------+------------------------+
  118. | *Default* | ``0`` |
  119. +-----------+------------------------+
  120. | *Setter* | set_point_count(value) |
  121. +-----------+------------------------+
  122. | *Getter* | get_point_count() |
  123. +-----------+------------------------+
  124. The number of points describing the curve.
  125. Method Descriptions
  126. -------------------
  127. .. _class_Curve_method_add_point:
  128. - :ref:`int<class_int>` **add_point** **(** :ref:`Vector2<class_Vector2>` position, :ref:`float<class_float>` left_tangent=0, :ref:`float<class_float>` right_tangent=0, :ref:`TangentMode<enum_Curve_TangentMode>` left_mode=0, :ref:`TangentMode<enum_Curve_TangentMode>` right_mode=0 **)**
  129. 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>`.
  130. ----
  131. .. _class_Curve_method_bake:
  132. - void **bake** **(** **)**
  133. Recomputes the baked cache of points for the curve.
  134. ----
  135. .. _class_Curve_method_clean_dupes:
  136. - void **clean_dupes** **(** **)**
  137. Removes points that are closer than ``CMP_EPSILON`` (0.00001) units to their neighbor on the curve.
  138. ----
  139. .. _class_Curve_method_clear_points:
  140. - void **clear_points** **(** **)**
  141. Removes all points from the curve.
  142. ----
  143. .. _class_Curve_method_get_point_left_mode:
  144. - :ref:`TangentMode<enum_Curve_TangentMode>` **get_point_left_mode** **(** :ref:`int<class_int>` index **)** |const|
  145. Returns the left :ref:`TangentMode<enum_Curve_TangentMode>` for the point at ``index``.
  146. ----
  147. .. _class_Curve_method_get_point_left_tangent:
  148. - :ref:`float<class_float>` **get_point_left_tangent** **(** :ref:`int<class_int>` index **)** |const|
  149. Returns the left tangent angle (in degrees) for the point at ``index``.
  150. ----
  151. .. _class_Curve_method_get_point_position:
  152. - :ref:`Vector2<class_Vector2>` **get_point_position** **(** :ref:`int<class_int>` index **)** |const|
  153. Returns the curve coordinates for the point at ``index``.
  154. ----
  155. .. _class_Curve_method_get_point_right_mode:
  156. - :ref:`TangentMode<enum_Curve_TangentMode>` **get_point_right_mode** **(** :ref:`int<class_int>` index **)** |const|
  157. Returns the right :ref:`TangentMode<enum_Curve_TangentMode>` for the point at ``index``.
  158. ----
  159. .. _class_Curve_method_get_point_right_tangent:
  160. - :ref:`float<class_float>` **get_point_right_tangent** **(** :ref:`int<class_int>` index **)** |const|
  161. Returns the right tangent angle (in degrees) for the point at ``index``.
  162. ----
  163. .. _class_Curve_method_remove_point:
  164. - void **remove_point** **(** :ref:`int<class_int>` index **)**
  165. Removes the point at ``index`` from the curve.
  166. ----
  167. .. _class_Curve_method_sample:
  168. - :ref:`float<class_float>` **sample** **(** :ref:`float<class_float>` offset **)** |const|
  169. Returns the Y value for the point that would exist at the X position ``offset`` along the curve.
  170. ----
  171. .. _class_Curve_method_sample_baked:
  172. - :ref:`float<class_float>` **sample_baked** **(** :ref:`float<class_float>` offset **)** |const|
  173. 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.
  174. ----
  175. .. _class_Curve_method_set_point_left_mode:
  176. - void **set_point_left_mode** **(** :ref:`int<class_int>` index, :ref:`TangentMode<enum_Curve_TangentMode>` mode **)**
  177. Sets the left :ref:`TangentMode<enum_Curve_TangentMode>` for the point at ``index`` to ``mode``.
  178. ----
  179. .. _class_Curve_method_set_point_left_tangent:
  180. - void **set_point_left_tangent** **(** :ref:`int<class_int>` index, :ref:`float<class_float>` tangent **)**
  181. Sets the left tangent angle for the point at ``index`` to ``tangent``.
  182. ----
  183. .. _class_Curve_method_set_point_offset:
  184. - :ref:`int<class_int>` **set_point_offset** **(** :ref:`int<class_int>` index, :ref:`float<class_float>` offset **)**
  185. Sets the offset from ``0.5``.
  186. ----
  187. .. _class_Curve_method_set_point_right_mode:
  188. - void **set_point_right_mode** **(** :ref:`int<class_int>` index, :ref:`TangentMode<enum_Curve_TangentMode>` mode **)**
  189. Sets the right :ref:`TangentMode<enum_Curve_TangentMode>` for the point at ``index`` to ``mode``.
  190. ----
  191. .. _class_Curve_method_set_point_right_tangent:
  192. - void **set_point_right_tangent** **(** :ref:`int<class_int>` index, :ref:`float<class_float>` tangent **)**
  193. Sets the right tangent angle for the point at ``index`` to ``tangent``.
  194. ----
  195. .. _class_Curve_method_set_point_value:
  196. - void **set_point_value** **(** :ref:`int<class_int>` index, :ref:`float<class_float>` y **)**
  197. Assigns the vertical position ``y`` to the point at ``index``.
  198. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  199. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  200. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  201. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  202. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  203. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`