class_polygon2d.rst 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the Polygon2D.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_Polygon2D:
  5. Polygon2D
  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 polygon.
  12. Member Functions
  13. ----------------
  14. +--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
  15. | :ref:`bool<class_bool>` | :ref:`get_antialiased<class_Polygon2D_get_antialiased>` **(** **)** const |
  16. +--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
  17. | :ref:`Color<class_color>` | :ref:`get_color<class_Polygon2D_get_color>` **(** **)** const |
  18. +--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
  19. | :ref:`bool<class_bool>` | :ref:`get_invert<class_Polygon2D_get_invert>` **(** **)** const |
  20. +--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`float<class_float>` | :ref:`get_invert_border<class_Polygon2D_get_invert_border>` **(** **)** const |
  22. +--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`Vector2<class_vector2>` | :ref:`get_offset<class_Polygon2D_get_offset>` **(** **)** const |
  24. +--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`PoolVector2Array<class_poolvector2array>` | :ref:`get_polygon<class_Polygon2D_get_polygon>` **(** **)** const |
  26. +--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`Texture<class_texture>` | :ref:`get_texture<class_Polygon2D_get_texture>` **(** **)** const |
  28. +--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`Vector2<class_vector2>` | :ref:`get_texture_offset<class_Polygon2D_get_texture_offset>` **(** **)** const |
  30. +--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`float<class_float>` | :ref:`get_texture_rotation<class_Polygon2D_get_texture_rotation>` **(** **)** const |
  32. +--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`Vector2<class_vector2>` | :ref:`get_texture_scale<class_Polygon2D_get_texture_scale>` **(** **)** const |
  34. +--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`PoolVector2Array<class_poolvector2array>` | :ref:`get_uv<class_Polygon2D_get_uv>` **(** **)** const |
  36. +--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`PoolColorArray<class_poolcolorarray>` | :ref:`get_vertex_colors<class_Polygon2D_get_vertex_colors>` **(** **)** const |
  38. +--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
  39. | void | :ref:`set_antialiased<class_Polygon2D_set_antialiased>` **(** :ref:`bool<class_bool>` antialiased **)** |
  40. +--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
  41. | void | :ref:`set_color<class_Polygon2D_set_color>` **(** :ref:`Color<class_color>` color **)** |
  42. +--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
  43. | void | :ref:`set_invert<class_Polygon2D_set_invert>` **(** :ref:`bool<class_bool>` invert **)** |
  44. +--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
  45. | void | :ref:`set_invert_border<class_Polygon2D_set_invert_border>` **(** :ref:`float<class_float>` invert_border **)** |
  46. +--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
  47. | void | :ref:`set_offset<class_Polygon2D_set_offset>` **(** :ref:`Vector2<class_vector2>` offset **)** |
  48. +--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
  49. | void | :ref:`set_polygon<class_Polygon2D_set_polygon>` **(** :ref:`PoolVector2Array<class_poolvector2array>` polygon **)** |
  50. +--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
  51. | void | :ref:`set_texture<class_Polygon2D_set_texture>` **(** :ref:`Texture<class_texture>` texture **)** |
  52. +--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
  53. | void | :ref:`set_texture_offset<class_Polygon2D_set_texture_offset>` **(** :ref:`Vector2<class_vector2>` texture_offset **)** |
  54. +--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
  55. | void | :ref:`set_texture_rotation<class_Polygon2D_set_texture_rotation>` **(** :ref:`float<class_float>` texture_rotation **)** |
  56. +--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
  57. | void | :ref:`set_texture_scale<class_Polygon2D_set_texture_scale>` **(** :ref:`Vector2<class_vector2>` texture_scale **)** |
  58. +--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
  59. | void | :ref:`set_uv<class_Polygon2D_set_uv>` **(** :ref:`PoolVector2Array<class_poolvector2array>` uv **)** |
  60. +--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
  61. | void | :ref:`set_vertex_colors<class_Polygon2D_set_vertex_colors>` **(** :ref:`PoolColorArray<class_poolcolorarray>` vertex_colors **)** |
  62. +--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
  63. Member Variables
  64. ----------------
  65. - :ref:`bool<class_bool>` **antialiased** - If [code]true[/code] polygon edges will be anti-aliased. Default value: [code]false[/code].
  66. - :ref:`Color<class_color>` **color** - The polygon's fill color. If [code]texture[/code] is defined, it will be multiplied by this color. It will also be the default color for vertices not set in [code]vertex_colors[/code].
  67. - :ref:`float<class_float>` **invert_border** - Added padding applied to the bounding box when using [code]invert[/code]. Setting this value too small may result in a "Bad Polygon" error. Default value: [code]100[/code].
  68. - :ref:`bool<class_bool>` **invert_enable** - If [code]true[/code] polygon will be inverted, containing the area outside the defined points and extending to the [code]invert_border[/code]. Default value: [code]false[/code].
  69. - :ref:`Vector2<class_vector2>` **offset** - The offset applied to each vertex.
  70. - :ref:`PoolVector2Array<class_poolvector2array>` **polygon** - The polygon's list of vertices. The final point will be connected to the first.
  71. - :ref:`Texture<class_texture>` **texture** - The polygon's fill texture. Use [code]uv[/code] to set texture coordinates.
  72. - :ref:`Vector2<class_vector2>` **texture_offset** - Amount to offset the polygon's [code]texture[/code]. If [code](0, 0)[/code] the texture's origin (its top-left corner) will be placed at the polygon's [code]position[/code].
  73. - :ref:`float<class_float>` **texture_rotation** - The texture's rotation in degrees.
  74. - :ref:`Vector2<class_vector2>` **texture_scale** - Amount to multiply the [code]uv[/code] coordinates when using a [code]texture[/code]. Larger values make the texture smaller, and vice versa.
  75. - :ref:`PoolVector2Array<class_poolvector2array>` **uv** - Texture coordinates for each vertex of the polygon. There should be one [code]uv[/code] per polygon vertex. If there are fewer, undefined vertices will use [code](0, 0)[/code].
  76. - :ref:`PoolColorArray<class_poolcolorarray>` **vertex_colors** - Color for each vertex. Colors are interpolated between vertices, resulting in smooth gradients. There should be one per polygon vertex. If there are fewer, undefined vertices will use [code]color[/code].
  77. Description
  78. -----------
  79. A Polygon2D is defined by a set of points. Each point is connected to the next, with the final point being connected to the first, resulting in a closed polygon. Polygon2Ds can be filled with color (solid or gradient) or filled with a given texture.
  80. Member Function Description
  81. ---------------------------
  82. .. _class_Polygon2D_get_antialiased:
  83. - :ref:`bool<class_bool>` **get_antialiased** **(** **)** const
  84. .. _class_Polygon2D_get_color:
  85. - :ref:`Color<class_color>` **get_color** **(** **)** const
  86. Return the polygon fill color.
  87. .. _class_Polygon2D_get_invert:
  88. - :ref:`bool<class_bool>` **get_invert** **(** **)** const
  89. Return whether this polygon is inverted or not.
  90. .. _class_Polygon2D_get_invert_border:
  91. - :ref:`float<class_float>` **get_invert_border** **(** **)** const
  92. Return the added padding around the bounding box.
  93. .. _class_Polygon2D_get_offset:
  94. - :ref:`Vector2<class_vector2>` **get_offset** **(** **)** const
  95. Return the offset for the polygon vertices.
  96. .. _class_Polygon2D_get_polygon:
  97. - :ref:`PoolVector2Array<class_poolvector2array>` **get_polygon** **(** **)** const
  98. Return the set of vertices that defines this polygon.
  99. .. _class_Polygon2D_get_texture:
  100. - :ref:`Texture<class_texture>` **get_texture** **(** **)** const
  101. Return the polygon texture
  102. .. _class_Polygon2D_get_texture_offset:
  103. - :ref:`Vector2<class_vector2>` **get_texture_offset** **(** **)** const
  104. Return the polygon texture offset.
  105. .. _class_Polygon2D_get_texture_rotation:
  106. - :ref:`float<class_float>` **get_texture_rotation** **(** **)** const
  107. Return the rotation in radians of the texture polygon.
  108. .. _class_Polygon2D_get_texture_scale:
  109. - :ref:`Vector2<class_vector2>` **get_texture_scale** **(** **)** const
  110. Return the uv coordinate multiplier.
  111. .. _class_Polygon2D_get_uv:
  112. - :ref:`PoolVector2Array<class_poolvector2array>` **get_uv** **(** **)** const
  113. Return the texture coordinates associated with every vertex of the polygon.
  114. .. _class_Polygon2D_get_vertex_colors:
  115. - :ref:`PoolColorArray<class_poolcolorarray>` **get_vertex_colors** **(** **)** const
  116. Return the list of vertex colors.
  117. .. _class_Polygon2D_set_antialiased:
  118. - void **set_antialiased** **(** :ref:`bool<class_bool>` antialiased **)**
  119. .. _class_Polygon2D_set_color:
  120. - void **set_color** **(** :ref:`Color<class_color>` color **)**
  121. Set the polygon fill color. If the polygon has a texture defined, the defined texture will be multiplied by the polygon fill color. This, also, is the default color for those vertices that are not defined by :ref:`get_vertex_colors<class_Polygon2D_get_vertex_colors>`.
  122. .. _class_Polygon2D_set_invert:
  123. - void **set_invert** **(** :ref:`bool<class_bool>` invert **)**
  124. Set the polygon as the defined polygon bounding box minus the defined polygon (the defined polygon will appear as a hole on the square that contains the defined polygon).
  125. .. _class_Polygon2D_set_invert_border:
  126. - void **set_invert_border** **(** :ref:`float<class_float>` invert_border **)**
  127. Add extra padding around the bounding box, making it bigger. Too small a value can make the polygon triangulate strangely, due to numerical imprecision.
  128. .. _class_Polygon2D_set_offset:
  129. - void **set_offset** **(** :ref:`Vector2<class_vector2>` offset **)**
  130. Set the an offset that will be added to the vertices' position. E.g. if the offset is set to (10,10) then all the polygon points will move 10 units to the right and 10 units to the bottom.
  131. .. _class_Polygon2D_set_polygon:
  132. - void **set_polygon** **(** :ref:`PoolVector2Array<class_poolvector2array>` polygon **)**
  133. Define the set of vertices that will represent the polygon.
  134. .. _class_Polygon2D_set_texture:
  135. - void **set_texture** **(** :ref:`Texture<class_texture>` texture **)**
  136. .. _class_Polygon2D_set_texture_offset:
  137. - void **set_texture_offset** **(** :ref:`Vector2<class_vector2>` texture_offset **)**
  138. Set the offset of the polygon texture. Initially the texture will appear anchored to the polygon position, the offset is used to move the texture location away from that point (notice that the texture origin is set to its top left corner, so when offset is 0,0 the top left corner of the texture is at the polygon position), for example setting the offset to 10, 10 will move the texture 10 units to the left and 10 units to the top.
  139. .. _class_Polygon2D_set_texture_rotation:
  140. - void **set_texture_rotation** **(** :ref:`float<class_float>` texture_rotation **)**
  141. Set the amount of rotation of the polygon texture, ``texture_rotation`` is specified in radians and clockwise rotation.
  142. .. _class_Polygon2D_set_texture_scale:
  143. - void **set_texture_scale** **(** :ref:`Vector2<class_vector2>` texture_scale **)**
  144. Set the value that will multiply the uv coordinates (:ref:`get_uv<class_Polygon2D_get_uv>`) when applying the texture. Larger values make the texture smaller, and vice versa.
  145. .. _class_Polygon2D_set_uv:
  146. - void **set_uv** **(** :ref:`PoolVector2Array<class_poolvector2array>` uv **)**
  147. Set the texture coordinates for every vertex of the polygon. There should be one uv vertex for every vertex in the polygon. If there are less, the undefined ones will be assumed to be (0,0). Extra uv vertices are ignored.
  148. .. _class_Polygon2D_set_vertex_colors:
  149. - void **set_vertex_colors** **(** :ref:`PoolColorArray<class_poolcolorarray>` vertex_colors **)**
  150. Set the color for each vertex of the polygon. There should be one color for every vertex in the polygon. If there are less, the undefined ones will be assumed to be :ref:`get_color<class_Polygon2D_get_color>`. Extra color entries are ignored.
  151. Colors are interpolated between vertices, resulting in smooth gradients when they differ.