Texture2D

Inherits: Texture < Resource < Reference < Object

Inherited By: AnimatedTexture, AtlasTexture, CameraTexture, CurveTexture, GradientTexture, ImageTexture, LargeTexture, MeshTexture, NoiseTexture, ProxyTexture, StreamTexture, 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 Sprite or GUI Control.

Textures are often created by loading them from a file. See @GDScript.load.

Texture2D is a base for other resources. It cannot be used directly.

Methods

void

draw ( RID canvas_item, Vector2 position, Color modulate=Color( 1, 1, 1, 1 ), bool transpose=false, Texture2D normal_map=null, Texture2D specular_map=null, Color specular_color_shininess=Color( 1, 1, 1, 1 ), CanvasItemTextureFilter texture_filter=0, CanvasItemTextureRepeat texture_repeat=0 ) const

void

draw_rect ( RID canvas_item, Rect2 rect, bool tile, Color modulate=Color( 1, 1, 1, 1 ), bool transpose=false, Texture2D normal_map=null, Texture2D specular_map=null, Color specular_color_shininess=Color( 1, 1, 1, 1 ), CanvasItemTextureFilter texture_filter=0, CanvasItemTextureRepeat texture_repeat=0 ) const

void

draw_rect_region ( RID canvas_item, Rect2 rect, Rect2 src_rect, Color modulate=Color( 1, 1, 1, 1 ), bool transpose=false, Texture2D normal_map=null, Texture2D specular_map=null, Color specular_color_shininess=Color( 1, 1, 1, 1 ), CanvasItemTextureFilter texture_filter=0, CanvasItemTextureRepeat texture_repeat=0, bool clip_uv=true ) const

Image

get_data ( ) const

int

get_height ( ) const

Vector2

get_size ( ) const

int

get_width ( ) const

bool

has_alpha ( ) const

Method Descriptions

Draws the texture using a CanvasItem with the VisualServer API at the specified position.


Draws the texture using a CanvasItem with the VisualServer API.


Draws a part of the texture using a CanvasItem with the VisualServer API.


  • Image get_data ( ) const

Returns an Image with the data from this Texture2D. Images can be accessed and manipulated directly.


  • int get_height ( ) const

Returns the texture height.


Returns the texture size.


  • int get_width ( ) const

Returns the texture width.


  • bool has_alpha ( ) const

Returns true if this Texture2D has an alpha channel.