class_curve.rst 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the Curve.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_Curve:
  5. Curve
  6. =====
  7. **Inherits:** :ref:`Resource<class_resource>` **<** :ref:`Reference<class_reference>` **<** :ref:`Object<class_object>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. A mathematic curve.
  12. Member Functions
  13. ----------------
  14. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  15. | :ref:`int<class_int>` | :ref:`add_point<class_Curve_add_point>` **(** :ref:`Vector2<class_vector2>` position, :ref:`float<class_float>` left_tangent=0, :ref:`float<class_float>` right_tangent=0, :ref:`int<class_int>` left_mode=0, :ref:`int<class_int>` right_mode=0 **)** |
  16. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  17. | void | :ref:`bake<class_Curve_bake>` **(** **)** |
  18. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  19. | void | :ref:`clean_dupes<class_Curve_clean_dupes>` **(** **)** |
  20. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | void | :ref:`clear_points<class_Curve_clear_points>` **(** **)** |
  22. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`int<class_int>` | :ref:`get_point_left_mode<class_Curve_get_point_left_mode>` **(** :ref:`int<class_int>` index **)** const |
  24. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`float<class_float>` | :ref:`get_point_left_tangent<class_Curve_get_point_left_tangent>` **(** :ref:`int<class_int>` index **)** const |
  26. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`Vector2<class_vector2>` | :ref:`get_point_position<class_Curve_get_point_position>` **(** :ref:`int<class_int>` index **)** const |
  28. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`int<class_int>` | :ref:`get_point_right_mode<class_Curve_get_point_right_mode>` **(** :ref:`int<class_int>` index **)** const |
  30. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`float<class_float>` | :ref:`get_point_right_tangent<class_Curve_get_point_right_tangent>` **(** :ref:`int<class_int>` index **)** const |
  32. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`float<class_float>` | :ref:`interpolate<class_Curve_interpolate>` **(** :ref:`float<class_float>` offset **)** const |
  34. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`float<class_float>` | :ref:`interpolate_baked<class_Curve_interpolate_baked>` **(** :ref:`float<class_float>` offset **)** |
  36. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | void | :ref:`remove_point<class_Curve_remove_point>` **(** :ref:`int<class_int>` index **)** |
  38. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | void | :ref:`set_point_left_mode<class_Curve_set_point_left_mode>` **(** :ref:`int<class_int>` index, :ref:`int<class_int>` mode **)** |
  40. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | void | :ref:`set_point_left_tangent<class_Curve_set_point_left_tangent>` **(** :ref:`int<class_int>` index, :ref:`float<class_float>` tangent **)** |
  42. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`int<class_int>` | :ref:`set_point_offset<class_Curve_set_point_offset>` **(** :ref:`int<class_int>` index, :ref:`float<class_float>` offset **)** |
  44. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | void | :ref:`set_point_right_mode<class_Curve_set_point_right_mode>` **(** :ref:`int<class_int>` index, :ref:`int<class_int>` mode **)** |
  46. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | void | :ref:`set_point_right_tangent<class_Curve_set_point_right_tangent>` **(** :ref:`int<class_int>` index, :ref:`float<class_float>` tangent **)** |
  48. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | void | :ref:`set_point_value<class_Curve_set_point_value>` **(** :ref:`int<class_int>` index, :ref:`float<class_float>` y **)** |
  50. +--------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. Signals
  52. -------
  53. .. _class_Curve_range_changed:
  54. - **range_changed** **(** **)**
  55. Emitted when :ref:`max_value<class_Curve_max_value>` or :ref:`min_value<class_Curve_min_value>` is changed.
  56. Member Variables
  57. ----------------
  58. .. _class_Curve_bake_resolution:
  59. - :ref:`int<class_int>` **bake_resolution** - The number of points to include in the baked (i.e. cached) curve data.
  60. .. _class_Curve_max_value:
  61. - :ref:`float<class_float>` **max_value** - The maximum value the curve can reach. Default value: ``1``.
  62. .. _class_Curve_min_value:
  63. - :ref:`float<class_float>` **min_value** - The minimum value the curve can reach. Default value: ``0``.
  64. Enums
  65. -----
  66. .. _enum_Curve_TangentMode:
  67. enum **TangentMode**
  68. - **TANGENT_FREE** = **0** --- The tangent on this side of the point is user-defined.
  69. - **TANGENT_LINEAR** = **1** --- The curve calculates the tangent on this side of the point as the slope halfway towards the adjacent point.
  70. - **TANGENT_MODE_COUNT** = **2** --- The total number of available tangent modes.
  71. Description
  72. -----------
  73. 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.
  74. Member Function Description
  75. ---------------------------
  76. .. _class_Curve_add_point:
  77. - :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:`int<class_int>` left_mode=0, :ref:`int<class_int>` right_mode=0 **)**
  78. 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``.
  79. .. _class_Curve_bake:
  80. - void **bake** **(** **)**
  81. Recomputes the baked cache of points for the curve.
  82. .. _class_Curve_clean_dupes:
  83. - void **clean_dupes** **(** **)**
  84. Removes points that are closer than ``CMP_EPSILON`` (0.00001) units to their neighbor on the curve.
  85. .. _class_Curve_clear_points:
  86. - void **clear_points** **(** **)**
  87. Removes all points from the curve.
  88. .. _class_Curve_get_point_left_mode:
  89. - :ref:`int<class_int>` **get_point_left_mode** **(** :ref:`int<class_int>` index **)** const
  90. Returns the left ``TangentMode`` for the point at ``index``.
  91. .. _class_Curve_get_point_left_tangent:
  92. - :ref:`float<class_float>` **get_point_left_tangent** **(** :ref:`int<class_int>` index **)** const
  93. Returns the left tangent angle (in degrees) for the point at ``index``.
  94. .. _class_Curve_get_point_position:
  95. - :ref:`Vector2<class_vector2>` **get_point_position** **(** :ref:`int<class_int>` index **)** const
  96. Returns the curve coordinates for the point at ``index``.
  97. .. _class_Curve_get_point_right_mode:
  98. - :ref:`int<class_int>` **get_point_right_mode** **(** :ref:`int<class_int>` index **)** const
  99. Returns the right ``TangentMode`` for the point at ``index``.
  100. .. _class_Curve_get_point_right_tangent:
  101. - :ref:`float<class_float>` **get_point_right_tangent** **(** :ref:`int<class_int>` index **)** const
  102. Returns the right tangent angle (in degrees) for the point at ``index``.
  103. .. _class_Curve_interpolate:
  104. - :ref:`float<class_float>` **interpolate** **(** :ref:`float<class_float>` offset **)** const
  105. Returns the y value for the point that would exist at x-position ``offset`` along the curve.
  106. .. _class_Curve_interpolate_baked:
  107. - :ref:`float<class_float>` **interpolate_baked** **(** :ref:`float<class_float>` offset **)**
  108. Returns the y value for the point that would exist at x-position ``offset`` along the curve using the baked cache. Bakes the curve's points if not already baked.
  109. .. _class_Curve_remove_point:
  110. - void **remove_point** **(** :ref:`int<class_int>` index **)**
  111. Removes the point at ``index`` from the curve.
  112. .. _class_Curve_set_point_left_mode:
  113. - void **set_point_left_mode** **(** :ref:`int<class_int>` index, :ref:`int<class_int>` mode **)**
  114. Sets the left ``TangentMode`` for the point at ``index`` to ``mode``.
  115. .. _class_Curve_set_point_left_tangent:
  116. - void **set_point_left_tangent** **(** :ref:`int<class_int>` index, :ref:`float<class_float>` tangent **)**
  117. Sets the left tangent angle for the point at ``index`` to ``tangent``.
  118. .. _class_Curve_set_point_offset:
  119. - :ref:`int<class_int>` **set_point_offset** **(** :ref:`int<class_int>` index, :ref:`float<class_float>` offset **)**
  120. Sets the offset from ``0.5``
  121. .. _class_Curve_set_point_right_mode:
  122. - void **set_point_right_mode** **(** :ref:`int<class_int>` index, :ref:`int<class_int>` mode **)**
  123. Sets the right ``TangentMode`` for the point at ``index`` to ``mode``.
  124. .. _class_Curve_set_point_right_tangent:
  125. - void **set_point_right_tangent** **(** :ref:`int<class_int>` index, :ref:`float<class_float>` tangent **)**
  126. Sets the right tangent angle for the point at ``index`` to ``tangent``.
  127. .. _class_Curve_set_point_value:
  128. - void **set_point_value** **(** :ref:`int<class_int>` index, :ref:`float<class_float>` y **)**
  129. Assigns the vertical position ``y`` to the point at ``index``.