2020-02-12 08:59:06 +00:00
<?xml version="1.0" encoding="UTF-8" ?>
2023-07-05 20:07:03 +00:00
<class name= "Texture2D" inherits= "Texture" version= "4.2" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation= "../class.xsd" >
2020-02-12 08:59:06 +00:00
<brief_description >
Texture for 2D and 3D.
</brief_description>
<description >
2020-03-30 16:22:57 +00:00
A texture works by registering an image in the video hardware, which then can be used in 3D models or 2D [Sprite2D] or GUI [Control].
2020-02-12 08:59:06 +00:00
Textures are often created by loading them from a file. See [method @GDScript.load].
[Texture2D] is a base for other resources. It cannot be used directly.
2020-09-29 14:27:13 +00:00
[b]Note:[/b] The maximum texture size is 16384× 16384 pixels due to graphics hardware limitations. Larger textures may fail to import.
2020-02-12 08:59:06 +00:00
</description>
<tutorials >
</tutorials>
<methods >
2022-03-10 07:17:38 +00:00
<method name= "_draw" qualifiers= "virtual const" >
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "to_canvas_item" type= "RID" />
<param index= "1" name= "pos" type= "Vector2" />
<param index= "2" name= "modulate" type= "Color" />
<param index= "3" name= "transpose" type= "bool" />
2022-03-10 07:17:38 +00:00
<description >
2022-10-24 21:19:32 +00:00
Called when the entire [Texture2D] is requested to be drawn over a [CanvasItem], with the top-left offset specified in [param pos]. [param modulate] specifies a multiplier for the colors being drawn, while [param transpose] specifies whether drawing should be performed in column-major order instead of row-major order (resulting in 90-degree clockwise rotation).
[b]Note:[/b] This is only used in 2D rendering, not 3D.
2022-03-10 07:17:38 +00:00
</description>
</method>
<method name= "_draw_rect" qualifiers= "virtual const" >
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "to_canvas_item" type= "RID" />
<param index= "1" name= "rect" type= "Rect2" />
<param index= "2" name= "tile" type= "bool" />
<param index= "3" name= "modulate" type= "Color" />
<param index= "4" name= "transpose" type= "bool" />
2022-03-10 07:17:38 +00:00
<description >
2022-10-24 21:19:32 +00:00
Called when the [Texture2D] is requested to be drawn onto [CanvasItem]'s specified [param rect]. [param modulate] specifies a multiplier for the colors being drawn, while [param transpose] specifies whether drawing should be performed in column-major order instead of row-major order (resulting in 90-degree clockwise rotation).
[b]Note:[/b] This is only used in 2D rendering, not 3D.
2022-03-10 07:17:38 +00:00
</description>
</method>
<method name= "_draw_rect_region" qualifiers= "virtual const" >
<return type= "void" />
2022-10-20 19:04:45 +00:00
<param index= "0" name= "to_canvas_item" type= "RID" />
2022-08-06 18:11:48 +00:00
<param index= "1" name= "rect" type= "Rect2" />
<param index= "2" name= "src_rect" type= "Rect2" />
<param index= "3" name= "modulate" type= "Color" />
<param index= "4" name= "transpose" type= "bool" />
<param index= "5" name= "clip_uv" type= "bool" />
2022-03-10 07:17:38 +00:00
<description >
2022-10-24 21:19:32 +00:00
Called when a part of the [Texture2D] specified by [param src_rect]'s coordinates is requested to be drawn onto [CanvasItem]'s specified [param rect]. [param modulate] specifies a multiplier for the colors being drawn, while [param transpose] specifies whether drawing should be performed in column-major order instead of row-major order (resulting in 90-degree clockwise rotation).
[b]Note:[/b] This is only used in 2D rendering, not 3D.
2022-03-10 07:17:38 +00:00
</description>
</method>
<method name= "_get_height" qualifiers= "virtual const" >
<return type= "int" />
<description >
2022-10-24 21:19:32 +00:00
Called when the [Texture2D]'s height is queried.
2022-03-10 07:17:38 +00:00
</description>
</method>
<method name= "_get_width" qualifiers= "virtual const" >
<return type= "int" />
<description >
2022-10-24 21:19:32 +00:00
Called when the [Texture2D]'s width is queried.
2022-03-10 07:17:38 +00:00
</description>
</method>
<method name= "_has_alpha" qualifiers= "virtual const" >
<return type= "bool" />
<description >
2022-10-24 21:19:32 +00:00
Called when the presence of an alpha channel in the [Texture2D] is queried.
2022-03-10 07:17:38 +00:00
</description>
</method>
<method name= "_is_pixel_opaque" qualifiers= "virtual const" >
<return type= "bool" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "x" type= "int" />
<param index= "1" name= "y" type= "int" />
2022-03-10 07:17:38 +00:00
<description >
2022-10-24 21:19:32 +00:00
Called when a pixel's opaque state in the [Texture2D] is queried at the specified [code](x, y)[/code] position.
2022-03-10 07:17:38 +00:00
</description>
</method>
2022-12-20 21:49:11 +00:00
<method name= "create_placeholder" qualifiers= "const" >
<return type= "Resource" />
<description >
Creates a placeholder version of this resource ([PlaceholderTexture2D]).
</description>
</method>
2020-02-12 08:59:06 +00:00
<method name= "draw" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "canvas_item" type= "RID" />
<param index= "1" name= "position" type= "Vector2" />
<param index= "2" name= "modulate" type= "Color" default= "Color(1, 1, 1, 1)" />
<param index= "3" name= "transpose" type= "bool" default= "false" />
2020-02-12 08:59:06 +00:00
<description >
2022-08-09 15:19:47 +00:00
Draws the texture using a [CanvasItem] with the [RenderingServer] API at the specified [param position].
2020-02-12 08:59:06 +00:00
</description>
</method>
<method name= "draw_rect" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "canvas_item" type= "RID" />
<param index= "1" name= "rect" type= "Rect2" />
<param index= "2" name= "tile" type= "bool" />
<param index= "3" name= "modulate" type= "Color" default= "Color(1, 1, 1, 1)" />
<param index= "4" name= "transpose" type= "bool" default= "false" />
2020-02-12 08:59:06 +00:00
<description >
2020-03-30 16:22:57 +00:00
Draws the texture using a [CanvasItem] with the [RenderingServer] API.
2020-02-12 08:59:06 +00:00
</description>
</method>
<method name= "draw_rect_region" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "canvas_item" type= "RID" />
<param index= "1" name= "rect" type= "Rect2" />
<param index= "2" name= "src_rect" type= "Rect2" />
<param index= "3" name= "modulate" type= "Color" default= "Color(1, 1, 1, 1)" />
<param index= "4" name= "transpose" type= "bool" default= "false" />
<param index= "5" name= "clip_uv" type= "bool" default= "true" />
2020-02-12 08:59:06 +00:00
<description >
2020-03-30 16:22:57 +00:00
Draws a part of the texture using a [CanvasItem] with the [RenderingServer] API.
2020-02-12 08:59:06 +00:00
</description>
</method>
2021-04-04 20:25:40 +00:00
<method name= "get_height" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
2020-02-12 08:59:06 +00:00
<description >
2022-10-24 21:19:32 +00:00
Returns the texture height in pixels.
2020-02-12 08:59:06 +00:00
</description>
</method>
2021-04-04 20:25:40 +00:00
<method name= "get_image" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Image" />
2020-02-12 08:59:06 +00:00
<description >
2022-05-22 15:44:19 +00:00
Returns an [Image] that is a copy of data from this [Texture2D] (a new [Image] is created each time). [Image]s can be accessed and manipulated directly.
[b]Note:[/b] This will fetch the texture data from the GPU, which might cause performance problems when overused.
2020-02-12 08:59:06 +00:00
</description>
</method>
<method name= "get_size" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Vector2" />
2020-02-12 08:59:06 +00:00
<description >
2022-10-24 21:19:32 +00:00
Returns the texture size in pixels.
2020-02-12 08:59:06 +00:00
</description>
</method>
<method name= "get_width" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
2020-02-12 08:59:06 +00:00
<description >
2022-10-24 21:19:32 +00:00
Returns the texture width in pixels.
2020-02-12 08:59:06 +00:00
</description>
</method>
<method name= "has_alpha" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
2020-02-12 08:59:06 +00:00
<description >
Returns [code]true[/code] if this [Texture2D] has an alpha channel.
</description>
</method>
</methods>
</class>