summaryrefslogtreecommitdiff
path: root/doc/classes/ImageTexture.xml
diff options
context:
space:
mode:
Diffstat (limited to 'doc/classes/ImageTexture.xml')
-rw-r--r--doc/classes/ImageTexture.xml26
1 files changed, 16 insertions, 10 deletions
diff --git a/doc/classes/ImageTexture.xml b/doc/classes/ImageTexture.xml
index aecb4fc4b6..084bf7e809 100644
--- a/doc/classes/ImageTexture.xml
+++ b/doc/classes/ImageTexture.xml
@@ -6,10 +6,8 @@
<description>
A [Texture2D] based on an [Image]. For an image to be displayed, an [ImageTexture] has to be created from it using the [method create_from_image] method:
[codeblock]
- var texture = ImageTexture.new()
- var image = Image.new()
- image.load("res://icon.png")
- texture.create_from_image(image)
+ var image = Image.load_from_file("res://icon.png")
+ var texture = ImageTexture.create_from_image(image)
$Sprite2D.texture = texture
[/codeblock]
This way, textures can be created at run-time by loading images both from within the editor and externally.
@@ -31,11 +29,11 @@
<link title="Importing images">$DOCS_URL/tutorials/assets_pipeline/importing_images.html</link>
</tutorials>
<methods>
- <method name="create_from_image">
- <return type="void" />
+ <method name="create_from_image" qualifiers="static">
+ <return type="ImageTexture" />
<argument index="0" name="image" type="Image" />
<description>
- Initializes the texture by allocating and setting the data from an [Image].
+ Creates a new [ImageTexture] and initializes it by allocating and setting the data from an [Image].
</description>
</method>
<method name="get_format" qualifiers="const">
@@ -44,9 +42,17 @@
Returns the format of the texture, one of [enum Image.Format].
</description>
</method>
+ <method name="set_image">
+ <return type="void" />
+ <argument index="0" name="image" type="Image" />
+ <description>
+ Replaces the texture's data with a new [Image]. This will re-allocate new memory for the texture.
+ If you want to update the image, but don't need to change its parameters (format, size), use [method update] instead for better performance.
+ </description>
+ </method>
<method name="set_size_override">
<return type="void" />
- <argument index="0" name="size" type="Vector2" />
+ <argument index="0" name="size" type="Vector2i" />
<description>
Resizes the texture to the specified dimensions.
</description>
@@ -56,8 +62,8 @@
<argument index="0" name="image" type="Image" />
<description>
Replaces the texture's data with a new [Image].
- [b]Note:[/b] The texture has to be initialized first with the [method create_from_image] method before it can be updated. The new image dimensions, format, and mipmaps configuration should match the existing texture's image configuration, otherwise it has to be re-created with the [method create_from_image] method.
- Use this method over [method create_from_image] if you need to update the texture frequently, which is faster than allocating additional memory for a new texture each time.
+ [b]Note:[/b] The texture has to be created using [method create_from_image] or initialized first with the [method set_image] method before it can be updated. The new image dimensions, format, and mipmaps configuration should match the existing texture's image configuration.
+ Use this method over [method set_image] if you need to update the texture frequently, which is faster than allocating additional memory for a new texture each time.
</description>
</method>
</methods>