GIFRecorder

Inherits: RefCounted < Object

Records a viewport, window, or screen to an animated GIF.

Description

Works in the editor and in exported templates. Capture a Viewport with start_viewport(), the engine window with start_window(), or a display with start_screen(). Tests and manual control can push images with add_frame(). Call stop() then save(), or use record_viewport() for a timed clip.

Properties

bool

dither

true

int

fps

12

int

loop_count

0

int

max_frames

0

Vector2i

max_size

Vector2i(480, 270)

Methods

Error

add_frame(image: Image)

bool

is_recording() const

Error

record_viewport(viewport: Viewport, path: String, duration_sec: float, fps: int = 12) static

Error

save(path: String)

Error

start_screen(screen: int = 0)

Error

start_viewport(viewport: Viewport)

Error

start_window()

GIFTexture

stop()


Signals

recording_finished(animation: GIFTexture, path: String) 🔗

Emitted when stop() finishes. path is set when a pending save path was provided.


Enumerations

enum Source: 🔗

Source SOURCE_VIEWPORT = 0

Capture one viewport.

Source SOURCE_WINDOW = 1

Capture the engine or game window.

Source SOURCE_SCREEN = 2

Capture a display.


Property Descriptions

bool dither = true 🔗

  • void set_dither(value: bool)

  • bool get_dither()

Enables encoder dithering.


int fps = 12 🔗

  • void set_fps(value: int)

  • int get_fps()

Capture rate and encoded frame delay.


int loop_count = 0 🔗

  • void set_loop_count(value: int)

  • int get_loop_count()

Netscape loop count written on encode. 0 is infinite.


int max_frames = 0 🔗

  • void set_max_frames(value: int)

  • int get_max_frames()

Optional cap. 0 uses blazium/gif/max_frames.


Vector2i max_size = Vector2i(480, 270) 🔗

Downscales captured frames that exceed this size. (0, 0) disables scaling.


Method Descriptions

Error add_frame(image: Image) 🔗

Appends a prepared frame. Used by unit tests and manual capture.


bool is_recording() const 🔗

Returns true while a timed capture is running.


Error record_viewport(viewport: Viewport, path: String, duration_sec: float, fps: int = 12) static 🔗

Records viewport for duration_sec seconds and writes path.


Error save(path: String) 🔗

Encodes collected frames to path.


Error start_screen(screen: int = 0) 🔗

Starts capturing a display.


Error start_viewport(viewport: Viewport) 🔗

Starts capturing viewport each process frame.


Error start_window() 🔗

Starts capturing the main engine or game window, including decorations.


GIFTexture stop() 🔗

Stops capture and returns the recorded animation.