class_line2d.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the Line2D.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_Line2D:
  5. Line2D
  6. ======
  7. **Inherits:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. A 2D line.
  12. Properties
  13. ----------
  14. +-----------------------------------------------------+---------------------------------------------------------------+
  15. | :ref:`LineCapMode<enum_Line2D_LineCapMode>` | :ref:`begin_cap_mode<class_Line2D_property_begin_cap_mode>` |
  16. +-----------------------------------------------------+---------------------------------------------------------------+
  17. | :ref:`Color<class_Color>` | :ref:`default_color<class_Line2D_property_default_color>` |
  18. +-----------------------------------------------------+---------------------------------------------------------------+
  19. | :ref:`LineCapMode<enum_Line2D_LineCapMode>` | :ref:`end_cap_mode<class_Line2D_property_end_cap_mode>` |
  20. +-----------------------------------------------------+---------------------------------------------------------------+
  21. | :ref:`Gradient<class_Gradient>` | :ref:`gradient<class_Line2D_property_gradient>` |
  22. +-----------------------------------------------------+---------------------------------------------------------------+
  23. | :ref:`LineJointMode<enum_Line2D_LineJointMode>` | :ref:`joint_mode<class_Line2D_property_joint_mode>` |
  24. +-----------------------------------------------------+---------------------------------------------------------------+
  25. | :ref:`PoolVector2Array<class_PoolVector2Array>` | :ref:`points<class_Line2D_property_points>` |
  26. +-----------------------------------------------------+---------------------------------------------------------------+
  27. | :ref:`int<class_int>` | :ref:`round_precision<class_Line2D_property_round_precision>` |
  28. +-----------------------------------------------------+---------------------------------------------------------------+
  29. | :ref:`float<class_float>` | :ref:`sharp_limit<class_Line2D_property_sharp_limit>` |
  30. +-----------------------------------------------------+---------------------------------------------------------------+
  31. | :ref:`Texture<class_Texture>` | :ref:`texture<class_Line2D_property_texture>` |
  32. +-----------------------------------------------------+---------------------------------------------------------------+
  33. | :ref:`LineTextureMode<enum_Line2D_LineTextureMode>` | :ref:`texture_mode<class_Line2D_property_texture_mode>` |
  34. +-----------------------------------------------------+---------------------------------------------------------------+
  35. | :ref:`float<class_float>` | :ref:`width<class_Line2D_property_width>` |
  36. +-----------------------------------------------------+---------------------------------------------------------------+
  37. Methods
  38. -------
  39. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
  40. | void | :ref:`add_point<class_Line2D_method_add_point>` **(** :ref:`Vector2<class_Vector2>` position, :ref:`int<class_int>` at_position=-1 **)** |
  41. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
  42. | void | :ref:`clear_points<class_Line2D_method_clear_points>` **(** **)** |
  43. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`int<class_int>` | :ref:`get_point_count<class_Line2D_method_get_point_count>` **(** **)** const |
  45. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`Vector2<class_Vector2>` | :ref:`get_point_position<class_Line2D_method_get_point_position>` **(** :ref:`int<class_int>` i **)** const |
  47. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
  48. | void | :ref:`remove_point<class_Line2D_method_remove_point>` **(** :ref:`int<class_int>` i **)** |
  49. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
  50. | void | :ref:`set_point_position<class_Line2D_method_set_point_position>` **(** :ref:`int<class_int>` i, :ref:`Vector2<class_Vector2>` position **)** |
  51. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
  52. Enumerations
  53. ------------
  54. .. _enum_Line2D_LineJointMode:
  55. .. _class_Line2D_constant_LINE_JOINT_SHARP:
  56. .. _class_Line2D_constant_LINE_JOINT_BEVEL:
  57. .. _class_Line2D_constant_LINE_JOINT_ROUND:
  58. enum **LineJointMode**:
  59. - **LINE_JOINT_SHARP** = **0** --- The line's joints will be pointy. If ``sharp_limit`` is greater than the rotation of a joint, it becomes a bevel joint instead.
  60. - **LINE_JOINT_BEVEL** = **1** --- The line's joints will be bevelled/chamfered.
  61. - **LINE_JOINT_ROUND** = **2** --- The line's joints will be rounded.
  62. .. _enum_Line2D_LineCapMode:
  63. .. _class_Line2D_constant_LINE_CAP_NONE:
  64. .. _class_Line2D_constant_LINE_CAP_BOX:
  65. .. _class_Line2D_constant_LINE_CAP_ROUND:
  66. enum **LineCapMode**:
  67. - **LINE_CAP_NONE** = **0** --- Don't have a line cap.
  68. - **LINE_CAP_BOX** = **1** --- Draws the line cap as a box.
  69. - **LINE_CAP_ROUND** = **2** --- Draws the line cap as a circle.
  70. .. _enum_Line2D_LineTextureMode:
  71. .. _class_Line2D_constant_LINE_TEXTURE_NONE:
  72. .. _class_Line2D_constant_LINE_TEXTURE_TILE:
  73. .. _class_Line2D_constant_LINE_TEXTURE_STRETCH:
  74. enum **LineTextureMode**:
  75. - **LINE_TEXTURE_NONE** = **0** --- Takes the left pixels of the texture and renders it over the whole line.
  76. - **LINE_TEXTURE_TILE** = **1** --- Tiles the texture over the line. The texture need to be imported with Repeat Enabled for it to work properly.
  77. - **LINE_TEXTURE_STRETCH** = **2** --- Stretches the texture across the line. Import the texture with Repeat Disabled for best results.
  78. Description
  79. -----------
  80. A line through several points in 2D space.
  81. Property Descriptions
  82. ---------------------
  83. .. _class_Line2D_property_begin_cap_mode:
  84. - :ref:`LineCapMode<enum_Line2D_LineCapMode>` **begin_cap_mode**
  85. +----------+---------------------------+
  86. | *Setter* | set_begin_cap_mode(value) |
  87. +----------+---------------------------+
  88. | *Getter* | get_begin_cap_mode() |
  89. +----------+---------------------------+
  90. Controls the style of the line's first point. Use ``LINE_CAP_*`` constants. Default value: ``LINE_CAP_NONE``.
  91. .. _class_Line2D_property_default_color:
  92. - :ref:`Color<class_Color>` **default_color**
  93. +----------+--------------------------+
  94. | *Setter* | set_default_color(value) |
  95. +----------+--------------------------+
  96. | *Getter* | get_default_color() |
  97. +----------+--------------------------+
  98. The line's color. Will not be used if a gradient is set.
  99. .. _class_Line2D_property_end_cap_mode:
  100. - :ref:`LineCapMode<enum_Line2D_LineCapMode>` **end_cap_mode**
  101. +----------+-------------------------+
  102. | *Setter* | set_end_cap_mode(value) |
  103. +----------+-------------------------+
  104. | *Getter* | get_end_cap_mode() |
  105. +----------+-------------------------+
  106. Controls the style of the line's last point. Use ``LINE_CAP_*`` constants. Default value: ``LINE_CAP_NONE``.
  107. .. _class_Line2D_property_gradient:
  108. - :ref:`Gradient<class_Gradient>` **gradient**
  109. +----------+---------------------+
  110. | *Setter* | set_gradient(value) |
  111. +----------+---------------------+
  112. | *Getter* | get_gradient() |
  113. +----------+---------------------+
  114. The gradient is drawn through the whole line from start to finish. The default color will not be used if a gradient is set.
  115. .. _class_Line2D_property_joint_mode:
  116. - :ref:`LineJointMode<enum_Line2D_LineJointMode>` **joint_mode**
  117. +----------+-----------------------+
  118. | *Setter* | set_joint_mode(value) |
  119. +----------+-----------------------+
  120. | *Getter* | get_joint_mode() |
  121. +----------+-----------------------+
  122. The style for the points between the start and the end.
  123. .. _class_Line2D_property_points:
  124. - :ref:`PoolVector2Array<class_PoolVector2Array>` **points**
  125. +----------+-------------------+
  126. | *Setter* | set_points(value) |
  127. +----------+-------------------+
  128. | *Getter* | get_points() |
  129. +----------+-------------------+
  130. The points that form the lines. The line is drawn between every point set in this array.
  131. .. _class_Line2D_property_round_precision:
  132. - :ref:`int<class_int>` **round_precision**
  133. +----------+----------------------------+
  134. | *Setter* | set_round_precision(value) |
  135. +----------+----------------------------+
  136. | *Getter* | get_round_precision() |
  137. +----------+----------------------------+
  138. The smoothness of the rounded joints and caps. This is only used if a cap or joint is set as round.
  139. .. _class_Line2D_property_sharp_limit:
  140. - :ref:`float<class_float>` **sharp_limit**
  141. +----------+------------------------+
  142. | *Setter* | set_sharp_limit(value) |
  143. +----------+------------------------+
  144. | *Getter* | get_sharp_limit() |
  145. +----------+------------------------+
  146. The direction difference in radians between vector points. This value is only used if ``joint mode`` is set to ``LINE_JOINT_SHARP``.
  147. .. _class_Line2D_property_texture:
  148. - :ref:`Texture<class_Texture>` **texture**
  149. +----------+--------------------+
  150. | *Setter* | set_texture(value) |
  151. +----------+--------------------+
  152. | *Getter* | get_texture() |
  153. +----------+--------------------+
  154. The texture used for the line's texture. Uses ``texture_mode`` for drawing style.
  155. .. _class_Line2D_property_texture_mode:
  156. - :ref:`LineTextureMode<enum_Line2D_LineTextureMode>` **texture_mode**
  157. +----------+-------------------------+
  158. | *Setter* | set_texture_mode(value) |
  159. +----------+-------------------------+
  160. | *Getter* | get_texture_mode() |
  161. +----------+-------------------------+
  162. The style to render the ``texture`` on the line. Use ``LINE_TEXTURE_*`` constants. Default value: ``LINE_TEXTURE_NONE``.
  163. .. _class_Line2D_property_width:
  164. - :ref:`float<class_float>` **width**
  165. +----------+------------------+
  166. | *Setter* | set_width(value) |
  167. +----------+------------------+
  168. | *Getter* | get_width() |
  169. +----------+------------------+
  170. The line's width.
  171. Method Descriptions
  172. -------------------
  173. .. _class_Line2D_method_add_point:
  174. - void **add_point** **(** :ref:`Vector2<class_Vector2>` position, :ref:`int<class_int>` at_position=-1 **)**
  175. Add a point at the ``position``. Appends the point at the end of the line.
  176. If ``at_position`` is given, the point is inserted before the point number ``at_position``, moving that point (and every point after) after the inserted point. If ``at_position`` is not given, or is an illegal value (``at_position < 0`` or ``at_position >= [method get_point_count]``), the point will be appended at the end of the point list.
  177. .. _class_Line2D_method_clear_points:
  178. - void **clear_points** **(** **)**
  179. Removes all points from the line.
  180. .. _class_Line2D_method_get_point_count:
  181. - :ref:`int<class_int>` **get_point_count** **(** **)** const
  182. Returns the Line2D's amount of points.
  183. .. _class_Line2D_method_get_point_position:
  184. - :ref:`Vector2<class_Vector2>` **get_point_position** **(** :ref:`int<class_int>` i **)** const
  185. Returns point ``i``'s position.
  186. .. _class_Line2D_method_remove_point:
  187. - void **remove_point** **(** :ref:`int<class_int>` i **)**
  188. Remove the point at index ``i`` from the line.
  189. .. _class_Line2D_method_set_point_position:
  190. - void **set_point_position** **(** :ref:`int<class_int>` i, :ref:`Vector2<class_Vector2>` position **)**
  191. Overwrites the position in point ``i`` with the supplied ``position``.