:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/Texture.xml. .. _class_Texture: Texture ======= **Inherits:** :ref:`Resource` **<** :ref:`Reference` **<** :ref:`Object` **Inherited By:** :ref:`AnimatedTexture`, :ref:`AtlasTexture`, :ref:`CameraTexture`, :ref:`CurveTexture`, :ref:`ExternalTexture`, :ref:`GradientTexture`, :ref:`GradientTexture2D`, :ref:`ImageTexture`, :ref:`LargeTexture`, :ref:`MeshTexture`, :ref:`NoiseTexture`, :ref:`ProxyTexture`, :ref:`StreamTexture`, :ref:`ViewportTexture` Texture for 2D and 3D. .. rst-class:: classref-introduction-group Description ----------- A texture works by registering an image in the video hardware, which then can be used in 3D models or 2D :ref:`Sprite` or GUI :ref:`Control`. Textures are often created by loading them from a file. See :ref:`@GDScript.load`. \ **Texture** is a base for other resources. It cannot be used directly. \ **Note:** The maximum texture size is 16384×16384 pixels due to graphics hardware limitations. Larger textures may fail to import. .. rst-class:: classref-reftable-group Properties ---------- .. table:: :widths: auto +-----------------------+--------------------------------------------+-------+ | :ref:`int` | :ref:`flags` | ``4`` | +-----------------------+--------------------------------------------+-------+ .. rst-class:: classref-reftable-group Methods ------- .. table:: :widths: auto +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`draw` **(** :ref:`RID` canvas_item, :ref:`Vector2` position, :ref:`Color` modulate=Color( 1, 1, 1, 1 ), :ref:`bool` transpose=false, :ref:`Texture` normal_map=null **)** |const| | +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`draw_rect` **(** :ref:`RID` canvas_item, :ref:`Rect2` rect, :ref:`bool` tile, :ref:`Color` modulate=Color( 1, 1, 1, 1 ), :ref:`bool` transpose=false, :ref:`Texture` normal_map=null **)** |const| | +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`draw_rect_region` **(** :ref:`RID` canvas_item, :ref:`Rect2` rect, :ref:`Rect2` src_rect, :ref:`Color` modulate=Color( 1, 1, 1, 1 ), :ref:`bool` transpose=false, :ref:`Texture` normal_map=null, :ref:`bool` clip_uv=true **)** |const| | +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Image` | :ref:`get_data` **(** **)** |const| | +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_height` **(** **)** |const| | +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`get_size` **(** **)** |const| | +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_width` **(** **)** |const| | +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`has_alpha` **(** **)** |const| | +-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Enumerations ------------ .. _enum_Texture_Flags: .. rst-class:: classref-enumeration enum **Flags**: .. _class_Texture_constant_FLAGS_DEFAULT: .. rst-class:: classref-enumeration-constant :ref:`Flags` **FLAGS_DEFAULT** = ``7`` Default flags. :ref:`FLAG_MIPMAPS`, :ref:`FLAG_REPEAT` and :ref:`FLAG_FILTER` are enabled. .. _class_Texture_constant_FLAG_MIPMAPS: .. rst-class:: classref-enumeration-constant :ref:`Flags` **FLAG_MIPMAPS** = ``1`` Generates mipmaps, which are smaller versions of the same texture to use when zoomed out, keeping the aspect ratio. .. _class_Texture_constant_FLAG_REPEAT: .. rst-class:: classref-enumeration-constant :ref:`Flags` **FLAG_REPEAT** = ``2`` Repeats the texture (instead of clamp to edge). \ **Note:** Ignored when using an :ref:`AtlasTexture` as these don't support repetition. .. _class_Texture_constant_FLAG_FILTER: .. rst-class:: classref-enumeration-constant :ref:`Flags` **FLAG_FILTER** = ``4`` Uses a magnifying filter, to enable smooth zooming in of the texture. .. _class_Texture_constant_FLAG_ANISOTROPIC_FILTER: .. rst-class:: classref-enumeration-constant :ref:`Flags` **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. .. _class_Texture_constant_FLAG_CONVERT_TO_LINEAR: .. rst-class:: classref-enumeration-constant :ref:`Flags` **FLAG_CONVERT_TO_LINEAR** = ``16`` Converts the texture to the sRGB color space. .. _class_Texture_constant_FLAG_MIRRORED_REPEAT: .. rst-class:: classref-enumeration-constant :ref:`Flags` **FLAG_MIRRORED_REPEAT** = ``32`` Repeats the texture with alternate sections mirrored. \ **Note:** Ignored when using an :ref:`AtlasTexture` as these don't support repetition. .. _class_Texture_constant_FLAG_VIDEO_SURFACE: .. rst-class:: classref-enumeration-constant :ref:`Flags` **FLAG_VIDEO_SURFACE** = ``2048`` Texture is a video surface. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Property Descriptions --------------------- .. _class_Texture_property_flags: .. rst-class:: classref-property :ref:`int` **flags** = ``4`` .. rst-class:: classref-property-setget - void **set_flags** **(** :ref:`int` value **)** - :ref:`int` **get_flags** **(** **)** The texture's :ref:`Flags`. :ref:`Flags` are used to set various properties of the **Texture**. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Method Descriptions ------------------- .. _class_Texture_method_draw: .. rst-class:: classref-method void **draw** **(** :ref:`RID` canvas_item, :ref:`Vector2` position, :ref:`Color` modulate=Color( 1, 1, 1, 1 ), :ref:`bool` transpose=false, :ref:`Texture` normal_map=null **)** |const| Draws the texture using a :ref:`CanvasItem` with the :ref:`VisualServer` API at the specified ``position``. Equivalent to :ref:`VisualServer.canvas_item_add_texture_rect` with a rect at ``position`` and the size of this **Texture**. .. rst-class:: classref-item-separator ---- .. _class_Texture_method_draw_rect: .. rst-class:: classref-method void **draw_rect** **(** :ref:`RID` canvas_item, :ref:`Rect2` rect, :ref:`bool` tile, :ref:`Color` modulate=Color( 1, 1, 1, 1 ), :ref:`bool` transpose=false, :ref:`Texture` normal_map=null **)** |const| Draws the texture using a :ref:`CanvasItem` with the :ref:`VisualServer` API. Equivalent to :ref:`VisualServer.canvas_item_add_texture_rect`. .. rst-class:: classref-item-separator ---- .. _class_Texture_method_draw_rect_region: .. rst-class:: classref-method void **draw_rect_region** **(** :ref:`RID` canvas_item, :ref:`Rect2` rect, :ref:`Rect2` src_rect, :ref:`Color` modulate=Color( 1, 1, 1, 1 ), :ref:`bool` transpose=false, :ref:`Texture` normal_map=null, :ref:`bool` clip_uv=true **)** |const| Draws a part of the texture using a :ref:`CanvasItem` with the :ref:`VisualServer` API. Equivalent to :ref:`VisualServer.canvas_item_add_texture_rect_region`. .. rst-class:: classref-item-separator ---- .. _class_Texture_method_get_data: .. rst-class:: classref-method :ref:`Image` **get_data** **(** **)** |const| Returns an :ref:`Image` that is a copy of data from this **Texture**. :ref:`Image`\ s can be accessed and manipulated directly. .. rst-class:: classref-item-separator ---- .. _class_Texture_method_get_height: .. rst-class:: classref-method :ref:`int` **get_height** **(** **)** |const| Returns the texture height. .. rst-class:: classref-item-separator ---- .. _class_Texture_method_get_size: .. rst-class:: classref-method :ref:`Vector2` **get_size** **(** **)** |const| Returns the texture size. .. rst-class:: classref-item-separator ---- .. _class_Texture_method_get_width: .. rst-class:: classref-method :ref:`int` **get_width** **(** **)** |const| Returns the texture width. .. rst-class:: classref-item-separator ---- .. _class_Texture_method_has_alpha: .. rst-class:: classref-method :ref:`bool` **has_alpha** **(** **)** |const| Returns ``true`` if this **Texture** has an alpha channel. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`