class_line2d.rst 12 KB

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