GifCapture
Captures the screen content and creates animated GIF files.
This utility allows recording gameplay or animations from your Ceramic app and exporting them as GIF files. It supports frame blending for smooth animations and configurable frame rates.
Features
- Screen capture to animated GIF
- Configurable frame rates and duration
- Frame blending for smoother animations
- Automatic file saving
- Real-time capture with fixed delta time
Usage Example
var capture = new GifCapture();
// Start capturing for 5 seconds at 30 FPS
capture.captureScreen(1, 1.0, 30, 5.0, "recording.gif");
// Listen for completion
capture.onFinish(this, () -> {
trace("GIF saved!");
});
// Or manually stop capture
app.onceDelay(this, 3.0, () -> {
var bytes = capture.finish("manual-stop.gif");
trace("Captured " + bytes.length + " bytes");
});
Instance Members
captureScreen(?imagesPerFrame: Int = 1, ?middleFactor: Float = 1, ?gifFps: Int = 50, ?duration: Float = -1, ?path: String): Void
Starts capturing the screen content to create an animated GIF.
Name | Type | Default | Description |
---|---|---|---|
imagesPerFrame |
Int | 1 |
Number of screen captures to blend per GIF frame (higher = smoother) |
middleFactor |
Float | 1 |
Blending weight for middle frames (0-1, affects smoothness) |
gifFps |
Int | 50 |
Target frame rate for the output GIF |
duration |
Float | -1 |
Duration to capture in seconds (-1 to capture until manually stopped) |
path |
String | (optional) | Optional file path to save the GIF (can also be specified in finish()) |
Finishes the GIF capture and saves the file.
Name | Type | Default | Description |
---|---|---|---|
path |
String | (optional) | Optional file path to save the GIF (overrides path from captureScreen) |
Returns | Description |
---|---|
haxe.io.Bytes | The encoded GIF data as bytes |
Cleans up resources and restores settings. Automatically stops capture if still running.
Creates a new GIF capture instance.
Private Members
Internal frame rate for screen capture
Output GIF frame rate
Duration to capture in seconds (-1 for manual stop)
Elapsed capture time
Whether currently capturing
Current frame number
GIF encoder instance
Output stream for GIF data
Capture width in pixels
Capture height in pixels
Previous delta time override value
Path to save the GIF file
List of captured pixel buffers for blending
Buffer for mixed/blended pixels
Blending factor for middle frames
Number of screen captures per GIF frame
Emitted when GIF capture has finished. Called after the file has been saved and encoding is complete.
Metadata
Name | Parameters |
---|---|
:build |
ceramic.macros.EntityMacro.buildForCompletion() |
:autoBuild |
ceramic.macros.EntityMacro.buildForCompletion() |
:build |
tracker.macros.EventsMacro.build() |
:autoBuild |
tracker.macros.EventsMacro.build() |