Debian Codegraph @

doc/classes/Texture2D.xml

raw symbols SCIP
1 <?xml version="1.0" encoding="UTF-8" ?>
2 <class name="Texture2D" inherits="Texture" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3 <brief_description>
4 Texture for 2D and 3D.
5 </brief_description>
6 <description>
7 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].
8 Textures are often created by loading them from a file. See [method @GDScript.load].
9 [Texture2D] is a base for other resources. It cannot be used directly.
10 [b]Note:[/b] The maximum texture size is 16384×16384 pixels due to graphics hardware limitations. Larger textures may fail to import.
11 </description>
12 <tutorials>
13 </tutorials>
14 <methods>
15 <method name="_draw" qualifiers="virtual const">
16 <return type="void" />
17 <param index="0" name="to_canvas_item" type="RID" />
18 <param index="1" name="pos" type="Vector2" />
19 <param index="2" name="modulate" type="Color" />
20 <param index="3" name="transpose" type="bool" />
21 <description>
22 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).
23 [b]Note:[/b] This is only used in 2D rendering, not 3D.
24 </description>
25 </method>
26 <method name="_draw_rect" qualifiers="virtual const">
27 <return type="void" />
28 <param index="0" name="to_canvas_item" type="RID" />
29 <param index="1" name="rect" type="Rect2" />
30 <param index="2" name="tile" type="bool" />
31 <param index="3" name="modulate" type="Color" />
32 <param index="4" name="transpose" type="bool" />
33 <description>
34 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).
35 [b]Note:[/b] This is only used in 2D rendering, not 3D.
36 </description>
37 </method>
38 <method name="_draw_rect_region" qualifiers="virtual const">
39 <return type="void" />
40 <param index="0" name="to_canvas_item" type="RID" />
41 <param index="1" name="rect" type="Rect2" />
42 <param index="2" name="src_rect" type="Rect2" />
43 <param index="3" name="modulate" type="Color" />
44 <param index="4" name="transpose" type="bool" />
45 <param index="5" name="clip_uv" type="bool" />
46 <description>
47 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).
48 [b]Note:[/b] This is only used in 2D rendering, not 3D.
49 </description>
50 </method>
51 <method name="_get_height" qualifiers="virtual required const">
52 <return type="int" />
53 <description>
54 Called when the [Texture2D]'s height is queried.
55 </description>
56 </method>
57 <method name="_get_width" qualifiers="virtual required const">
58 <return type="int" />
59 <description>
60 Called when the [Texture2D]'s width is queried.
61 </description>
62 </method>
63 <method name="_has_alpha" qualifiers="virtual const">
64 <return type="bool" />
65 <description>
66 Called when the presence of an alpha channel in the [Texture2D] is queried.
67 </description>
68 </method>
69 <method name="_is_pixel_opaque" qualifiers="virtual const">
70 <return type="bool" />
71 <param index="0" name="x" type="int" />
72 <param index="1" name="y" type="int" />
73 <description>
74 Called when a pixel's opaque state in the [Texture2D] is queried at the specified [code](x, y)[/code] position.
75 </description>
76 </method>
77 <method name="create_placeholder" qualifiers="const">
78 <return type="Resource" />
79 <description>
80 Creates a placeholder version of this resource ([PlaceholderTexture2D]).
81 </description>
82 </method>
83 <method name="draw" qualifiers="const">
84 <return type="void" />
85 <param index="0" name="canvas_item" type="RID" />
86 <param index="1" name="position" type="Vector2" />
87 <param index="2" name="modulate" type="Color" default="Color(1, 1, 1, 1)" />
88 <param index="3" name="transpose" type="bool" default="false" />
89 <description>
90 Draws the texture using a [CanvasItem] with the [RenderingServer] API at the specified [param position].
91 </description>
92 </method>
93 <method name="draw_rect" qualifiers="const">
94 <return type="void" />
95 <param index="0" name="canvas_item" type="RID" />
96 <param index="1" name="rect" type="Rect2" />
97 <param index="2" name="tile" type="bool" />
98 <param index="3" name="modulate" type="Color" default="Color(1, 1, 1, 1)" />
99 <param index="4" name="transpose" type="bool" default="false" />
100 <description>
101 Draws the texture using a [CanvasItem] with the [RenderingServer] API.
102 </description>
103 </method>
104 <method name="draw_rect_region" qualifiers="const">
105 <return type="void" />
106 <param index="0" name="canvas_item" type="RID" />
107 <param index="1" name="rect" type="Rect2" />
108 <param index="2" name="src_rect" type="Rect2" />
109 <param index="3" name="modulate" type="Color" default="Color(1, 1, 1, 1)" />
110 <param index="4" name="transpose" type="bool" default="false" />
111 <param index="5" name="clip_uv" type="bool" default="true" />
112 <description>
113 Draws a part of the texture using a [CanvasItem] with the [RenderingServer] API.
114 </description>
115 </method>
116 <method name="get_height" qualifiers="const">
117 <return type="int" />
118 <description>
119 Returns the texture height in pixels.
120 </description>
121 </method>
122 <method name="get_image" qualifiers="const">
123 <return type="Image" />
124 <description>
125 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.
126 [b]Note:[/b] This will return [code]null[/code] if this [Texture2D] is invalid.
127 [b]Note:[/b] This will fetch the texture data from the GPU, which might cause performance problems when overused. Avoid calling [method get_image] every frame, especially on large textures.
128 </description>
129 </method>
130 <method name="get_size" qualifiers="const">
131 <return type="Vector2" />
132 <description>
133 Returns the texture size in pixels.
134 </description>
135 </method>
136 <method name="get_width" qualifiers="const">
137 <return type="int" />
138 <description>
139 Returns the texture width in pixels.
140 </description>
141 </method>
142 <method name="has_alpha" qualifiers="const">
143 <return type="bool" />
144 <description>
145 Returns [code]true[/code] if this [Texture2D] has an alpha channel.
146 </description>
147 </method>
148 </methods>
149 </class>