class_polygon2d.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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. | void | :ref:`set_polygon<class_Polygon2D_set_polygon>` **(** :ref:`Vector2Array<class_vector2array>` polygon **)** |
  15. +------------------------------------------+----------------------------------------------------------------------------------------------------------------------------+
  16. | :ref:`Vector2Array<class_vector2array>` | :ref:`get_polygon<class_Polygon2D_get_polygon>` **(** **)** const |
  17. +------------------------------------------+----------------------------------------------------------------------------------------------------------------------------+
  18. | void | :ref:`set_uv<class_Polygon2D_set_uv>` **(** :ref:`Vector2Array<class_vector2array>` uv **)** |
  19. +------------------------------------------+----------------------------------------------------------------------------------------------------------------------------+
  20. | :ref:`Vector2Array<class_vector2array>` | :ref:`get_uv<class_Polygon2D_get_uv>` **(** **)** const |
  21. +------------------------------------------+----------------------------------------------------------------------------------------------------------------------------+
  22. | void | :ref:`set_color<class_Polygon2D_set_color>` **(** :ref:`Color<class_color>` color **)** |
  23. +------------------------------------------+----------------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`Color<class_color>` | :ref:`get_color<class_Polygon2D_get_color>` **(** **)** const |
  25. +------------------------------------------+----------------------------------------------------------------------------------------------------------------------------+
  26. | void | :ref:`set_texture<class_Polygon2D_set_texture>` **(** :ref:`Object<class_object>` texture **)** |
  27. +------------------------------------------+----------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`Object<class_object>` | :ref:`get_texture<class_Polygon2D_get_texture>` **(** **)** const |
  29. +------------------------------------------+----------------------------------------------------------------------------------------------------------------------------+
  30. | void | :ref:`set_texture_offset<class_Polygon2D_set_texture_offset>` **(** :ref:`Vector2<class_vector2>` texture_offset **)** |
  31. +------------------------------------------+----------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`Vector2<class_vector2>` | :ref:`get_texture_offset<class_Polygon2D_get_texture_offset>` **(** **)** const |
  33. +------------------------------------------+----------------------------------------------------------------------------------------------------------------------------+
  34. | void | :ref:`set_texture_rotation<class_Polygon2D_set_texture_rotation>` **(** :ref:`float<class_float>` texture_rotation **)** |
  35. +------------------------------------------+----------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`float<class_float>` | :ref:`get_texture_rotation<class_Polygon2D_get_texture_rotation>` **(** **)** const |
  37. +------------------------------------------+----------------------------------------------------------------------------------------------------------------------------+
  38. | void | :ref:`set_texture_scale<class_Polygon2D_set_texture_scale>` **(** :ref:`Vector2<class_vector2>` texture_scale **)** |
  39. +------------------------------------------+----------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`Vector2<class_vector2>` | :ref:`get_texture_scale<class_Polygon2D_get_texture_scale>` **(** **)** const |
  41. +------------------------------------------+----------------------------------------------------------------------------------------------------------------------------+
  42. | void | :ref:`set_invert<class_Polygon2D_set_invert>` **(** :ref:`bool<class_bool>` invert **)** |
  43. +------------------------------------------+----------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`bool<class_bool>` | :ref:`get_invert<class_Polygon2D_get_invert>` **(** **)** const |
  45. +------------------------------------------+----------------------------------------------------------------------------------------------------------------------------+
  46. | void | :ref:`set_invert_border<class_Polygon2D_set_invert_border>` **(** :ref:`float<class_float>` invert_border **)** |
  47. +------------------------------------------+----------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`float<class_float>` | :ref:`get_invert_border<class_Polygon2D_get_invert_border>` **(** **)** const |
  49. +------------------------------------------+----------------------------------------------------------------------------------------------------------------------------+
  50. | void | :ref:`set_offset<class_Polygon2D_set_offset>` **(** :ref:`Vector2<class_vector2>` offset **)** |
  51. +------------------------------------------+----------------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`Vector2<class_vector2>` | :ref:`get_offset<class_Polygon2D_get_offset>` **(** **)** const |
  53. +------------------------------------------+----------------------------------------------------------------------------------------------------------------------------+
  54. Description
  55. -----------
  56. A Polygon2D is defined by a set of n points connected together by line segments, meaning that the point 1 will be connected with point 2, point 2 with point 3 ..., point n-1 with point n and point n with point 1 in order to close the loop and define a plane.
  57. Member Function Description
  58. ---------------------------
  59. .. _class_Polygon2D_set_polygon:
  60. - void **set_polygon** **(** :ref:`Vector2Array<class_vector2array>` polygon **)**
  61. Defines the set of points that will represent the polygon.
  62. .. _class_Polygon2D_get_polygon:
  63. - :ref:`Vector2Array<class_vector2array>` **get_polygon** **(** **)** const
  64. Returns the set of points that defines this polygon
  65. .. _class_Polygon2D_set_uv:
  66. - void **set_uv** **(** :ref:`Vector2Array<class_vector2array>` uv **)**
  67. Sets the uv value for every point of the polygon
  68. .. _class_Polygon2D_get_uv:
  69. - :ref:`Vector2Array<class_vector2array>` **get_uv** **(** **)** const
  70. Returns the uv value associated with every point of the polygon
  71. .. _class_Polygon2D_set_color:
  72. - void **set_color** **(** :ref:`Color<class_color>` color **)**
  73. Sets the polygon fill color, if the polygon has a texture defined, the defined texture will be tinted to the polygon fill color.
  74. .. _class_Polygon2D_get_color:
  75. - :ref:`Color<class_color>` **get_color** **(** **)** const
  76. Returns the polygon fill color
  77. .. _class_Polygon2D_set_texture:
  78. - void **set_texture** **(** :ref:`Object<class_object>` texture **)**
  79. Sets the polygon texture.
  80. .. _class_Polygon2D_get_texture:
  81. - :ref:`Object<class_object>` **get_texture** **(** **)** const
  82. Returns the polygon texture
  83. .. _class_Polygon2D_set_texture_offset:
  84. - void **set_texture_offset** **(** :ref:`Vector2<class_vector2>` texture_offset **)**
  85. Sets 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.
  86. .. _class_Polygon2D_get_texture_offset:
  87. - :ref:`Vector2<class_vector2>` **get_texture_offset** **(** **)** const
  88. Returns the polygon texture offset
  89. .. _class_Polygon2D_set_texture_rotation:
  90. - void **set_texture_rotation** **(** :ref:`float<class_float>` texture_rotation **)**
  91. Sets the amount of rotation of the polygon texture, ``texture_rotation`` is specified in degrees and clockwise rotation, meaning that if the texture rotation is set to 45 degrees, the texture will be rotated 45 degrees clockwise along the polygon position plus the texture offset.
  92. .. _class_Polygon2D_get_texture_rotation:
  93. - :ref:`float<class_float>` **get_texture_rotation** **(** **)** const
  94. Returns the rotation in degrees of the texture polygon
  95. .. _class_Polygon2D_set_texture_scale:
  96. - void **set_texture_scale** **(** :ref:`Vector2<class_vector2>` texture_scale **)**
  97. .. _class_Polygon2D_get_texture_scale:
  98. - :ref:`Vector2<class_vector2>` **get_texture_scale** **(** **)** const
  99. .. _class_Polygon2D_set_invert:
  100. - void **set_invert** **(** :ref:`bool<class_bool>` invert **)**
  101. Sets the polygon as the defined polygon bounding box minus the defined polygon (the defined polygon will appear as a hole on square that contains the defined polygon).
  102. .. _class_Polygon2D_get_invert:
  103. - :ref:`bool<class_bool>` **get_invert** **(** **)** const
  104. Returns whether this polygon is inverted or not
  105. .. _class_Polygon2D_set_invert_border:
  106. - void **set_invert_border** **(** :ref:`float<class_float>` invert_border **)**
  107. .. _class_Polygon2D_get_invert_border:
  108. - :ref:`float<class_float>` **get_invert_border** **(** **)** const
  109. .. _class_Polygon2D_set_offset:
  110. - void **set_offset** **(** :ref:`Vector2<class_vector2>` offset **)**
  111. Sets the amount of distance from the polygon points from the polygon position, for example 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.
  112. .. _class_Polygon2D_get_offset:
  113. - :ref:`Vector2<class_vector2>` **get_offset** **(** **)** const
  114. Returns the polygon points offset to the polygon position.