:github_url: hide .. Generated automatically by doc/tools/makerst.py in Godot's source tree. .. DO NOT EDIT THIS FILE, but the Texture2D.xml source instead. .. The source is found in doc/classes or modules//doc_classes. .. _class_Texture2D: Texture2D ========= **Inherits:** :ref:`Texture` **<** :ref:`Resource` **<** :ref:`Reference` **<** :ref:`Object` **Inherited By:** :ref:`AnimatedTexture`, :ref:`AtlasTexture`, :ref:`CameraTexture`, :ref:`CurveTexture`, :ref:`GradientTexture`, :ref:`ImageTexture`, :ref:`LargeTexture`, :ref:`MeshTexture`, :ref:`NoiseTexture`, :ref:`ProxyTexture`, :ref:`StreamTexture`, :ref:`ViewportTexture` Texture for 2D and 3D. 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`. ``Texture2D`` is a base for other resources. It cannot be used directly. Methods ------- +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`draw` **(** :ref:`RID` canvas_item, :ref:`Vector2` position, :ref:`Color` modulate=Color( 1, 1, 1, 1 ), :ref:`bool` transpose=false, :ref:`Texture2D` normal_map=null, :ref:`Texture2D` specular_map=null, :ref:`Color` specular_color_shininess=Color( 1, 1, 1, 1 ), :ref:`CanvasItemTextureFilter` texture_filter=0, :ref:`CanvasItemTextureRepeat` texture_repeat=0 **)** 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:`Texture2D` normal_map=null, :ref:`Texture2D` specular_map=null, :ref:`Color` specular_color_shininess=Color( 1, 1, 1, 1 ), :ref:`CanvasItemTextureFilter` texture_filter=0, :ref:`CanvasItemTextureRepeat` texture_repeat=0 **)** 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:`Texture2D` normal_map=null, :ref:`Texture2D` specular_map=null, :ref:`Color` specular_color_shininess=Color( 1, 1, 1, 1 ), :ref:`CanvasItemTextureFilter` texture_filter=0, :ref:`CanvasItemTextureRepeat` texture_repeat=0, :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 | +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ Method Descriptions ------------------- .. _class_Texture2D_method_draw: - void **draw** **(** :ref:`RID` canvas_item, :ref:`Vector2` position, :ref:`Color` modulate=Color( 1, 1, 1, 1 ), :ref:`bool` transpose=false, :ref:`Texture2D` normal_map=null, :ref:`Texture2D` specular_map=null, :ref:`Color` specular_color_shininess=Color( 1, 1, 1, 1 ), :ref:`CanvasItemTextureFilter` texture_filter=0, :ref:`CanvasItemTextureRepeat` texture_repeat=0 **)** const Draws the texture using a :ref:`CanvasItem` with the :ref:`VisualServer` API at the specified ``position``. ---- .. _class_Texture2D_method_draw_rect: - 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:`Texture2D` normal_map=null, :ref:`Texture2D` specular_map=null, :ref:`Color` specular_color_shininess=Color( 1, 1, 1, 1 ), :ref:`CanvasItemTextureFilter` texture_filter=0, :ref:`CanvasItemTextureRepeat` texture_repeat=0 **)** const Draws the texture using a :ref:`CanvasItem` with the :ref:`VisualServer` API. ---- .. _class_Texture2D_method_draw_rect_region: - 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:`Texture2D` normal_map=null, :ref:`Texture2D` specular_map=null, :ref:`Color` specular_color_shininess=Color( 1, 1, 1, 1 ), :ref:`CanvasItemTextureFilter` texture_filter=0, :ref:`CanvasItemTextureRepeat` texture_repeat=0, :ref:`bool` clip_uv=true **)** const Draws a part of the texture using a :ref:`CanvasItem` with the :ref:`VisualServer` API. ---- .. _class_Texture2D_method_get_data: - :ref:`Image` **get_data** **(** **)** const Returns an :ref:`Image` with the data from this ``Texture2D``. :ref:`Image`\ s can be accessed and manipulated directly. ---- .. _class_Texture2D_method_get_height: - :ref:`int` **get_height** **(** **)** const Returns the texture height. ---- .. _class_Texture2D_method_get_size: - :ref:`Vector2` **get_size** **(** **)** const Returns the texture size. ---- .. _class_Texture2D_method_get_width: - :ref:`int` **get_width** **(** **)** const Returns the texture width. ---- .. _class_Texture2D_method_has_alpha: - :ref:`bool` **has_alpha** **(** **)** const Returns ``true`` if this ``Texture2D`` has an alpha channel.