mirror of
https://github.com/godotengine/godot-docs.git
synced 2025-12-31 17:49:03 +03:00
155 lines
12 KiB
ReStructuredText
155 lines
12 KiB
ReStructuredText
.. Generated automatically by doc/tools/makerst.py in Godot's source tree.
|
|
.. DO NOT EDIT THIS FILE, but the Texture.xml source instead.
|
|
.. The source is found in doc/classes or modules/<name>/doc_classes.
|
|
|
|
.. _class_Texture:
|
|
|
|
Texture
|
|
=======
|
|
|
|
**Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
|
|
|
|
**Inherited By:** :ref:`AnimatedTexture<class_AnimatedTexture>`, :ref:`AtlasTexture<class_AtlasTexture>`, :ref:`CameraTexture<class_CameraTexture>`, :ref:`CurveTexture<class_CurveTexture>`, :ref:`GradientTexture<class_GradientTexture>`, :ref:`ImageTexture<class_ImageTexture>`, :ref:`LargeTexture<class_LargeTexture>`, :ref:`MeshTexture<class_MeshTexture>`, :ref:`NoiseTexture<class_NoiseTexture>`, :ref:`ProxyTexture<class_ProxyTexture>`, :ref:`StreamTexture<class_StreamTexture>`, :ref:`ViewportTexture<class_ViewportTexture>`
|
|
|
|
**Category:** Core
|
|
|
|
Brief Description
|
|
-----------------
|
|
|
|
Texture for 2D and 3D.
|
|
|
|
Properties
|
|
----------
|
|
|
|
+-----------------------+--------------------------------------------+---+
|
|
| :ref:`int<class_int>` | :ref:`flags<class_Texture_property_flags>` | 4 |
|
|
+-----------------------+--------------------------------------------+---+
|
|
|
|
Methods
|
|
-------
|
|
|
|
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`draw<class_Texture_method_draw>` **(** :ref:`RID<class_RID>` canvas_item, :ref:`Vector2<class_Vector2>` position, :ref:`Color<class_Color>` modulate=Color( 1, 1, 1, 1 ), :ref:`bool<class_bool>` transpose=false, :ref:`Texture<class_Texture>` normal_map=null **)** const |
|
|
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`draw_rect<class_Texture_method_draw_rect>` **(** :ref:`RID<class_RID>` canvas_item, :ref:`Rect2<class_Rect2>` rect, :ref:`bool<class_bool>` tile, :ref:`Color<class_Color>` modulate=Color( 1, 1, 1, 1 ), :ref:`bool<class_bool>` transpose=false, :ref:`Texture<class_Texture>` normal_map=null **)** const |
|
|
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`draw_rect_region<class_Texture_method_draw_rect_region>` **(** :ref:`RID<class_RID>` canvas_item, :ref:`Rect2<class_Rect2>` rect, :ref:`Rect2<class_Rect2>` src_rect, :ref:`Color<class_Color>` modulate=Color( 1, 1, 1, 1 ), :ref:`bool<class_bool>` transpose=false, :ref:`Texture<class_Texture>` normal_map=null, :ref:`bool<class_bool>` clip_uv=true **)** const |
|
|
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Image<class_Image>` | :ref:`get_data<class_Texture_method_get_data>` **(** **)** const |
|
|
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`get_height<class_Texture_method_get_height>` **(** **)** const |
|
|
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Vector2<class_Vector2>` | :ref:`get_size<class_Texture_method_get_size>` **(** **)** const |
|
|
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`get_width<class_Texture_method_get_width>` **(** **)** const |
|
|
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`has_alpha<class_Texture_method_has_alpha>` **(** **)** const |
|
|
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
Enumerations
|
|
------------
|
|
|
|
.. _enum_Texture_Flags:
|
|
|
|
.. _class_Texture_constant_FLAGS_DEFAULT:
|
|
|
|
.. _class_Texture_constant_FLAG_MIPMAPS:
|
|
|
|
.. _class_Texture_constant_FLAG_REPEAT:
|
|
|
|
.. _class_Texture_constant_FLAG_FILTER:
|
|
|
|
.. _class_Texture_constant_FLAG_ANISOTROPIC_FILTER:
|
|
|
|
.. _class_Texture_constant_FLAG_CONVERT_TO_LINEAR:
|
|
|
|
.. _class_Texture_constant_FLAG_MIRRORED_REPEAT:
|
|
|
|
.. _class_Texture_constant_FLAG_VIDEO_SURFACE:
|
|
|
|
enum **Flags**:
|
|
|
|
- **FLAGS_DEFAULT** = **7** --- Default flags. :ref:`FLAG_MIPMAPS<class_Texture_constant_FLAG_MIPMAPS>`, :ref:`FLAG_REPEAT<class_Texture_constant_FLAG_REPEAT>` and :ref:`FLAG_FILTER<class_Texture_constant_FLAG_FILTER>` are enabled.
|
|
|
|
- **FLAG_MIPMAPS** = **1** --- Generates mipmaps, which are smaller versions of the same texture to use when zoomed out, keeping the aspect ratio.
|
|
|
|
- **FLAG_REPEAT** = **2** --- Repeats the texture (instead of clamp to edge).
|
|
|
|
- **FLAG_FILTER** = **4** --- Uses a magnifying filter, to enable smooth zooming in of the texture.
|
|
|
|
- **FLAG_ANISOTROPIC_FILTER** = **8** --- Uses anisotropic mipmap filtering. Generates smaller versions of the same texture with different aspect ratios.
|
|
|
|
This results in better-looking textures when viewed from oblique angles.
|
|
|
|
- **FLAG_CONVERT_TO_LINEAR** = **16** --- Converts the texture to the sRGB color space.
|
|
|
|
- **FLAG_MIRRORED_REPEAT** = **32** --- Repeats the texture with alternate sections mirrored.
|
|
|
|
- **FLAG_VIDEO_SURFACE** = **2048** --- Texture is a video surface.
|
|
|
|
Description
|
|
-----------
|
|
|
|
A texture works by registering an image in the video hardware, which then can be used in 3D models or 2D :ref:`Sprite<class_Sprite>` or GUI :ref:`Control<class_Control>`.
|
|
|
|
Textures are often created by loading them from a file. See :ref:`@GDScript.load<class_@GDScript_method_load>`.
|
|
|
|
Property Descriptions
|
|
---------------------
|
|
|
|
.. _class_Texture_property_flags:
|
|
|
|
- :ref:`int<class_int>` **flags**
|
|
|
|
+-----------+------------------+
|
|
| *Default* | 4 |
|
|
+-----------+------------------+
|
|
| *Setter* | set_flags(value) |
|
|
+-----------+------------------+
|
|
| *Getter* | get_flags() |
|
|
+-----------+------------------+
|
|
|
|
The texture's flags.
|
|
|
|
Method Descriptions
|
|
-------------------
|
|
|
|
.. _class_Texture_method_draw:
|
|
|
|
- void **draw** **(** :ref:`RID<class_RID>` canvas_item, :ref:`Vector2<class_Vector2>` position, :ref:`Color<class_Color>` modulate=Color( 1, 1, 1, 1 ), :ref:`bool<class_bool>` transpose=false, :ref:`Texture<class_Texture>` normal_map=null **)** const
|
|
|
|
.. _class_Texture_method_draw_rect:
|
|
|
|
- void **draw_rect** **(** :ref:`RID<class_RID>` canvas_item, :ref:`Rect2<class_Rect2>` rect, :ref:`bool<class_bool>` tile, :ref:`Color<class_Color>` modulate=Color( 1, 1, 1, 1 ), :ref:`bool<class_bool>` transpose=false, :ref:`Texture<class_Texture>` normal_map=null **)** const
|
|
|
|
.. _class_Texture_method_draw_rect_region:
|
|
|
|
- void **draw_rect_region** **(** :ref:`RID<class_RID>` canvas_item, :ref:`Rect2<class_Rect2>` rect, :ref:`Rect2<class_Rect2>` src_rect, :ref:`Color<class_Color>` modulate=Color( 1, 1, 1, 1 ), :ref:`bool<class_bool>` transpose=false, :ref:`Texture<class_Texture>` normal_map=null, :ref:`bool<class_bool>` clip_uv=true **)** const
|
|
|
|
.. _class_Texture_method_get_data:
|
|
|
|
- :ref:`Image<class_Image>` **get_data** **(** **)** const
|
|
|
|
.. _class_Texture_method_get_height:
|
|
|
|
- :ref:`int<class_int>` **get_height** **(** **)** const
|
|
|
|
Returns the texture height.
|
|
|
|
.. _class_Texture_method_get_size:
|
|
|
|
- :ref:`Vector2<class_Vector2>` **get_size** **(** **)** const
|
|
|
|
Returns the texture size.
|
|
|
|
.. _class_Texture_method_get_width:
|
|
|
|
- :ref:`int<class_int>` **get_width** **(** **)** const
|
|
|
|
Returns the texture width.
|
|
|
|
.. _class_Texture_method_has_alpha:
|
|
|
|
- :ref:`bool<class_bool>` **has_alpha** **(** **)** const
|
|
|