Line2D.xml 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="Line2D" inherits="Node2D" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
  3. <brief_description>
  4. A 2D line.
  5. </brief_description>
  6. <description>
  7. A line through several points in 2D space. Supports varying width and color over the line's length, texturing, and several cap/joint types.
  8. [b]Note:[/b] By default, Godot can only draw up to 4,096 polygon points at a time. To increase this limit, open the Project Settings and increase [member ProjectSettings.rendering/limits/buffers/canvas_polygon_buffer_size_kb] and [member ProjectSettings.rendering/limits/buffers/canvas_polygon_index_buffer_size_kb].
  9. </description>
  10. <tutorials>
  11. <link title="Matrix Transform Demo">https://godotengine.org/asset-library/asset/584</link>
  12. <link title="2.5D Demo">https://godotengine.org/asset-library/asset/583</link>
  13. </tutorials>
  14. <methods>
  15. <method name="add_point">
  16. <return type="void" />
  17. <argument index="0" name="position" type="Vector2" />
  18. <argument index="1" name="index" type="int" default="-1" />
  19. <description>
  20. Adds a point with the specified [code]position[/code] relative to the line's own position. Appends the new point at the end of the point list.
  21. If [code]index[/code] is given, the new point is inserted before the existing point identified by index [code]index[/code]. Every existing point starting from [code]index[/code] is shifted further down the list of points. The index must be greater than or equal to [code]0[/code] and must not exceed the number of existing points in the line. See [method get_point_count].
  22. </description>
  23. </method>
  24. <method name="clear_points">
  25. <return type="void" />
  26. <description>
  27. Removes all points from the line.
  28. </description>
  29. </method>
  30. <method name="get_point_count" qualifiers="const">
  31. <return type="int" />
  32. <description>
  33. Returns the amount of points in the line.
  34. </description>
  35. </method>
  36. <method name="get_point_position" qualifiers="const">
  37. <return type="Vector2" />
  38. <argument index="0" name="index" type="int" />
  39. <description>
  40. Returns the position of the point at index [code]index[/code].
  41. </description>
  42. </method>
  43. <method name="remove_point">
  44. <return type="void" />
  45. <argument index="0" name="index" type="int" />
  46. <description>
  47. Removes the point at index [code]index[/code] from the line.
  48. </description>
  49. </method>
  50. <method name="set_point_position">
  51. <return type="void" />
  52. <argument index="0" name="index" type="int" />
  53. <argument index="1" name="position" type="Vector2" />
  54. <description>
  55. Overwrites the position of the point at index [code]index[/code] with the supplied [code]position[/code].
  56. </description>
  57. </method>
  58. </methods>
  59. <members>
  60. <member name="antialiased" type="bool" setter="set_antialiased" getter="get_antialiased" default="false">
  61. If [code]true[/code], the line's border will attempt to perform antialiasing by drawing thin OpenGL smooth lines on the line's edges.
  62. [b]Note:[/b] Line2D is not accelerated by batching if [member antialiased] is [code]true[/code].
  63. [b]Note:[/b] Due to how it works, built-in antialiasing will not look correct for translucent lines and may not work on certain platforms. As a workaround, install the [url=https://github.com/godot-extended-libraries/godot-antialiased-line2d]Antialiased Line2D[/url] add-on then create an AntialiasedLine2D node. That node relies on a texture with custom mipmaps to perform antialiasing. 2D batching is also still supported with those antialiased lines.
  64. </member>
  65. <member name="begin_cap_mode" type="int" setter="set_begin_cap_mode" getter="get_begin_cap_mode" enum="Line2D.LineCapMode" default="0">
  66. Controls the style of the line's first point. Use [enum LineCapMode] constants.
  67. </member>
  68. <member name="default_color" type="Color" setter="set_default_color" getter="get_default_color" default="Color( 0.4, 0.5, 1, 1 )">
  69. The line's color. Will not be used if a gradient is set.
  70. </member>
  71. <member name="end_cap_mode" type="int" setter="set_end_cap_mode" getter="get_end_cap_mode" enum="Line2D.LineCapMode" default="0">
  72. Controls the style of the line's last point. Use [enum LineCapMode] constants.
  73. </member>
  74. <member name="gradient" type="Gradient" setter="set_gradient" getter="get_gradient">
  75. The gradient is drawn through the whole line from start to finish. The default color will not be used if a gradient is set.
  76. </member>
  77. <member name="joint_mode" type="int" setter="set_joint_mode" getter="get_joint_mode" enum="Line2D.LineJointMode" default="0">
  78. The style for the points between the start and the end.
  79. </member>
  80. <member name="points" type="PoolVector2Array" setter="set_points" getter="get_points" default="PoolVector2Array( )">
  81. The points that form the lines. The line is drawn between every point set in this array. Points are interpreted as local vectors.
  82. </member>
  83. <member name="round_precision" type="int" setter="set_round_precision" getter="get_round_precision" default="8">
  84. The smoothness of the rounded joints and caps. Higher values result in smoother corners, but are more demanding to render and update. This is only used if a cap or joint is set as round.
  85. [b]Note:[/b] The default value is tuned for lines with the default [member width]. For thin lines, this value should be reduced to a number between [code]2[/code] and [code]4[/code] to improve performance.
  86. </member>
  87. <member name="sharp_limit" type="float" setter="set_sharp_limit" getter="get_sharp_limit" default="2.0">
  88. The direction difference in radians between vector points. This value is only used if [member joint_mode] is set to [constant LINE_JOINT_SHARP].
  89. </member>
  90. <member name="texture" type="Texture" setter="set_texture" getter="get_texture">
  91. The texture used for the line's texture. Uses [code]texture_mode[/code] for drawing style.
  92. </member>
  93. <member name="texture_mode" type="int" setter="set_texture_mode" getter="get_texture_mode" enum="Line2D.LineTextureMode" default="0">
  94. The style to render the [code]texture[/code] on the line. Use [enum LineTextureMode] constants.
  95. </member>
  96. <member name="width" type="float" setter="set_width" getter="get_width" default="10.0">
  97. The line's width.
  98. </member>
  99. <member name="width_curve" type="Curve" setter="set_curve" getter="get_curve">
  100. The line's width varies with the curve. The original width is simply multiply by the value of the Curve.
  101. </member>
  102. </members>
  103. <constants>
  104. <constant name="LINE_JOINT_SHARP" value="0" enum="LineJointMode">
  105. The line's joints will be pointy. If [code]sharp_limit[/code] is greater than the rotation of a joint, it becomes a bevel joint instead.
  106. </constant>
  107. <constant name="LINE_JOINT_BEVEL" value="1" enum="LineJointMode">
  108. The line's joints will be bevelled/chamfered.
  109. </constant>
  110. <constant name="LINE_JOINT_ROUND" value="2" enum="LineJointMode">
  111. The line's joints will be rounded.
  112. </constant>
  113. <constant name="LINE_CAP_NONE" value="0" enum="LineCapMode">
  114. Don't draw a line cap.
  115. </constant>
  116. <constant name="LINE_CAP_BOX" value="1" enum="LineCapMode">
  117. Draws the line cap as a box.
  118. </constant>
  119. <constant name="LINE_CAP_ROUND" value="2" enum="LineCapMode">
  120. Draws the line cap as a circle.
  121. </constant>
  122. <constant name="LINE_TEXTURE_NONE" value="0" enum="LineTextureMode">
  123. Takes the left pixels of the texture and renders it over the whole line.
  124. </constant>
  125. <constant name="LINE_TEXTURE_TILE" value="1" enum="LineTextureMode">
  126. Tiles the texture over the line. The texture must be imported with [b]Repeat[/b] enabled for it to work properly.
  127. </constant>
  128. <constant name="LINE_TEXTURE_STRETCH" value="2" enum="LineTextureMode">
  129. Stretches the texture across the line. Import the texture with [b]Repeat[/b] disabled for best results.
  130. </constant>
  131. </constants>
  132. </class>