class_polygon2d.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_Polygon2D:
  4. Polygon2D
  5. =========
  6. **Inherits:** :ref:`Node2D<class_node2d>` **<** :ref:`CanvasItem<class_canvasitem>` **<** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
  7. **Category:** Core
  8. Brief Description
  9. -----------------
  10. 2D polygon representation
  11. Member Functions
  12. ----------------
  13. +------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  14. | :ref:`Color<class_color>` | :ref:`get_color<class_Polygon2D_get_color>` **(** **)** const |
  15. +------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  16. | :ref:`bool<class_bool>` | :ref:`get_invert<class_Polygon2D_get_invert>` **(** **)** const |
  17. +------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  18. | :ref:`float<class_float>` | :ref:`get_invert_border<class_Polygon2D_get_invert_border>` **(** **)** const |
  19. +------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  20. | :ref:`Vector2<class_vector2>` | :ref:`get_offset<class_Polygon2D_get_offset>` **(** **)** const |
  21. +------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  22. | :ref:`Vector2Array<class_vector2array>` | :ref:`get_polygon<class_Polygon2D_get_polygon>` **(** **)** const |
  23. +------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`Object<class_object>` | :ref:`get_texture<class_Polygon2D_get_texture>` **(** **)** const |
  25. +------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`Vector2<class_vector2>` | :ref:`get_texture_offset<class_Polygon2D_get_texture_offset>` **(** **)** const |
  27. +------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`float<class_float>` | :ref:`get_texture_rotation<class_Polygon2D_get_texture_rotation>` **(** **)** const |
  29. +------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`Vector2<class_vector2>` | :ref:`get_texture_scale<class_Polygon2D_get_texture_scale>` **(** **)** const |
  31. +------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`Vector2Array<class_vector2array>` | :ref:`get_uv<class_Polygon2D_get_uv>` **(** **)** const |
  33. +------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`ColorArray<class_colorarray>` | :ref:`get_vertex_colors<class_Polygon2D_get_vertex_colors>` **(** **)** const |
  35. +------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  36. | void | :ref:`set_color<class_Polygon2D_set_color>` **(** :ref:`Color<class_color>` color **)** |
  37. +------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  38. | void | :ref:`set_invert<class_Polygon2D_set_invert>` **(** :ref:`bool<class_bool>` invert **)** |
  39. +------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  40. | void | :ref:`set_invert_border<class_Polygon2D_set_invert_border>` **(** :ref:`float<class_float>` invert_border **)** |
  41. +------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  42. | void | :ref:`set_offset<class_Polygon2D_set_offset>` **(** :ref:`Vector2<class_vector2>` offset **)** |
  43. +------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  44. | void | :ref:`set_polygon<class_Polygon2D_set_polygon>` **(** :ref:`Vector2Array<class_vector2array>` polygon **)** |
  45. +------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  46. | void | :ref:`set_texture<class_Polygon2D_set_texture>` **(** :ref:`Object<class_object>` texture **)** |
  47. +------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  48. | void | :ref:`set_texture_offset<class_Polygon2D_set_texture_offset>` **(** :ref:`Vector2<class_vector2>` texture_offset **)** |
  49. +------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  50. | void | :ref:`set_texture_rotation<class_Polygon2D_set_texture_rotation>` **(** :ref:`float<class_float>` texture_rotation **)** |
  51. +------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  52. | void | :ref:`set_texture_scale<class_Polygon2D_set_texture_scale>` **(** :ref:`Vector2<class_vector2>` texture_scale **)** |
  53. +------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  54. | void | :ref:`set_uv<class_Polygon2D_set_uv>` **(** :ref:`Vector2Array<class_vector2array>` uv **)** |
  55. +------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  56. | void | :ref:`set_vertex_colors<class_Polygon2D_set_vertex_colors>` **(** :ref:`ColorArray<class_colorarray>` vertex_colors **)** |
  57. +------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  58. Description
  59. -----------
  60. A Polygon2D is defined by a set of n vertices connected together by line segments, meaning that the vertex 1 will be connected with vertex 2, vertex 2 with vertex 3 ..., vertex n-1 with vertex n and vertex n with vertex 1 in order to close the loop and define a polygon.
  61. Member Function Description
  62. ---------------------------
  63. .. _class_Polygon2D_get_color:
  64. - :ref:`Color<class_color>` **get_color** **(** **)** const
  65. Return the polygon fill color.
  66. .. _class_Polygon2D_get_invert:
  67. - :ref:`bool<class_bool>` **get_invert** **(** **)** const
  68. Return whether this polygon is inverted or not.
  69. .. _class_Polygon2D_get_invert_border:
  70. - :ref:`float<class_float>` **get_invert_border** **(** **)** const
  71. Return the added padding around the bounding box.
  72. .. _class_Polygon2D_get_offset:
  73. - :ref:`Vector2<class_vector2>` **get_offset** **(** **)** const
  74. Return the offset for the polygon vertices.
  75. .. _class_Polygon2D_get_polygon:
  76. - :ref:`Vector2Array<class_vector2array>` **get_polygon** **(** **)** const
  77. Return the set of vertices that defines this polygon.
  78. .. _class_Polygon2D_get_texture:
  79. - :ref:`Object<class_object>` **get_texture** **(** **)** const
  80. Return the polygon texture
  81. .. _class_Polygon2D_get_texture_offset:
  82. - :ref:`Vector2<class_vector2>` **get_texture_offset** **(** **)** const
  83. Return the polygon texture offset.
  84. .. _class_Polygon2D_get_texture_rotation:
  85. - :ref:`float<class_float>` **get_texture_rotation** **(** **)** const
  86. Return the rotation in radians of the texture polygon.
  87. .. _class_Polygon2D_get_texture_scale:
  88. - :ref:`Vector2<class_vector2>` **get_texture_scale** **(** **)** const
  89. Return the uv coordinate multiplier.
  90. .. _class_Polygon2D_get_uv:
  91. - :ref:`Vector2Array<class_vector2array>` **get_uv** **(** **)** const
  92. Return the texture coordinates associated with every vertex of the polygon.
  93. .. _class_Polygon2D_get_vertex_colors:
  94. - :ref:`ColorArray<class_colorarray>` **get_vertex_colors** **(** **)** const
  95. Return the list of vertex colors.
  96. .. _class_Polygon2D_set_color:
  97. - void **set_color** **(** :ref:`Color<class_color>` color **)**
  98. 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>`.
  99. .. _class_Polygon2D_set_invert:
  100. - void **set_invert** **(** :ref:`bool<class_bool>` invert **)**
  101. 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).
  102. .. _class_Polygon2D_set_invert_border:
  103. - void **set_invert_border** **(** :ref:`float<class_float>` invert_border **)**
  104. Add extra padding around the bounding box, making it bigger. Too small a value can make the polygon triangulate strangely, due to numerical imprecision.
  105. .. _class_Polygon2D_set_offset:
  106. - void **set_offset** **(** :ref:`Vector2<class_vector2>` offset **)**
  107. 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.
  108. .. _class_Polygon2D_set_polygon:
  109. - void **set_polygon** **(** :ref:`Vector2Array<class_vector2array>` polygon **)**
  110. Define the set of vertices that will represent the polygon.
  111. .. _class_Polygon2D_set_texture:
  112. - void **set_texture** **(** :ref:`Object<class_object>` texture **)**
  113. Set the polygon texture.
  114. .. _class_Polygon2D_set_texture_offset:
  115. - void **set_texture_offset** **(** :ref:`Vector2<class_vector2>` texture_offset **)**
  116. 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.
  117. .. _class_Polygon2D_set_texture_rotation:
  118. - void **set_texture_rotation** **(** :ref:`float<class_float>` texture_rotation **)**
  119. Set the amount of rotation of the polygon texture, ``texture_rotation`` is specified in radians and clockwise rotation.
  120. .. _class_Polygon2D_set_texture_scale:
  121. - void **set_texture_scale** **(** :ref:`Vector2<class_vector2>` texture_scale **)**
  122. 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.
  123. .. _class_Polygon2D_set_uv:
  124. - void **set_uv** **(** :ref:`Vector2Array<class_vector2array>` uv **)**
  125. 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.
  126. .. _class_Polygon2D_set_vertex_colors:
  127. - void **set_vertex_colors** **(** :ref:`ColorArray<class_colorarray>` vertex_colors **)**
  128. 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.
  129. Colors are interpolated between vertices, resulting in smooth gradients when they differ.