GIFTexture
Inherits: Texture2D < Texture < Resource < RefCounted < Object
A self-contained animated Texture2D that decodes, stores, and plays a GIF.
Description
GIFTexture is the single resource for GIF content: it owns the decoded frame data and its playback state. Assign it to Sprite2D, Sprite3D, TextureRect, materials, or shader uniforms like any other Texture2D. Importing a .gif file produces a GIFTexture. Each scene instance gets its own copy (Resource.resource_local_to_scene is enabled by default), so playback state never leaks between instances; use "Make Unique" when two nodes in the same scene must play independently. Looping honors netscape_loop_count while loop is true.
Properties
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Methods
void |
add_source_frame(image: Image, delay_cs: int = 10, disposal: Disposal = 0, position: Vector2i = Vector2i(0, 0)) |
from_sprite_frames(frames: SpriteFrames, animation_name: StringName = &"default") static |
|
get_active_texture(frame: int) |
|
get_baked_image(frame: int) const |
|
get_frame_count() const |
|
get_frame_delay(frame: int) const |
|
get_frame_delay_sec(frame: int) const |
|
get_frame_disposal(frame: int) const |
|
get_frame_has_transparency(frame: int) const |
|
get_frame_position(frame: int) const |
|
get_frame_transparent_color(frame: int) const |
|
get_source_image(frame: int) const |
|
load_from_buffer(buffer: PackedByteArray) |
|
load_from_path(path: String) |
|
save_to_buffer() const |
|
save_to_path(path: String) const |
|
to_sprite_frames(animation_name: StringName = &"default") |
|
wrap_frame(frame: int) const |
Signals
frames_changed() 🔗
Emitted when the frame data changes (load, add_source_frame, reimport).
rebaked() 🔗
Emitted after bake_frames() composites new baked frames.
Enumerations
enum DisplayMode: 🔗
DisplayMode DISPLAY_SOURCE = 0
There is currently no description for this enum. Please help us by contributing one!
DisplayMode DISPLAY_BAKED = 1
There is currently no description for this enum. Please help us by contributing one!
enum BakeStorage: 🔗
BakeStorage BAKE_STORE = 0
There is currently no description for this enum. Please help us by contributing one!
BakeStorage BAKE_GENERATE_ON_LOAD = 1
There is currently no description for this enum. Please help us by contributing one!
enum Disposal: 🔗
Disposal DISPOSAL_NONE = 0
There is currently no description for this enum. Please help us by contributing one!
Disposal DISPOSAL_DO_NOT_DISPOSE = 1
There is currently no description for this enum. Please help us by contributing one!
Disposal DISPOSAL_RESTORE_BACKGROUND = 2
There is currently no description for this enum. Please help us by contributing one!
Disposal DISPOSAL_RESTORE_PREVIOUS = 3
There is currently no description for this enum. Please help us by contributing one!
Property Descriptions
bool autoplay_on_load = true 🔗
If true, playback starts automatically when the texture is loaded or instanced. Disable this to keep the first frame until play is set.
Compress baked frame images.
BakeStorage bake_storage = 1 🔗
void set_bake_storage(value: BakeStorage)
BakeStorage get_bake_storage()
Whether baked frames are stored in the resource or regenerated on load.
Array[Image] baked_frames = [] 🔗
There is currently no description for this property. Please help us by contributing one!
Vector2i canvas_size = Vector2i(0, 0) 🔗
Logical canvas size of the GIF.
Visible frame index.
DisplayMode display_mode = 0 🔗
void set_display_mode(value: DisplayMode)
DisplayMode get_display_mode()
Whether rendering uses raw source frames or composited baked frames.
Dithering used when encoding GIFs.
If true, playback repeats according to netscape_loop_count.
Netscape loop count from the file: 0 loops forever, N plays N times.
If true, the texture advances frames. Non-looping playback automatically clears this when the animation finishes; setting it again restarts from frame 0.
Array[Image] source_frames = [] 🔗
There is currently no description for this property. Please help us by contributing one!
Playback speed. Negative values play in reverse.
Method Descriptions
void add_source_frame(image: Image, delay_cs: int = 10, disposal: Disposal = 0, position: Vector2i = Vector2i(0, 0)) 🔗
Appends a raw frame with delay (centiseconds), disposal method, and canvas offset.
Composites source frames (disposals, offsets, transparency) into full-canvas baked frames.
GIFTexture from_sprite_frames(frames: SpriteFrames, animation_name: StringName = &"default") static 🔗
Creates a GIFTexture from a SpriteFrames animation.
Texture2D get_active_texture(frame: int) 🔗
Returns the composited texture for a frame index.
Image get_baked_image(frame: int) const 🔗
Returns the baked full-canvas image of a frame.
Returns the number of frames.
int get_frame_delay(frame: int) const 🔗
There is currently no description for this method. Please help us by contributing one!
float get_frame_delay_sec(frame: int) const 🔗
There is currently no description for this method. Please help us by contributing one!
Disposal get_frame_disposal(frame: int) const 🔗
There is currently no description for this method. Please help us by contributing one!
bool get_frame_has_transparency(frame: int) const 🔗
There is currently no description for this method. Please help us by contributing one!
Vector2i get_frame_position(frame: int) const 🔗
There is currently no description for this method. Please help us by contributing one!
int get_frame_transparent_color(frame: int) const 🔗
There is currently no description for this method. Please help us by contributing one!
Image get_source_image(frame: int) const 🔗
Returns the raw source image of a frame.
Error load_from_buffer(buffer: PackedByteArray) 🔗
Decodes GIF data into this texture, replacing all frames.
Error load_from_path(path: String) 🔗
Decodes a GIF file into this texture, replacing all frames.
PackedByteArray save_to_buffer() const 🔗
Encodes the current frames as GIF data.
Error save_to_path(path: String) const 🔗
Encodes the current frames as a GIF file.
SpriteFrames to_sprite_frames(animation_name: StringName = &"default") 🔗
Converts the frames to a SpriteFrames animation.
int wrap_frame(frame: int) const 🔗
Wraps an arbitrary frame index into the valid range.