Files
godot-docs/classes/class_polygon2d.rst
2017-10-11 23:56:28 +02:00

237 lines
17 KiB
ReStructuredText

.. Generated automatically by doc/tools/makerst.py in Godot's source tree.
.. DO NOT EDIT THIS FILE, but the Polygon2D.xml source instead.
.. The source is found in doc/classes or modules/<name>/doc_classes.
.. _class_Polygon2D:
Polygon2D
=========
**Inherits:** :ref:`Node2D<class_node2d>` **<** :ref:`CanvasItem<class_canvasitem>` **<** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
**Category:** Core
Brief Description
-----------------
A 2D polygon.
Member Functions
----------------
+--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`get_antialiased<class_Polygon2D_get_antialiased>` **(** **)** const |
+--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Color<class_color>` | :ref:`get_color<class_Polygon2D_get_color>` **(** **)** const |
+--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`get_invert<class_Polygon2D_get_invert>` **(** **)** const |
+--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`float<class_float>` | :ref:`get_invert_border<class_Polygon2D_get_invert_border>` **(** **)** const |
+--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Vector2<class_vector2>` | :ref:`get_offset<class_Polygon2D_get_offset>` **(** **)** const |
+--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`PoolVector2Array<class_poolvector2array>` | :ref:`get_polygon<class_Polygon2D_get_polygon>` **(** **)** const |
+--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Texture<class_texture>` | :ref:`get_texture<class_Polygon2D_get_texture>` **(** **)** const |
+--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Vector2<class_vector2>` | :ref:`get_texture_offset<class_Polygon2D_get_texture_offset>` **(** **)** const |
+--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`float<class_float>` | :ref:`get_texture_rotation<class_Polygon2D_get_texture_rotation>` **(** **)** const |
+--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Vector2<class_vector2>` | :ref:`get_texture_scale<class_Polygon2D_get_texture_scale>` **(** **)** const |
+--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`PoolVector2Array<class_poolvector2array>` | :ref:`get_uv<class_Polygon2D_get_uv>` **(** **)** const |
+--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`PoolColorArray<class_poolcolorarray>` | :ref:`get_vertex_colors<class_Polygon2D_get_vertex_colors>` **(** **)** const |
+--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_antialiased<class_Polygon2D_set_antialiased>` **(** :ref:`bool<class_bool>` antialiased **)** |
+--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_color<class_Polygon2D_set_color>` **(** :ref:`Color<class_color>` color **)** |
+--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_invert<class_Polygon2D_set_invert>` **(** :ref:`bool<class_bool>` invert **)** |
+--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_invert_border<class_Polygon2D_set_invert_border>` **(** :ref:`float<class_float>` invert_border **)** |
+--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_offset<class_Polygon2D_set_offset>` **(** :ref:`Vector2<class_vector2>` offset **)** |
+--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_polygon<class_Polygon2D_set_polygon>` **(** :ref:`PoolVector2Array<class_poolvector2array>` polygon **)** |
+--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_texture<class_Polygon2D_set_texture>` **(** :ref:`Texture<class_texture>` texture **)** |
+--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_texture_offset<class_Polygon2D_set_texture_offset>` **(** :ref:`Vector2<class_vector2>` texture_offset **)** |
+--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_texture_rotation<class_Polygon2D_set_texture_rotation>` **(** :ref:`float<class_float>` texture_rotation **)** |
+--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_texture_scale<class_Polygon2D_set_texture_scale>` **(** :ref:`Vector2<class_vector2>` texture_scale **)** |
+--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_uv<class_Polygon2D_set_uv>` **(** :ref:`PoolVector2Array<class_poolvector2array>` uv **)** |
+--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_vertex_colors<class_Polygon2D_set_vertex_colors>` **(** :ref:`PoolColorArray<class_poolcolorarray>` vertex_colors **)** |
+--------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
Member Variables
----------------
- :ref:`bool<class_bool>` **antialiased** - If [code]true[/code] polygon edges will be anti-aliased. Default value: [code]false[/code].
- :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].
- :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].
- :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].
- :ref:`Vector2<class_vector2>` **offset** - The offset applied to each vertex.
- :ref:`PoolVector2Array<class_poolvector2array>` **polygon** - The polygon's list of vertices. The final point will be connected to the first.
- :ref:`Texture<class_texture>` **texture** - The polygon's fill texture. Use [code]uv[/code] to set texture coordinates.
- :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].
- :ref:`float<class_float>` **texture_rotation** - The texture's rotation in degrees.
- :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.
- :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].
- :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].
Description
-----------
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.
Member Function Description
---------------------------
.. _class_Polygon2D_get_antialiased:
- :ref:`bool<class_bool>` **get_antialiased** **(** **)** const
.. _class_Polygon2D_get_color:
- :ref:`Color<class_color>` **get_color** **(** **)** const
Return the polygon fill color.
.. _class_Polygon2D_get_invert:
- :ref:`bool<class_bool>` **get_invert** **(** **)** const
Return whether this polygon is inverted or not.
.. _class_Polygon2D_get_invert_border:
- :ref:`float<class_float>` **get_invert_border** **(** **)** const
Return the added padding around the bounding box.
.. _class_Polygon2D_get_offset:
- :ref:`Vector2<class_vector2>` **get_offset** **(** **)** const
Return the offset for the polygon vertices.
.. _class_Polygon2D_get_polygon:
- :ref:`PoolVector2Array<class_poolvector2array>` **get_polygon** **(** **)** const
Return the set of vertices that defines this polygon.
.. _class_Polygon2D_get_texture:
- :ref:`Texture<class_texture>` **get_texture** **(** **)** const
Return the polygon texture
.. _class_Polygon2D_get_texture_offset:
- :ref:`Vector2<class_vector2>` **get_texture_offset** **(** **)** const
Return the polygon texture offset.
.. _class_Polygon2D_get_texture_rotation:
- :ref:`float<class_float>` **get_texture_rotation** **(** **)** const
Return the rotation in radians of the texture polygon.
.. _class_Polygon2D_get_texture_scale:
- :ref:`Vector2<class_vector2>` **get_texture_scale** **(** **)** const
Return the uv coordinate multiplier.
.. _class_Polygon2D_get_uv:
- :ref:`PoolVector2Array<class_poolvector2array>` **get_uv** **(** **)** const
Return the texture coordinates associated with every vertex of the polygon.
.. _class_Polygon2D_get_vertex_colors:
- :ref:`PoolColorArray<class_poolcolorarray>` **get_vertex_colors** **(** **)** const
Return the list of vertex colors.
.. _class_Polygon2D_set_antialiased:
- void **set_antialiased** **(** :ref:`bool<class_bool>` antialiased **)**
.. _class_Polygon2D_set_color:
- void **set_color** **(** :ref:`Color<class_color>` color **)**
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>`.
.. _class_Polygon2D_set_invert:
- void **set_invert** **(** :ref:`bool<class_bool>` invert **)**
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).
.. _class_Polygon2D_set_invert_border:
- void **set_invert_border** **(** :ref:`float<class_float>` invert_border **)**
Add extra padding around the bounding box, making it bigger. Too small a value can make the polygon triangulate strangely, due to numerical imprecision.
.. _class_Polygon2D_set_offset:
- void **set_offset** **(** :ref:`Vector2<class_vector2>` offset **)**
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.
.. _class_Polygon2D_set_polygon:
- void **set_polygon** **(** :ref:`PoolVector2Array<class_poolvector2array>` polygon **)**
Define the set of vertices that will represent the polygon.
.. _class_Polygon2D_set_texture:
- void **set_texture** **(** :ref:`Texture<class_texture>` texture **)**
.. _class_Polygon2D_set_texture_offset:
- void **set_texture_offset** **(** :ref:`Vector2<class_vector2>` texture_offset **)**
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.
.. _class_Polygon2D_set_texture_rotation:
- void **set_texture_rotation** **(** :ref:`float<class_float>` texture_rotation **)**
Set the amount of rotation of the polygon texture, ``texture_rotation`` is specified in radians and clockwise rotation.
.. _class_Polygon2D_set_texture_scale:
- void **set_texture_scale** **(** :ref:`Vector2<class_vector2>` texture_scale **)**
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.
.. _class_Polygon2D_set_uv:
- void **set_uv** **(** :ref:`PoolVector2Array<class_poolvector2array>` uv **)**
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.
.. _class_Polygon2D_set_vertex_colors:
- void **set_vertex_colors** **(** :ref:`PoolColorArray<class_poolcolorarray>` vertex_colors **)**
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.
Colors are interpolated between vertices, resulting in smooth gradients when they differ.