moonbit-gif

    A mizchi/image extension for multi-frame GIF89a composition, palette quantization, and streaming LZW.

    gif
    gif89a
    animation
    lzw
    palette
    image
    mizchi-image
    Download zip
    Author
    Version
    0.1.0
    License
    Apache-2.0
    Last updated
    2 months ago
    Downloads
    49

    #moonbit-gif

    纯 MoonBit 实现的 GIF87a/GIF89a 动态图引擎:从 RGBA 帧合成可播放 GIF,覆盖调色板量化、透明度、帧时序、差分优化、位级 LZW 编解码和流式分块。它适合作为录屏转 GIF、网页表情包、像素动画导出器的底层库。

    项目以 mizchi/image 的 ImageData 为输入边界,新增多帧时间线和 GIF 文件格式能力,不复制上游源码,也不替代通用静态图片编解码库。

    #核心能力

    • GIF87a/GIF89a 解析:逻辑屏幕、全局/局部调色板、图形控制扩展、循环扩展、多帧图像数据和结构报告。
    • GIF89a 生成:全局/局部调色板、透明色、帧延迟、disposal、循环次数和元数据扩展。
    • 调色板与压缩:Median Cut 量化、有序/Floyd–Steinberg 抖动、12 位动态 LZW、清除码/结束码、KwKwK 情形和 GIF data sub-block。
    • 画布与动画:RGBA 绘制、alpha 合成、裁剪、缩放、旋转、形态学、卷积、模式生成、关键帧、差分矩形、补丁和时间线工具。
    • 工程化接口:GifWorkflow 声明式导出流水线、GifLimits 安全限制、流式 chunk collector、Netpbm 输入输出、CLI 请求模型和确定性基准。

    #快速开始

    添加模块依赖:

    moon add mizchi/image@0.4.3 moon add WGYo90/moonbit-gif@0.1.0

    最小的内存编码示例:

    import {
    "mizchi/image" @image,
    "WGYo90/moonbit-gif" @gif,
    }

    let image = @image.ImageData::{
    width: 32,
    height: 32,
    data: Bytes::make(32 * 32 * 4, 255),
    }
    let bytes = @gif.encode_image_sequence([image], delay_cs=8, loop_count=0)

    需要精细绘制时,可直接构造 @gif.Canvas、@gif.Frame 和 @gif.Animation;Canvas::to_image_data 可将结果交回 mizchi/image 的 RGBA 表示。

    #CLI 与基准

    仓库提供两个无文件系统依赖的可运行入口:

    moon run --target native cmd/main moon run --target native cmd/benchmark

    PowerShell 用户可以运行多次预热后的基准脚本;-Release 测量 release 目标:

    powershell -NoProfile -ExecutionPolicy Bypass -File scripts/bench.ps1 -Repeat 5 powershell -NoProfile -ExecutionPolicy Bypass -File scripts/bench.ps1 -Release -Repeat 5

    默认工作负载固定为 12 帧、128×96、64 色。当前本地 MoonBit 0.10.10 工具链上的一次实测输出如下,确定性字段应保持一致,耗时随机器和缓存变化:

    frames=12 size=128x96 encoded=1929 estimated=1916 decoded=12 pixels=147456 roundtrip=true palette_error=120 lzw_saving_per_mille=985 debug: runs=5 avg_ms=691.68 median_ms=693.75 min_ms=662.94 max_ms=731.71 release: runs=5 avg_ms=524.35 median_ms=540.81 min_ms=469.77 max_ms=563.18

    #架构

    层主要模块作用
    数据模型gif_types.mbt, gif_bytes.mbt, image_bridge.mbtRGBA、画布、帧、动画与 ImageData 适配
    格式层gif_decoder.mbt, gif_encoder.mbt, gif_formats.mbt, gif_metadata.mbtGIF block、调色板、扩展块和元数据
    压缩层lzw.mbt, lzw_analysis.mbt, gif_stream.mbt, gif_streaming.mbt位级 LZW、子块封装、分块收集和压缩分析
    质量层palette.mbt, palette_tools.mbt, quantization_extra.mbt, palette_mapping.mbtMedian Cut、抖动、索引映射和量化质量
    动画层compose.mbt, animation_*.mbt, gif_delta*.mbt, gif_optimizer.mbtdisposal 合成、时间线、差分帧和大小优化
    画布层canvas_*.mbt, color_*.mbt, draw_primitives.mbt几何、滤镜、绘制、颜色空间、统计和图案
    应用层gif_workflow.mbt, gif_cli_*.mbt, gif_report.mbt, gif_preflight.mbt声明式导出、CLI 请求、预检、报告和限制

    根包当前包含 20,296 行 MoonBit 源文件;统计口径为非测试、非 cmd/ 的 *.mbt 文件总行数,不计生成的接口文件,也没有用空文件或占位文件补数。

    #测试与质量门禁

    本地完整检查:

    moon fmt --check moon check --target all --deny-warn --fmt moon info --target all moon test --target all --deny-warn moon build --target all --deny-warn

    当前原生测试包含编码/解码、LZW 清除码与码宽增长、调色板上限、透明度、Netpbm 异常输入、形态学空画布、流式分块乱序重组、GIF 截断预检、元数据、差分帧、工作流报告和确定性基准等边界场景。

    moon fmt --check 负责格式无差异,moon check --target all --deny-warn --fmt 负责严格类型与警告,moon info --target all 后通过干净工作树检查生成接口没有漂移。Windows 可直接运行:

    powershell -NoProfile -ExecutionPolicy Bypass -File scripts/check.ps1

    #CI

    .github/workflows/check.yml 在 Ubuntu、macOS、Windows 三个平台安装稳定版 MoonBit,执行格式检查、全目标严格检查、构建、接口生成和全目标测试;.github/workflows/coverage.yml 在 Ubuntu 上执行原生覆盖率报告与分析。工作流使用最小的只读仓库权限,并关闭 checkout 的持久化凭据。

    #上游、来源与许可证

    本项目通过 Mooncakes 依赖 mizchi/image@0.4.3。上游源码和 Apache-2.0 许可见 mizchi/image-mbt;本仓库只使用其 RGBA ImageData 边界,不复制上游源码。动态 GIF 时间线、画布工具、调色板量化、LZW、合成、流式接口和适配层均位于本仓库,来源说明见 docs/SOURCE_NOTES.md。

    项目使用 Apache License 2.0,详见 LICENSE 与 NOTICE。

    GifError

    pub(all) suberror GifError {
    InvalidSignature
    UnexpectedEnd(context~ : String)
    InvalidDimensions
    InvalidBlock(context~ : String)
    UnsupportedFeature(feature~ : String)
    InvalidLzw(context~ : String)
    InvalidPalette(context~ : String)
    } derive(Eq,
    Debug
    )

    Affine2i

    pub(all) struct Affine2i {
    a : Int
    b : Int
    c : Int
    d : Int
    tx : Int
    ty : Int
    scale : Int
    } derive(
    Debug
    )

    Integer affine transforms for controlled sprite placement.

    Affine2i::apply

    fn Affine2i::apply(self : Affine2i, x : Int, y : Int) -> (Int, Int)

    Affine2i::identity

    fn Affine2i::identity() -> Affine2i

    Affine2i::inverse_apply

    fn Affine2i::inverse_apply(self : Affine2i, x : Int, y : Int) -> (Int, Int)

    Affine2i::scale

    fn Affine2i::scale(self : Affine2i, per_mille : Int) -> Affine2i

    Affine2i::translate

    fn Affine2i::translate(self : Affine2i, x : Int, y : Int) -> Affine2i

    Animation

    pub(all) struct Animation {
    width : Int
    height : Int
    frames : Array[Frame]
    loop_count : Int?
    background : Rgba
    } derive(
    Debug
    )

    A GIF animation. The encoder writes GIF89a when the animation has more than one frame.

    Animation::activity_per_mille

    fn Animation::activity_per_mille(self : Animation) -> Int

    Return a normalized activity score in the range 0..1000.

    Animation::activity_scores

    fn Animation::activity_scores(self : Animation) -> Array[Int]

    Compute a compact temporal activity score from adjacent frame differences.

    Animation::add_frame

    fn Animation::add_frame(self : Animation, frame : Frame) -> Animation

    Animation::append

    fn Animation::append(self : Animation, other : Animation) -> Animation

    Concatenate two animations with identical logical dimensions.

    Animation::apply_delta_plan

    fn Animation::apply_delta_plan(self : Animation, plan : DeltaPlan) -> Animation

    Apply a delta plan without changing frame timing or logical screen size.

    Animation::apply_mask

    fn Animation::apply_mask(self : Animation, mask : Canvas) -> Animation

    Apply a mask to every frame while retaining GIF timing metadata.

    Animation::apply_motion

    fn Animation::apply_motion(self : Animation, track : MotionTrack) -> Animation

    Apply a motion track to each frame at its timeline start time.

    Animation::apply_scale_plan

    fn Animation::apply_scale_plan(self : Animation, plan : ScalePlan) -> Animation

    Apply one scale plan to every frame and reset offsets to the new screen.

    Animation::average_colors

    fn Animation::average_colors(self : Animation) -> Array[Rgba]

    Return the average frame color sequence for lightweight visual analytics.
    fn Animation::blink(self : Animation, visible_copies : Int, hidden_copies : Int) -> Animation

    Repeat each frame with alternating opacity to create a reliable blink.

    Animation::clamp_limits

    fn Animation::clamp_limits(self : Animation, limits : GifLimits) -> Animation

    Clamp an animation to configured dimensions and delay limits.

    Animation::clip_around

    fn Animation::clip_around(self : Animation, center_cs : Int, padding_cs : Int) -> AnimationClip

    Return a clip that includes a small pre-roll and post-roll around a marker.

    Animation::clip_frames

    fn Animation::clip_frames(self : Animation, start : Int, end : Int) -> AnimationClip

    Extract a clip directly from a frame range and annotate its timing.

    Animation::clip_offsets

    fn Animation::clip_offsets(self : Animation) -> Animation

    Return a copy with frame offsets clipped to the logical screen.

    Animation::complexity

    fn Animation::complexity(self : Animation) -> AnimationComplexity

    Analyze frame-to-frame activity and palette diversity.

    Animation::contact_sheet

    fn Animation::contact_sheet(self : Animation, options? : ContactSheetOptions, policy? : AnimationSamplingPolicy) -> Canvas

    Create a tiled contact sheet for review, documentation, and CI artifacts.

    Animation::crop

    fn Animation::crop(self : Animation, x~ : Int, y~ : Int, width~ : Int, height~ : Int) -> Animation

    Crop every frame to the same logical rectangle.

    Animation::deduplicate_frames

    fn Animation::deduplicate_frames(self : Animation, threshold? : Int) -> Animation

    Keep only frames whose canvas differs from the preceding frame.

    Animation::delay_all

    fn Animation::delay_all(self : Animation, delay_cs : Int) -> Animation

    Add a constant delay to every frame, clamping to GIF's practical range.

    Animation::delta_encode

    fn Animation::delta_encode(self : Animation, threshold? : Int) -> Animation

    Encode unchanged frames as transparent 1x1 frames and crop changed frames to their bounding rectangles. This is an optimization pass; it preserves timing and keeps the logical screen size unchanged.

    Animation::delta_rectangles

    fn Animation::delta_rectangles(self : Animation, threshold? : Int) -> Array[GifRect?]

    Return changed rectangles for visual diff overlays.

    Animation::delta_stats

    fn Animation::delta_stats(self : Animation, threshold? : Int) -> DeltaStats

    Estimate the amount of pixel data saved by frame differencing.

    Animation::difference_frames

    fn Animation::difference_frames(self : Animation) -> Array[Canvas]

    Generate one difference heatmap per adjacent frame pair.

    Animation::duration_cs

    fn Animation::duration_cs(self : Animation) -> Int

    Sum frame delays in GIF centiseconds.

    Animation::effective_fps_milli

    fn Animation::effective_fps_milli(self : Animation) -> Int

    Return an animation's effective frames per second in milli-Hz.

    Animation::export_report

    fn Animation::export_report(self : Animation, profile : ExportProfile) -> ExportReport raise GifError

    Run an export profile and return measured encoded bytes.

    Animation::export_with_plan

    fn Animation::export_with_plan(self : Animation, plan : ExportPlan) -> Bytes raise GifError

    Apply an export plan and encode it in one operation.

    Animation::first_canvas

    fn Animation::first_canvas(self : Animation) -> Canvas?

    Return the first frame's canvas, if present.

    Animation::first_slow_frame

    fn Animation::first_slow_frame(self : Animation, threshold_cs : Int) -> Int?

    Return the first frame whose delay exceeds a threshold.

    Animation::flatten_frames

    fn Animation::flatten_frames(self : Animation) -> Animation

    Normalize all frames to the logical screen and reset their offsets.

    Animation::flip_horizontal

    fn Animation::flip_horizontal(self : Animation) -> Animation

    Animation::flip_vertical

    fn Animation::flip_vertical(self : Animation) -> Animation

    Animation::frame_at

    fn Animation::frame_at(self : Animation, time_cs : Int) -> Frame?

    Return the frame visible at a centisecond position.

    Animation::frame_count

    fn Animation::frame_count(self : Animation) -> Int

    Animation::frames

    fn Animation::frames(self : Animation) -> ArrayView[Frame]

    Animation::frames_at_times

    fn Animation::frames_at_times(self : Animation, times : ArrayView[Int]) -> Array[Frame]

    Return frames whose timeline position is closest to each requested time.

    Animation::grayscale

    fn Animation::grayscale(self : Animation) -> Animation

    Animation::height

    fn Animation::height(self : Animation) -> Int

    Animation::hold

    fn Animation::hold(self : Animation, copies : Int) -> Animation

    Insert a hold after each frame, keeping the original delay on the first copy.

    Animation::insert_frame

    fn Animation::insert_frame(self : Animation, index : Int, frame : Frame) -> Animation

    Insert a frame before the requested index. Out-of-range indices append.

    Animation::insert_gap

    fn Animation::insert_gap(self : Animation, index : Int, count : Int, delay_cs~ : Int) -> Animation

    Insert count transparent frames with the requested delay.

    Animation::interpolate_frames

    fn Animation::interpolate_frames(self : Animation, between : Int, easing~ : Easing) -> Animation

    Insert interpolated frames between every pair of animation frames.

    Animation::invert

    fn Animation::invert(self : Animation) -> Animation

    Animation::keyframe_indices

    fn Animation::keyframe_indices(self : Animation, threshold? : Int) -> Array[Int]

    Find keyframes by comparing each frame to the previous full canvas.

    Animation::keyframes

    fn Animation::keyframes(self : Animation, threshold? : Int) -> Animation

    Keep only keyframes and preserve each frame's timing.

    Animation::last_canvas

    fn Animation::last_canvas(self : Animation) -> Canvas?

    Return the last frame's canvas, if present.

    Animation::loop_count

    fn Animation::loop_count(self : Animation) -> Int?

    Animation::looped

    fn Animation::looped(self : Animation, cycles : Int) -> Animation

    Create a looped timeline while avoiding repeated endpoint frames.

    Animation::map_effect

    fn Animation::map_effect(self : Animation, effect : ColorAdjustment) -> Animation

    Apply a frame effect to every visible snapshot while keeping delays.

    Animation::map_transform

    fn Animation::map_transform(self : Animation, transform : AnimationTransform) -> Animation

    Apply the same canvas transform to every frame.

    Animation::merge_equal_frames

    fn Animation::merge_equal_frames(self : Animation) -> Animation

    Merge adjacent frames when their rendered pixels are identical.

    Animation::merge_identical

    fn Animation::merge_identical(self : Animation) -> Animation

    Merge adjacent frames with the same canvas hash.

    Animation::move_between

    fn Animation::move_between(self : Animation, from~ : (Int, Int), to~ : (Int, Int), easing~ : Easing) -> Animation

    Generate a moving copy of an animation between two positions.

    Animation::move_range

    fn Animation::move_range(self : Animation, range : FrameRange, destination : Int) -> Animation

    Move a range before another index, retaining frame order.

    Animation::moving_layer

    fn Animation::moving_layer(self : Animation, layer : ImageLayer, start_left : Int, start_top : Int, end_left : Int, end_top : Int) -> Animation

    Render a moving overlay across a timeline using integer interpolation.

    Animation::new

    fn Animation::new(width~ : Int, height~ : Int) -> Animation

    Animation::normalize_delays

    fn Animation::normalize_delays(self : Animation, default_delay_cs? : Int) -> Animation

    Replace zero-delay frames with a visible default delay.

    Animation::optimization_report

    fn Animation::optimization_report(self : Animation, options : OptimizationOptions) -> OptimizationReport raise GifError

    Estimate GIF payload cost after palette quantization and delta analysis.

    Animation::optimization_warnings

    fn Animation::optimization_warnings(self : Animation, options : OptimizationOptions) -> Array[String]

    Verify that a planned animation still has valid GIF frame rectangles.

    Animation::optimize_for_size

    fn Animation::optimize_for_size(self : Animation, options : OptimizationOptions) -> Animation

    Run safe size optimizations while preserving logical dimensions and delay.

    Animation::optimize_frames

    fn Animation::optimize_frames(self : Animation) -> Animation

    Alias emphasizing that the pass is safe to apply before encoding.

    Animation::optimize_to_budget

    fn Animation::optimize_to_budget(self : Animation, budget_bytes : Int, options : OptimizationOptions) -> (Animation, OptimizationReport) raise GifError

    Optimize an animation for a byte budget and return the chosen report.

    Animation::overlay_layer

    fn Animation::overlay_layer(self : Animation, layer : ImageLayer) -> Animation

    Apply a single layer at all frame times while keeping the base timeline.

    Animation::overlay_static

    fn Animation::overlay_static(self : Animation, overlay : Canvas, alignment : CompositeAlignment) -> Animation

    Stack a static canvas over every frame at a selected alignment.

    Animation::patch_density

    fn Animation::patch_density(self : Animation, threshold? : Int) -> Int

    Estimate the patch ratio of an animation in per mille.

    Animation::patch_frames

    fn Animation::patch_frames(self : Animation, threshold? : Int) -> Array[PatchFrame]

    Compute one patch per frame, using the logical background as the first base.

    Animation::pattern_background

    fn Animation::pattern_background(self : Animation, options : PatternOptions) -> Animation

    Apply a phase-shifted pattern behind an existing animation.

    Animation::persistent

    fn Animation::persistent(self : Animation) -> Animation

    Remove disposal history by flattening and making each frame persistent.

    Animation::ping_pong

    fn Animation::ping_pong(self : Animation) -> Animation

    Add a reverse pass without duplicating the endpoints.

    Animation::plan_delta

    fn Animation::plan_delta(self : Animation, policy : DeltaPolicy, threshold? : Int) -> DeltaPlan

    Build a per-frame plan from changed rectangles and a policy.

    Animation::plan_export

    fn Animation::plan_export(self : Animation, profile : ExportProfile) -> ExportPlan raise GifError

    Choose a practical optimization and palette plan for a target use case.

    Animation::position_at

    fn Animation::position_at(self : Animation, time_cs : Int) -> TimelinePosition?

    Return the frame occupying a centisecond position, with loop handling.

    Animation::poster

    fn Animation::poster(self : Animation, max_edge : Int, columns : Int) -> Canvas

    Create a poster canvas by placing sampled thumbnails on a checkerboard.

    Animation::profile_for_budget

    fn Animation::profile_for_budget(self : Animation, budget_bytes : Int) -> ExportProfile raise GifError

    Select a profile from a size budget using the optimizer's exact estimate.

    Animation::pulse

    fn Animation::pulse(self : Animation, minimum_alpha~ : Byte, easing~ : Easing) -> Animation

    Add a pulsing opacity effect without changing frame dimensions.

    Animation::quantize_delays

    fn Animation::quantize_delays(self : Animation, tick_cs : Int, policy : TimelinePolicy) -> Animation

    Quantize all frame delays to a display tick while preserving total duration.

    Animation::ranges

    fn Animation::ranges(self : Animation) -> Array[FrameRange]

    Split a timeline at every delay boundary and return the generated ranges.

    Animation::remove_range

    fn Animation::remove_range(self : Animation, range : FrameRange) -> Animation

    Remove a half-open frame range and return the resulting animation.

    Animation::repeat

    fn Animation::repeat(self : Animation, times : Int) -> Animation

    Repeat the timeline times times. A zero or negative count returns no frames.

    Animation::replace_range

    fn Animation::replace_range(self : Animation, range : FrameRange, replacement : ArrayView[Frame]) -> Animation

    Replace a range with a new sequence while preserving logical dimensions.

    Animation::resample

    fn Animation::resample(self : Animation, frame_count : Int, policy : TimelinePolicy) -> Animation

    Normalize a time range into a sequence of uniformly sampled snapshots.

    Animation::resample_frames_with_filter

    fn Animation::resample_frames_with_filter(self : Animation, width : Int, height : Int, filter? : ResampleFilter) -> Animation

    Resample every frame while keeping the animation timeline.

    Animation::resize_nearest

    fn Animation::resize_nearest(self : Animation, width~ : Int, height~ : Int) -> Animation

    Resize every frame and update the logical screen dimensions.

    Animation::retained_pixel_ratio

    fn Animation::retained_pixel_ratio(self : Animation, threshold : Int) -> Int

    Return the ratio of frame pixels retained after delta cropping.

    Animation::retime

    fn Animation::retime(self : Animation, target_cs : Int) -> Animation

    Rescale all delays so the total duration approaches target_cs.

    Animation::reverse

    fn Animation::reverse(self : Animation) -> Animation

    Return a timeline with frames in reverse display order.

    Animation::sample

    fn Animation::sample(self : Animation, count : Int) -> Animation

    Build a sampled timeline with evenly spaced positions.

    Animation::sample_with_policy

    fn Animation::sample_with_policy(self : Animation, policy : AnimationSamplingPolicy) -> Animation

    Extract a deterministic preview animation according to a sampling policy.

    Animation::shake

    fn Animation::shake(self : Animation, radius : Int, seed? : Int) -> Animation

    Create a deterministic camera shake by translating successive frames.

    Animation::slice

    fn Animation::slice(self : Animation, start~ : Int, end~ : Int) -> Animation

    Select a half-open range of frames.

    Animation::split_frames

    fn Animation::split_frames(self : Animation, pieces : Int) -> Animation

    Split every frame into a fixed number of duration-preserving copies.

    Animation::stats

    fn Animation::stats(self : Animation) -> AnimationStats

    Compute statistics without encoding the animation.

    Animation::thumbnail_strip

    fn Animation::thumbnail_strip(self : Animation, max_edge : Int, gap? : Int) -> Canvas

    Produce thumbnails in one horizontal strip, preserving frame order.

    Animation::tile_frames

    fn Animation::tile_frames(self : Animation, columns : Int, rows : Int, gap : Int, background : Rgba) -> Animation

    Make a tiled animation from a single source animation.

    Animation::timecodes

    fn Animation::timecodes(self : Animation) -> Array[Int]

    Return cumulative timeline positions for storyboard labels and scrubbing.

    Animation::timeline_indices

    fn Animation::timeline_indices(self : Animation) -> Array[Int]

    Return the frame indices at every timeline boundary.

    Animation::timeline_metrics

    fn Animation::timeline_metrics(self : Animation) -> TimelineMetrics

    Calculate duration, delay distribution, and visible pixel totals.

    Animation::timeline_starts

    fn Animation::timeline_starts(self : Animation) -> Array[Int]

    Return cumulative frame start times in centiseconds.

    Animation::to_sprite_atlas

    fn Animation::to_sprite_atlas(self : Animation, options : AtlasPackOptions) -> SpriteAtlas

    Pack each animation frame as a named sprite.

    Animation::trim

    fn Animation::trim(self : Animation, range : FrameRange) -> Animation

    Remove frames outside the requested range while retaining logical metadata.

    Animation::uses_compatible_metadata

    fn Animation::uses_compatible_metadata(self : Animation) -> Bool

    Return whether all frames use metadata accepted by the encoder.

    Animation::validate

    fn Animation::validate(self : Animation) -> Array[String]

    Validate dimensions, offsets, delays, and GIF representability.

    Animation::width

    fn Animation::width(self : Animation) -> Int

    Animation::wipe

    fn Animation::wipe(self : Animation, direction : Int, color : Rgba) -> Animation

    Create a frame-by-frame color wipe from one edge of the logical screen.

    Animation::with_background

    fn Animation::with_background(self : Animation, background~ : Rgba) -> Animation

    Animation::with_delay

    fn Animation::with_delay(self : Animation, delay_cs : Int) -> Animation

    Set every frame to one delay value.

    Animation::with_delay_floor

    fn Animation::with_delay_floor(self : Animation, floor_cs : Int) -> Animation

    Return a copy with pathological delays normalized to a playback floor.

    Animation::with_frame

    fn Animation::with_frame(self : Animation, index~ : Int, frame : Frame) -> Animation

    Animation::with_loop_count

    fn Animation::with_loop_count(self : Animation, loop_count~ : Int?) -> Animation

    Animation::with_transitions

    fn Animation::with_transitions(self : Animation, options? : TransitionOptions) -> Animation

    Append transition frames between every pair of frames in an animation.

    Animation::zoom

    fn Animation::zoom(self : Animation, from_per_mille~ : Int, to_per_mille~ : Int, easing~ : Easing) -> Animation

    Add a zoom-in or zoom-out camera move around the logical screen center.

    AnimationBuilder

    pub(all) struct AnimationBuilder {
    animation : Animation
    } derive(
    Debug
    )

    Mutable-style builder that keeps construction readable in CLI tools.

    AnimationBuilder::background

    fn AnimationBuilder::background(self : AnimationBuilder, color : Rgba) -> AnimationBuilder

    AnimationBuilder::build

    AnimationBuilder::frame

    AnimationBuilder::loop_count

    fn AnimationBuilder::loop_count(self : AnimationBuilder, value : Int?) -> AnimationBuilder

    AnimationBuilder::new

    fn AnimationBuilder::new(width~ : Int, height~ : Int) -> AnimationBuilder

    AnimationBuilder::solid_frame

    fn AnimationBuilder::solid_frame(self : AnimationBuilder, color~ : Rgba, delay_cs~ : Int) -> AnimationBuilder

    AnimationClip

    pub(all) struct AnimationClip {
    source : Animation
    start_cs : Int
    end_cs : Int
    speed_per_mille : Int
    loop_count : Int
    } derive(
    Debug
    )

    Non-destructive timeline clips for editors and reusable export scenes.

    AnimationClip::duration

    fn AnimationClip::duration(self : AnimationClip) -> Int

    AnimationClip::fps

    fn AnimationClip::fps(self : AnimationClip, frames_per_second : Int) -> AnimationClip

    Set an explicit frame rate for clip playback.

    AnimationClip::loops

    fn AnimationClip::loops(self : AnimationClip, count : Int) -> AnimationClip

    AnimationClip::new

    fn AnimationClip::new(source : Animation, start_cs : Int, end_cs : Int) -> AnimationClip

    AnimationClip::range

    fn AnimationClip::range(self : AnimationClip) -> (Int, Int)

    AnimationClip::render

    fn AnimationClip::render(self : AnimationClip) -> Animation

    Render a clip into a fresh animation while preserving sampled timing.

    AnimationClip::reverse

    Reverse clip order while preserving each frame's delay.

    AnimationClip::source

    fn AnimationClip::source(self : AnimationClip) -> Animation

    AnimationClip::speed

    fn AnimationClip::speed(self : AnimationClip, per_mille : Int) -> AnimationClip

    AnimationComplexity

    pub(all) struct AnimationComplexity {
    frame_count : Int
    total_pixels : Int
    changed_pixels : Int
    mean_unique_colors : Int
    active_frames : Int
    peak_entropy : Int
    } derive(
    Debug
    )

    AnimationComplexity::active_frames

    fn AnimationComplexity::active_frames(self : AnimationComplexity) -> Int

    AnimationComplexity::changed_pixels

    fn AnimationComplexity::changed_pixels(self : AnimationComplexity) -> Int

    AnimationComplexity::frame_count

    fn AnimationComplexity::frame_count(self : AnimationComplexity) -> Int

    AnimationComplexity::mean_unique_colors

    fn AnimationComplexity::mean_unique_colors(self : AnimationComplexity) -> Int

    AnimationComplexity::peak_entropy

    fn AnimationComplexity::peak_entropy(self : AnimationComplexity) -> Int

    AnimationComplexity::total_pixels

    fn AnimationComplexity::total_pixels(self : AnimationComplexity) -> Int

    AnimationEditor

    pub(all) struct AnimationEditor {
    current : Animation
    history : Array[Animation]
    cursor : Int
    } derive(
    Debug
    )

    A small non-destructive editor with undo snapshots for CLI and UI clients.

    AnimationEditor::build

    AnimationEditor::can_redo

    fn AnimationEditor::can_redo(self : AnimationEditor) -> Bool

    AnimationEditor::can_undo

    fn AnimationEditor::can_undo(self : AnimationEditor) -> Bool

    AnimationEditor::current

    AnimationEditor::insert

    fn AnimationEditor::insert(self : AnimationEditor, index : Int, frame : Frame) -> AnimationEditor

    AnimationEditor::new

    fn AnimationEditor::new(animation : Animation) -> AnimationEditor

    AnimationEditor::remove

    AnimationEditor::transform

    AnimationEditor::undo

    AnimationGraph

    pub(all) struct AnimationGraph {
    width : Int
    height : Int
    nodes : Array[AnimationNode]
    background : Rgba
    } derive(
    Debug
    )

    AnimationGraph::add

    AnimationGraph::background

    fn AnimationGraph::background(self : AnimationGraph, color : Rgba) -> AnimationGraph

    AnimationGraph::compact

    Remove disabled nodes and empty animations before rendering.

    AnimationGraph::frame_count

    fn AnimationGraph::frame_count(self : AnimationGraph) -> Int

    AnimationGraph::new

    fn AnimationGraph::new(width : Int, height : Int) -> AnimationGraph

    AnimationGraph::node_names

    fn AnimationGraph::node_names(self : AnimationGraph) -> Array[String]

    Return a stable list of node names for diagnostics.

    AnimationGraph::nodes

    AnimationGraph::render

    Render the graph by compositing each enabled node at a cyclic frame index.

    AnimationGraph::replace

    fn AnimationGraph::replace(self : AnimationGraph, name : String, node : AnimationNode) -> AnimationGraph

    Replace one named node while preserving graph order.

    AnimationNode

    pub(all) struct AnimationNode {
    name : String
    animation : Animation
    opacity : Byte
    enabled : Bool
    } derive(
    Debug
    )

    A small composition graph for reusable animation scenes.

    AnimationNode::animation

    fn AnimationNode::animation(self : AnimationNode) -> Animation

    AnimationNode::enabled

    fn AnimationNode::enabled(self : AnimationNode, value : Bool) -> AnimationNode

    AnimationNode::name

    fn AnimationNode::name(self : AnimationNode) -> String

    AnimationNode::new

    fn AnimationNode::new(name : String, animation : Animation) -> AnimationNode

    AnimationNode::opacity

    fn AnimationNode::opacity(self : AnimationNode, value : Byte) -> AnimationNode

    AnimationPipeline

    pub(all) struct AnimationPipeline {
    stages : Array[PipelineStage]
    delay_override : Int?
    } derive(
    Debug
    )

    AnimationPipeline::add

    AnimationPipeline::apply

    fn AnimationPipeline::apply(self : AnimationPipeline, animation : Animation) -> Animation

    AnimationPipeline::apply_preserving_metadata

    fn AnimationPipeline::apply_preserving_metadata(self : AnimationPipeline, animation : Animation) -> Animation

    Apply stages while keeping the timeline and GIF frame metadata intact.

    AnimationPipeline::new

    AnimationPipeline::with_delay

    fn AnimationPipeline::with_delay(self : AnimationPipeline, delay_cs : Int?) -> AnimationPipeline

    AnimationQuality

    pub(all) struct AnimationQuality {
    compared_frames : Int
    mean_error : Int
    maximum_error : Int
    differing_frames : Int
    mean_psnr_milli : Int
    } derive(
    Debug
    )

    Perceptual-style quality metrics for export verification.

    AnimationQuality::compared_frames

    fn AnimationQuality::compared_frames(self : AnimationQuality) -> Int

    AnimationQuality::differing_frames

    fn AnimationQuality::differing_frames(self : AnimationQuality) -> Int

    AnimationQuality::maximum_error

    fn AnimationQuality::maximum_error(self : AnimationQuality) -> Int

    AnimationQuality::mean_error

    fn AnimationQuality::mean_error(self : AnimationQuality) -> Int

    AnimationQuality::mean_psnr

    fn AnimationQuality::mean_psnr(self : AnimationQuality) -> Int

    AnimationQuality::score

    fn AnimationQuality::score(self : AnimationQuality) -> Int

    Return a compact score where 1000 means exact frame equality.

    AnimationQuality::within_error

    fn AnimationQuality::within_error(self : AnimationQuality, maximum_mean_error : Int) -> Bool

    Return true when every compared frame meets a mean error budget.

    AnimationSamplingPolicy

    pub(all) enum AnimationSamplingPolicy {
    EveryFrame
    Evenly(count~ : Int)
    Keyframes(threshold~ : Int)
    FirstAndLast
    } derive(Eq,
    Debug
    )

    Sampling policies for contact sheets and preview generation.

    AnimationStats

    pub(all) struct AnimationStats {
    frame_count : Int
    duration_cs : Int
    transparent_frames : Int
    changed_pixels : Int
    } derive(
    Debug
    )

    Summary values useful for timeline UIs and encoder diagnostics.

    AnimationStats::changed_pixels

    fn AnimationStats::changed_pixels(self : AnimationStats) -> Int

    AnimationStats::duration_cs

    fn AnimationStats::duration_cs(self : AnimationStats) -> Int

    AnimationStats::frame_count

    fn AnimationStats::frame_count(self : AnimationStats) -> Int

    AnimationStats::transparent_frames

    fn AnimationStats::transparent_frames(self : AnimationStats) -> Int

    AnimationTimeline

    pub(all) struct AnimationTimeline {
    animation : Animation
    markers : Array[TimelineMarker]
    } derive(
    Debug
    )

    AnimationTimeline::animation

    AnimationTimeline::at_time

    fn AnimationTimeline::at_time(self : AnimationTimeline, time_cs : Int) -> Array[TimelineMarker]

    AnimationTimeline::between

    fn AnimationTimeline::between(self : AnimationTimeline, start_cs : Int, end_cs : Int) -> Array[TimelineMarker]

    AnimationTimeline::deduplicate

    Remove duplicate markers at the same time and name.

    AnimationTimeline::mark

    AnimationTimeline::mark_frame

    fn AnimationTimeline::mark_frame(self : AnimationTimeline, name : String, index : Int, color : Rgba) -> AnimationTimeline

    AnimationTimeline::marker_strip

    fn AnimationTimeline::marker_strip(self : AnimationTimeline, width : Int, height : Int) -> Canvas

    Render a marker strip aligned with the animation timeline.

    AnimationTimeline::markers

    AnimationTimeline::names

    fn AnimationTimeline::names(self : AnimationTimeline) -> Array[String]

    Return marker names in timeline order.

    AnimationTimeline::new

    AnimationTimeline::scale_time

    fn AnimationTimeline::scale_time(self : AnimationTimeline, per_mille : Int) -> AnimationTimeline

    Scale all marker positions using the same integer tempo rule as retiming.

    AnimationTimeline::shift

    fn AnimationTimeline::shift(self : AnimationTimeline, offset_cs : Int) -> AnimationTimeline

    Move all markers by a time offset while clamping at zero.

    AnimationTimeline::split_at_markers

    fn AnimationTimeline::split_at_markers(self : AnimationTimeline) -> Animation

    Attach marker-derived delays to a sequence of frames.

    AnimationTransform

    pub(all) enum AnimationTransform {
    Identity
    Grayscale
    Invert
    FlipHorizontal
    FlipVertical
    } derive(Eq,
    Debug
    )

    Timeline-wide canvas transform.

    AtlasPackOptions

    pub(all) struct AtlasPackOptions {
    page_width : Int
    page_height : Int
    padding : Int
    allow_rotation : Bool
    extrude : Bool
    background : Rgba
    } derive(
    Debug
    )

    AtlasPackOptions::background

    fn AtlasPackOptions::background(self : AtlasPackOptions, color : Rgba) -> AtlasPackOptions

    AtlasPackOptions::default

    AtlasPackOptions::extrusion

    fn AtlasPackOptions::extrusion(self : AtlasPackOptions, enabled : Bool) -> AtlasPackOptions

    AtlasPackOptions::padding

    fn AtlasPackOptions::padding(self : AtlasPackOptions, value : Int) -> AtlasPackOptions

    AtlasPackOptions::page_size

    fn AtlasPackOptions::page_size(self : AtlasPackOptions, width : Int, height : Int) -> AtlasPackOptions

    AtlasPackOptions::rotation

    fn AtlasPackOptions::rotation(self : AtlasPackOptions, enabled : Bool) -> AtlasPackOptions

    AtlasPage

    pub(all) struct AtlasPage {
    index : Int
    canvas : Canvas
    placements : Array[SpritePlacement]
    } derive(
    Debug
    )

    AtlasPage::canvas

    fn AtlasPage::canvas(self : AtlasPage) -> Canvas

    AtlasPage::index

    fn AtlasPage::index(self : AtlasPage) -> Int

    AtlasPage::placements

    fn AtlasPage::placements(self : AtlasPage) -> ArrayView[SpritePlacement]

    BatchItem

    pub(all) struct BatchItem {
    name : String
    animation : Animation
    } derive(
    Debug
    )

    Batch operations for applying a common export policy to many animations.

    BatchItem::animation

    fn BatchItem::animation(self : BatchItem) -> Animation

    BatchItem::name

    fn BatchItem::name(self : BatchItem) -> String

    BatchItem::new

    fn BatchItem::new(name : String, animation : Animation) -> BatchItem

    BatchReport

    pub(all) struct BatchReport {
    processed : Int
    encoded : Int
    failed : Int
    total_input_bytes : Int
    total_output_bytes : Int
    names : Array[String]
    } derive(
    Debug
    )

    BatchReport::encoded

    fn BatchReport::encoded(self : BatchReport) -> Int

    BatchReport::failed

    fn BatchReport::failed(self : BatchReport) -> Int

    BatchReport::names

    fn BatchReport::names(self : BatchReport) -> ArrayView[String]

    BatchReport::processed

    fn BatchReport::processed(self : BatchReport) -> Int

    BatchReport::saving_per_mille

    fn BatchReport::saving_per_mille(self : BatchReport) -> Int

    Return output compression in per mille, based on measured byte totals.

    BatchReport::total_input_bytes

    fn BatchReport::total_input_bytes(self : BatchReport) -> Int

    BatchReport::total_output_bytes

    fn BatchReport::total_output_bytes(self : BatchReport) -> Int

    BenchmarkResult

    pub(all) struct BenchmarkResult {
    workload : BenchmarkWorkload
    encoded_bytes : Int
    estimated_bytes : Int
    decoded_frames : Int
    source_pixels : Int
    roundtrip_equal : Bool
    palette_error : Int
    lzw_saving_per_mille : Int
    } derive(
    Debug
    )

    BenchmarkResult::decoded_frames

    fn BenchmarkResult::decoded_frames(self : BenchmarkResult) -> Int

    BenchmarkResult::encoded_bytes

    fn BenchmarkResult::encoded_bytes(self : BenchmarkResult) -> Int

    BenchmarkResult::estimated_bytes

    fn BenchmarkResult::estimated_bytes(self : BenchmarkResult) -> Int

    BenchmarkResult::lzw_saving_per_mille

    fn BenchmarkResult::lzw_saving_per_mille(self : BenchmarkResult) -> Int

    BenchmarkResult::palette_error

    fn BenchmarkResult::palette_error(self : BenchmarkResult) -> Int

    BenchmarkResult::roundtrip_equal

    fn BenchmarkResult::roundtrip_equal(self : BenchmarkResult) -> Bool

    BenchmarkResult::source_pixels

    fn BenchmarkResult::source_pixels(self : BenchmarkResult) -> Int

    BenchmarkResult::summary

    fn BenchmarkResult::summary(self : BenchmarkResult) -> String

    Format a stable one-line benchmark record for CI artifacts.

    BenchmarkResult::workload

    BenchmarkWorkload

    pub(all) struct BenchmarkWorkload {
    width : Int
    height : Int
    frames : Int
    palette_colors : Int
    delay_cs : Int
    } derive(
    Debug
    )

    Deterministic benchmark workload for GIF encoding, decoding, and quantization.

    BenchmarkWorkload::colors

    fn BenchmarkWorkload::colors(self : BenchmarkWorkload, count : Int) -> BenchmarkWorkload

    BenchmarkWorkload::default

    BenchmarkWorkload::frame_count

    fn BenchmarkWorkload::frame_count(self : BenchmarkWorkload, count : Int) -> BenchmarkWorkload

    BenchmarkWorkload::size

    fn BenchmarkWorkload::size(self : BenchmarkWorkload, width : Int, height : Int) -> BenchmarkWorkload

    BlendMode

    pub(all) enum BlendMode {
    Normal
    Multiply
    Screen
    Overlay
    Darken
    Lighten
    Add
    Subtract
    Difference
    Exclude
    } derive(Eq,
    Debug
    )

    Blend operators used by compositing and layer pipelines.

    Canvas

    pub(all) struct Canvas {
    width : Int
    height : Int
    pixels : Array[Rgba]
    } derive(
    Debug
    )

    An image plane with one RGBA pixel for each coordinate.

    Pixels are stored in row-major order: x + y * width.

    Canvas::active_quadrant

    fn Canvas::active_quadrant(self : Canvas) -> Int

    Return the most visually active quadrant of a canvas.

    Canvas::adjust

    fn Canvas::adjust(self : Canvas, adjustment : ColorAdjustment) -> Canvas

    Apply brightness, contrast, saturation, hue, and alpha adjustments.

    Canvas::affine

    fn Canvas::affine(self : Canvas, transform : Affine2i) -> Canvas

    Apply an affine transform with nearest-neighbor sampling and transparent fill.

    Canvas::affine_rotate

    fn Canvas::affine_rotate(self : Canvas, rotation : CanvasRotation) -> Canvas

    Rotate around the canvas center using a right-angle approximation.

    Canvas::all_channel_stats

    fn Canvas::all_channel_stats(self : Canvas) -> Array[ChannelStats]

    Calculate all five standard channels in one pass.

    Canvas::alpha_mask

    fn Canvas::alpha_mask(self : Canvas, threshold? : Byte) -> Canvas

    Build an alpha-only mask where visible pixels become white.

    Canvas::alpha_threshold

    fn Canvas::alpha_threshold(self : Canvas, threshold : Byte, soft : Bool) -> Canvas

    Threshold an alpha mask into hard or soft coverage.

    Canvas::apply_mask

    fn Canvas::apply_mask(self : Canvas, mask : Canvas) -> Canvas

    Multiply a canvas alpha channel by a mask alpha channel.

    Canvas::apply_matrix

    fn Canvas::apply_matrix(self : Canvas, matrix : ColorMatrix) -> Canvas

    Canvas::apply_patch

    fn Canvas::apply_patch(self : Canvas, patch : PixelPatch) -> Int

    Apply a patch with clipping and alpha compositing.

    Canvas::apply_scale_plan

    fn Canvas::apply_scale_plan(self : Canvas, plan : ScalePlan) -> Canvas

    Execute a scale plan with stable nearest-neighbor behavior.

    Canvas::average_color

    fn Canvas::average_color(self : Canvas) -> Rgba

    Compute the arithmetic mean color of all pixels.

    Canvas::binary_mask

    fn Canvas::binary_mask(self : Canvas, threshold : Byte) -> Canvas

    Build a binary alpha mask with an explicit threshold.

    Canvas::blend

    fn Canvas::blend(self : Canvas, layer : Canvas, mode : BlendMode) -> Canvas

    Apply a layer using a blend mode over every overlapping pixel.

    Canvas::blend_pixel

    fn Canvas::blend_pixel(self : Canvas, x~ : Int, y~ : Int, color~ : Rgba) -> Bool

    Alpha-blend one pixel. Returns false when the coordinate is outside the canvas.

    Canvas::blit

    fn Canvas::blit(self : Canvas, source : Canvas, destination_x~ : Int, destination_y~ : Int) -> Int

    Copy a source canvas with alpha compositing and clipping.

    Canvas::blur

    fn Canvas::blur(self : Canvas, radius? : Int) -> Canvas

    Canvas::border

    fn Canvas::border(self : Canvas, thickness : Int, color : Rgba) -> Canvas

    Draw a soft rectangular border around the visible image.

    Canvas::border_samples

    fn Canvas::border_samples(self : Canvas) -> Array[Rgba]

    Return a one-pixel border sample in clockwise order.

    Canvas::bounds

    fn Canvas::bounds(self : Canvas) -> GifRect

    Return a clipped rectangle as a value suitable for frame metadata.

    Canvas::canonicalize_transparency

    fn Canvas::canonicalize_transparency(self : Canvas) -> Canvas

    Replace transparent RGB values with a canonical zero color.

    Canvas::channel_stats

    fn Canvas::channel_stats(self : Canvas, channel : ColorChannel) -> ChannelStats

    Calculate histogram statistics for one color channel.

    Canvas::chroma_key

    fn Canvas::chroma_key(self : Canvas, key : Rgba, tolerance : Int) -> Canvas

    Keep only pixels whose color is within a Manhattan distance of the key.

    Canvas::close_mask

    fn Canvas::close_mask(self : Canvas, radius : Int, mode? : MorphologyMode, threshold? : Byte) -> Canvas

    Close small holes in an alpha mask: dilate then erode.

    Canvas::color_frequencies

    fn Canvas::color_frequencies(self : Canvas, limit : Int) -> Array[(Rgba, Int)]

    Return an indexed color frequency table sorted by descending frequency.

    Canvas::colorize_channel

    fn Canvas::colorize_channel(self : Canvas, channel : ColorChannel, tint : Rgba, strength : Int) -> Canvas

    Mix an RGB channel image with a tint while retaining the source alpha.

    Canvas::common_color_count

    fn Canvas::common_color_count(self : Canvas, minimum_count : Int) -> Int

    Count colors that survive a minimum frequency threshold.

    Canvas::complexity

    fn Canvas::complexity(self : Canvas) -> CanvasComplexity

    Estimate visual complexity using exact colors, edges, and luma spread.

    Canvas::components

    fn Canvas::components(self : Canvas, threshold? : Byte, minimum_pixels? : Int) -> Array[ComponentInfo]

    Find four-connected opaque components for sprite and mask extraction.

    Canvas::contain

    fn Canvas::contain(self : Canvas, width~ : Int, height~ : Int, fill? : Rgba) -> Canvas

    Nearest-neighbor scale to fit inside a box, preserving aspect ratio.

    Canvas::contrast_mask

    fn Canvas::contrast_mask(self : Canvas, threshold : Int) -> Canvas

    Detect high-contrast pixels into an alpha mask.

    Canvas::convolve

    fn Canvas::convolve(self : Canvas, kernel : ConvolutionKernel) -> Canvas

    Apply a convolution kernel with edge-clamped sampling.

    Canvas::copy

    fn Canvas::copy(self : Canvas) -> Canvas

    Canvas::corners

    fn Canvas::corners(self : Canvas) -> Array[Rgba]

    Return the four corner colors in clockwise order.

    Canvas::count_color

    fn Canvas::count_color(self : Canvas, color : Rgba) -> Int

    Count exact pixel matches.

    Canvas::cover

    fn Canvas::cover(self : Canvas, width~ : Int, height~ : Int) -> Canvas

    Nearest-neighbor scale to cover a box, cropping the overflow.

    Canvas::coverage_per_mille

    fn Canvas::coverage_per_mille(self : Canvas, threshold : Byte) -> Int

    Return the visible fraction of a mask in per mille.

    Canvas::crop

    fn Canvas::crop(self : Canvas, x~ : Int, y~ : Int, width~ : Int, height~ : Int) -> Canvas

    Crop a rectangle. Pixels outside the source are filled with transparent black.

    Canvas::diff_patch

    fn Canvas::diff_patch(self : Canvas, base : Canvas, threshold? : Int) -> PixelPatch?

    Extract a changed rectangle from source relative to base.

    Canvas::digest

    fn Canvas::digest(self : Canvas) -> CanvasDigest

    Compute a stable digest for cache keys and regression reports.

    Canvas::dilate

    fn Canvas::dilate(self : Canvas, radius : Int, mode? : MorphologyMode, threshold? : Byte) -> Canvas

    Expand opaque regions using a square, diamond, or cross neighborhood.

    Canvas::dominant_color

    fn Canvas::dominant_color(self : Canvas) -> Rgba

    Return the most common exact color. This intentionally keeps the fast path small; palette quantization remains the right choice for large images.

    Canvas::downsample

    fn Canvas::downsample(self : Canvas, factor : Int) -> Canvas

    Downsample by an integer factor using box averaging.

    Canvas::draw_circle

    fn Canvas::draw_circle(self : Canvas, center_x~ : Int, center_y~ : Int, radius~ : Int, color~ : Rgba) -> Int

    Draw a circle outline using a midpoint-style eight-way rasterization.

    Canvas::draw_dashed_line

    fn Canvas::draw_dashed_line(self : Canvas, start_x : Int, start_y : Int, end_x : Int, end_y : Int, dash : Int, gap : Int, color : Rgba) -> Int

    Draw a dashed line with a stable on/off pattern.

    Canvas::draw_line

    fn Canvas::draw_line(self : Canvas, x0~ : Int, y0~ : Int, x1~ : Int, y1~ : Int, color~ : Rgba) -> Int

    Draw a clipped Bresenham line.

    Canvas::draw_polygon

    fn Canvas::draw_polygon(self : Canvas, points : ArrayView[(Int, Int)], color : Rgba) -> Int

    Draw a regular polygon outline with a deterministic integer approximation.

    Canvas::draw_quadratic

    fn Canvas::draw_quadratic(self : Canvas, start : Point2i, control : Point2i, end : Point2i, color : Rgba, samples : Int) -> Int

    Draw a quadratic Bezier curve in one operation.

    Canvas::draw_rect

    fn Canvas::draw_rect(self : Canvas, x~ : Int, y~ : Int, width~ : Int, height~ : Int, color~ : Rgba) -> Int

    Draw a rectangle outline. Coordinates are inclusive.

    Canvas::draw_transformed

    fn Canvas::draw_transformed(self : Canvas, source : Canvas, transform : Affine2i) -> Int

    Place a transformed canvas at a destination with clipping.

    Canvas::duotone

    fn Canvas::duotone(self : Canvas, shadow : Rgba, highlight : Rgba) -> Canvas

    Map luma to a two-color duotone palette.

    Canvas::edge_map

    fn Canvas::edge_map(self : Canvas) -> Canvas

    Canvas::emboss

    fn Canvas::emboss(self : Canvas) -> Canvas

    Canvas::erode

    fn Canvas::erode(self : Canvas, radius : Int, mode? : MorphologyMode, threshold? : Byte) -> Canvas

    Contract opaque regions while preserving the source color where possible.

    Canvas::extract_channel

    fn Canvas::extract_channel(self : Canvas, channel : ColorChannel) -> Canvas

    Extract a channel as a grayscale canvas.

    Canvas::fade_to

    fn Canvas::fade_to(self : Canvas, target : Canvas, numerator : Int, denominator : Int) -> Canvas

    Canvas::feather_mask

    fn Canvas::feather_mask(self : Canvas, radius : Int) -> Canvas

    Build a feathered alpha mask from an input canvas.

    Canvas::fill

    fn Canvas::fill(self : Canvas, color : Rgba) -> Unit

    Fill the entire canvas with a color.

    Canvas::fill_circle

    fn Canvas::fill_circle(self : Canvas, center_x~ : Int, center_y~ : Int, radius~ : Int, color~ : Rgba) -> Int

    Fill a circle using an integer distance test.

    Canvas::fill_polygon

    fn Canvas::fill_polygon(self : Canvas, points : ArrayView[(Int, Int)], color : Rgba) -> Int

    Fill a clipped polygon using an integer scanline test.

    Canvas::fill_rect

    fn Canvas::fill_rect(self : Canvas, x~ : Int, y~ : Int, width~ : Int, height~ : Int, color~ : Rgba) -> Int

    Fill a clipped rectangle and return the number of pixels written.

    Canvas::fill_regular_polygon

    fn Canvas::fill_regular_polygon(self : Canvas, center_x : Int, center_y : Int, radius : Int, sides : Int, color : Rgba) -> Int

    Fill a regular polygon centered at a coordinate.

    Canvas::fill_rounded_rect

    fn Canvas::fill_rounded_rect(self : Canvas, x~ : Int, y~ : Int, width~ : Int, height~ : Int, radius~ : Int, color~ : Rgba) -> Int

    Fill a rectangle with rounded corners using a distance test.

    Canvas::film_grade

    fn Canvas::film_grade(self : Canvas, contrast : Int, warmth : Int) -> Canvas

    Apply a film-like grade while preserving alpha and dimensions.

    Canvas::fit_affine

    fn Canvas::fit_affine(self : Canvas, width : Int, height : Int) -> Canvas

    Fit a source into an output rectangle using a center translation.

    Canvas::fit_resample

    fn Canvas::fit_resample(self : Canvas, width : Int, height : Int, filter : ResampleFilter) -> Canvas

    Fit an image to an exact output size using the chosen filter.

    Canvas::flatten_alpha

    fn Canvas::flatten_alpha(self : Canvas, fill~ : Rgba) -> Canvas

    Replace transparent pixels with fill, keeping all visible pixels.

    Canvas::flip_horizontal

    fn Canvas::flip_horizontal(self : Canvas) -> Canvas

    Return a horizontally mirrored copy.

    Canvas::flip_vertical

    fn Canvas::flip_vertical(self : Canvas) -> Canvas

    Return a vertically mirrored copy.

    Canvas::flood_fill

    fn Canvas::flood_fill(self : Canvas, x : Int, y : Int, replacement : Rgba, tolerance? : Int) -> Int

    Paint a connected region starting at a coordinate, returning changed pixels.

    Canvas::fractal_noise

    fn Canvas::fractal_noise(self : Canvas, amount : Int, seed : Int) -> Canvas

    Layer two scales of value noise for a smoother texture.

    Canvas::frame_rect

    fn Canvas::frame_rect(self : Canvas, x~ : Int, y~ : Int, width~ : Int, height~ : Int, border : Rgba, fill : Rgba, thickness : Int) -> Int

    Fill an axis-aligned rectangle with a border and an optional interior.

    Canvas::gamma

    fn Canvas::gamma(self : Canvas, channel : ColorChannel, gamma_per_mille : Int) -> Canvas

    Apply a gamma curve using a fixed integer lookup table.

    Canvas::gaussian_blur

    fn Canvas::gaussian_blur(self : Canvas) -> Canvas

    Canvas::get

    fn Canvas::get(self : Canvas, x~ : Int, y~ : Int) -> Rgba?

    Canvas::gradient

    fn Canvas::gradient(self : Canvas, mode : GradientMode, first : Rgba, second : Rgba) -> Canvas

    Fill a canvas with a two-color deterministic gradient.

    Canvas::gradient_stops

    fn Canvas::gradient_stops(self : Canvas, mode : GradientMode, stops : ArrayView[GradientStop]) -> Canvas

    Fill using multiple stops. Positions are integer percentages 0..1000.

    Canvas::grain

    fn Canvas::grain(self : Canvas, amount : Int, seed? : Int) -> Canvas

    Add deterministic grain using a local linear congruential generator.

    Canvas::grayscale

    fn Canvas::grayscale(self : Canvas) -> Canvas

    Canvas::grid

    fn Canvas::grid(self : Canvas, spacing : Int, color : Rgba) -> Canvas

    Add a regular grid useful for pixel-art previews.

    Canvas::hash

    fn Canvas::hash(self : Canvas) -> UInt

    A stable non-cryptographic hash for cache keys and snapshot tests.

    Canvas::height

    fn Canvas::height(self : Canvas) -> Int

    Canvas::invert

    fn Canvas::invert(self : Canvas) -> Canvas

    Canvas::invert_mask

    fn Canvas::invert_mask(self : Canvas) -> Canvas

    Invert a mask while retaining its RGB placeholder.

    Canvas::is_opaque

    fn Canvas::is_opaque(self : Canvas) -> Bool

    Return true when every pixel has an opaque alpha channel.

    Canvas::kaleidoscope

    fn Canvas::kaleidoscope(self : Canvas, sectors : Int) -> Canvas

    Reflect four quadrants around the center to create a symmetric sprite.

    Canvas::laplacian

    fn Canvas::laplacian(self : Canvas) -> Canvas

    Canvas::len

    fn Canvas::len(self : Canvas) -> Int

    Canvas::levels

    fn Canvas::levels(self : Canvas, channel : ColorChannel, black : Int, white : Int) -> Canvas

    Stretch a channel between black and white points.

    Canvas::lookup_channel

    fn Canvas::lookup_channel(self : Canvas, channel : ColorChannel, table : ArrayView[Byte]) -> Canvas

    Apply a 256-entry lookup table to one channel.

    Canvas::luma_bands

    fn Canvas::luma_bands(self : Canvas, bands : Int) -> Canvas

    Quantize luma into a small number of stable bands.

    Canvas::map_channel

    fn Canvas::map_channel(self : Canvas, channel : ColorChannel, gain_per_mille : Int, bias : Int) -> Canvas

    Apply an affine channel mapping with integer gain and bias.

    Canvas::map_colors

    fn Canvas::map_colors(self : Canvas, transform : ColorTransform) -> Canvas

    Canvas::mask_stats

    fn Canvas::mask_stats(self : Canvas, threshold : Byte) -> MaskStats

    Collect coverage information without reading RGB channels.

    Canvas::matte

    fn Canvas::matte(self : Canvas, color : Rgba) -> Canvas

    Composite an image over a matte color using its alpha channel.

    Canvas::median_filter

    fn Canvas::median_filter(self : Canvas, radius? : Int) -> Canvas

    Remove isolated salt-and-pepper noise with a median neighborhood filter.

    Canvas::mirror

    fn Canvas::mirror(self : Canvas, horizontal : Bool, vertical : Bool) -> Canvas

    Mirror an image around its vertical and horizontal axes.

    Canvas::new

    fn Canvas::new(width~ : Int, height~ : Int, fill~ : Rgba) -> Canvas

    Canvas::noise

    fn Canvas::noise(self : Canvas, amount : Int, seed : Int, blend : NoiseBlend) -> Canvas

    Add deterministic noise with a per-channel strength.

    Canvas::noise_dither

    fn Canvas::noise_dither(self : Canvas, amount : Int, seed : Int) -> Canvas

    Add blue-noise-like ordered variation before palette quantization.

    Canvas::normalize_luma

    fn Canvas::normalize_luma(self : Canvas, black? : Int, white? : Int) -> Canvas

    Stretch the luma range between the requested black and white points.

    Canvas::opaque_bounds

    fn Canvas::opaque_bounds(self : Canvas, alpha_threshold? : Byte) -> GifRect?

    Find the non-transparent bounds of a canvas.

    Canvas::opaque_components

    fn Canvas::opaque_components(self : Canvas, threshold? : Byte) -> Array[GifRect]

    Find connected opaque components using four-neighbor flood fill.

    Canvas::open_mask

    fn Canvas::open_mask(self : Canvas, radius : Int, mode? : MorphologyMode, threshold? : Byte) -> Canvas

    Open an alpha mask: erode then dilate.

    Canvas::ordered_dither

    fn Canvas::ordered_dither(self : Canvas, levels? : Int) -> Canvas

    Apply a 2x2 ordered threshold matrix to a grayscale representation.

    Canvas::outline

    fn Canvas::outline(self : Canvas, radius? : Int, mode? : MorphologyMode, threshold? : Byte) -> Canvas

    Return the newly exposed outline of an alpha shape.

    Canvas::overlay

    fn Canvas::overlay(self : Canvas, source : Canvas, left~ : Int, top~ : Int) -> Canvas

    Composite a source image over this canvas at an offset.

    Canvas::pad

    fn Canvas::pad(self : Canvas, left~ : Int, top~ : Int, right~ : Int, bottom~ : Int, fill? : Rgba) -> Canvas

    Add transparent or colored margins around a canvas.

    Canvas::pattern

    fn Canvas::pattern(self : Canvas, cell_size : Int, first : Rgba, second : Rgba, stripes : Bool) -> Canvas

    Paint a repeating checker or stripe pattern into a copy of a canvas.

    Canvas::pixel_aspect

    fn Canvas::pixel_aspect(self : Canvas, horizontal_per_mille : Int, vertical_per_mille : Int) -> Canvas

    Use pixel aspect compensation for low-resolution GIF previews.

    Canvas::pixel_histogram

    fn Canvas::pixel_histogram(self : Canvas) -> PixelHistogram

    Count all pixel channels, including transparent colors, for diagnostics.

    Canvas::pixelate

    fn Canvas::pixelate(self : Canvas, block_size : Int) -> Canvas

    Reduce each pixel to a block average, useful for privacy previews and deliberately pixelated GIF effects.

    Canvas::pixels

    fn Canvas::pixels(self : Canvas) -> ArrayView[Rgba]

    Canvas::posterize

    fn Canvas::posterize(self : Canvas, levels : Int) -> Canvas

    Reduce each channel to a fixed number of evenly spaced levels.

    Canvas::posterize_smooth

    fn Canvas::posterize_smooth(self : Canvas, levels : Int, smooth : Bool) -> Canvas

    Apply a hard posterized tone curve and optional smoothing.

    Canvas::premultiplied

    fn Canvas::premultiplied(self : Canvas) -> Canvas

    Premultiply RGB channels, a useful representation before interpolation.

    Canvas::preview

    fn Canvas::preview(self : Canvas, cell_size? : Int) -> Canvas

    Place a canvas over a checkerboard transparency preview.

    Canvas::quality_against

    fn Canvas::quality_against(self : Canvas, reference : Canvas) -> QualityMetrics

    Compare two canvases using all four channels. psnr_milli is a fixed-point approximation that avoids floating-point differences in test snapshots.

    Canvas::range_mask

    fn Canvas::range_mask(self : Canvas, channel : ColorChannel, low : Byte, high : Byte) -> Canvas

    Compute a binary mask from a channel and an inclusive range.

    Canvas::remove_small_components

    fn Canvas::remove_small_components(self : Canvas, minimum_pixels : Int, threshold? : Byte) -> Canvas

    Remove connected components smaller than a pixel threshold.

    Canvas::replace_channel

    fn Canvas::replace_channel(self : Canvas, channel : ColorChannel, source : Canvas) -> Canvas

    Replace a channel with values read from a grayscale canvas.

    Canvas::replace_color

    fn Canvas::replace_color(self : Canvas, from~ : Rgba, to~ : Rgba) -> Int

    Replace every exact color match and return the number of changed pixels.

    Canvas::replace_near

    fn Canvas::replace_near(self : Canvas, source : Rgba, target : Rgba, tolerance : Int) -> Int

    Replace colors in a tolerance radius while retaining the source alpha.

    Canvas::resample

    fn Canvas::resample(self : Canvas, width~ : Int, height~ : Int, filter? : ResampleFilter) -> Canvas

    Resize with an explicit deterministic filter.

    Canvas::resample_with_report

    fn Canvas::resample_with_report(self : Canvas, width~ : Int, height~ : Int, filter? : ResampleFilter) -> (Canvas, ResampleReport)

    Resize and return metrics useful for export logs.

    Canvas::resize_nearest

    fn Canvas::resize_nearest(self : Canvas, width~ : Int, height~ : Int) -> Canvas

    Resize with nearest-neighbor sampling, suitable for pixel art and thumbnails.

    Canvas::rotate

    fn Canvas::rotate(self : Canvas, rotation : CanvasRotation) -> Canvas

    Rotate a canvas without interpolation.

    Canvas::rotate180

    fn Canvas::rotate180(self : Canvas) -> Canvas

    Rotate by 180 degrees.

    Canvas::rotate270

    fn Canvas::rotate270(self : Canvas) -> Canvas

    Rotate counter-clockwise, or equivalently three clockwise turns.

    Canvas::rotate90

    fn Canvas::rotate90(self : Canvas) -> Canvas

    Rotate clockwise. The old top-left pixel becomes the top-right pixel.

    Canvas::rotate_fit

    fn Canvas::rotate_fit(self : Canvas, rotation : CanvasRotation, fill : Rgba) -> Canvas

    Rotate an image by a right-angle amount and optionally center it on a canvas.

    Canvas::sample

    fn Canvas::sample(self : Canvas, x~ : Int, y~ : Int) -> Rgba

    Sample a pixel with integer coordinates, returning transparent black outside.

    Canvas::sampled

    fn Canvas::sampled(self : Canvas, width~ : Int, height~ : Int, mode? : SamplingMode) -> Canvas

    Downsample or upscale using a selectable integer sampling policy.

    Canvas::scale_alpha

    fn Canvas::scale_alpha(self : Canvas, alpha : Byte) -> Canvas

    Return a copy with every alpha channel multiplied by alpha.

    Canvas::scale_centered

    fn Canvas::scale_centered(self : Canvas, scale_per_mille : Int) -> Canvas

    Scale a canvas around its center with nearest-neighbor sampling.

    Canvas::sepia

    fn Canvas::sepia(self : Canvas, strength : Int) -> Canvas

    A compact color grade commonly used for sticker exports.

    Canvas::set

    fn Canvas::set(self : Canvas, x~ : Int, y~ : Int, color~ : Rgba) -> Bool

    Canvas::sharpen

    fn Canvas::sharpen(self : Canvas) -> Canvas

    Canvas::silhouette

    fn Canvas::silhouette(self : Canvas, color? : Rgba, threshold? : Byte) -> Canvas

    Make an opaque silhouette using the source alpha channel.

    Canvas::smooth3

    fn Canvas::smooth3(self : Canvas) -> Canvas

    Smooth a canvas using a separable three-tap kernel.

    Canvas::sobel

    fn Canvas::sobel(self : Canvas, threshold? : Int) -> Canvas

    Return the Sobel gradient magnitude as an opaque grayscale canvas.

    Canvas::spatial_stats

    fn Canvas::spatial_stats(self : Canvas) -> SpatialStats

    Calculate center, corner, quadrant, and luma variance in one scan.

    Canvas::stats

    fn Canvas::stats(self : Canvas) -> CanvasStats

    Canvas::stripe_shift

    fn Canvas::stripe_shift(self : Canvas, stripe_height : Int, offset : Int) -> Canvas

    Extract evenly spaced stripes for a glitch-style animated effect.

    Canvas::stroke_polygon

    fn Canvas::stroke_polygon(self : Canvas, vertices : ArrayView[(Int, Int)], color : Rgba) -> Int

    Create an outline-only version of a polygon.

    Canvas::stroke_polyline

    fn Canvas::stroke_polyline(self : Canvas, polyline : Polyline, color : Rgba, thickness : Int) -> Int

    Draw an anti-aliased-looking polyline using integer supersampling.

    Canvas::summarize

    fn Canvas::summarize(self : Canvas, rect : GifRect) -> RegionSummary

    Summarize a clipped logical rectangle. Empty rectangles return transparent black and zero counts, which keeps analysis pipelines total.

    Canvas::swatch

    fn Canvas::swatch(self : Canvas, columns : Int, rows : Int) -> Canvas

    Return a compact visual swatch made from dominant colors.

    Canvas::temperature

    fn Canvas::temperature(self : Canvas, shift : Int) -> Canvas

    Apply a warm/cool color-temperature shift.

    Canvas::threshold

    fn Canvas::threshold(self : Canvas, cutoff : Int, softness? : Int) -> Canvas

    A hard threshold with optional soft transition around the cutoff.

    Canvas::thumbnail

    fn Canvas::thumbnail(self : Canvas, max_edge : Int, mode? : SamplingMode) -> Canvas

    Scale the long edge to max_edge, preserving aspect ratio.

    Canvas::tile

    fn Canvas::tile(self : Canvas, width~ : Int, height~ : Int, mode? : TileMode) -> Canvas

    Tile a canvas into an output rectangle.

    Canvas::tint

    fn Canvas::tint(self : Canvas, tint~ : Rgba, strength~ : Int) -> Canvas

    Canvas::to_gray

    fn Canvas::to_gray(self : Canvas) -> Canvas

    Convert a canvas to a grayscale alpha-preserving view.

    Canvas::to_image_data

    fn Canvas::to_image_data(self : Canvas) ->
    ImageData

    Convert a Canvas back to mizchi/image RGBA ImageData.

    Canvas::to_rgb

    fn Canvas::to_rgb(self : Canvas) -> Canvas

    Crop a canvas to a rectangular PPM-friendly RGB view.

    Canvas::to_rgba_bytes

    fn Canvas::to_rgba_bytes(self : Canvas) -> Bytes

    Serialize pixels as tightly packed RGBA bytes.

    Canvas::tone_map

    fn Canvas::tone_map(self : Canvas, mode : ToneMap, exposure : Int) -> Canvas

    Apply a tone map to RGB channels while preserving alpha.

    Canvas::translate

    fn Canvas::translate(self : Canvas, offset_x : Int, offset_y : Int, mode? : TileMode) -> Canvas

    Translate a canvas with explicit wrapping semantics.

    Canvas::trim_transparent

    fn Canvas::trim_transparent(self : Canvas, alpha_threshold? : Byte) -> Canvas

    Crop transparent margins. An empty canvas returns a 1x1 transparent canvas.

    Canvas::unpremultiplied

    fn Canvas::unpremultiplied(self : Canvas) -> Canvas

    Unpremultiply RGB channels after compositing.

    Canvas::unsharp3

    fn Canvas::unsharp3(self : Canvas, amount : Int) -> Canvas

    Unsharp-mask a canvas using the smooth3 pass.

    Canvas::unsharp_mask

    fn Canvas::unsharp_mask(self : Canvas, amount? : Int) -> Canvas

    Canvas::upscale

    fn Canvas::upscale(self : Canvas, factor : Int) -> Canvas

    Upsample by an integer factor using nearest pixels for crisp sprites.

    Canvas::vignette

    fn Canvas::vignette(self : Canvas, options? : VignetteOptions) -> Canvas

    Apply a radial falloff over a canvas.

    Canvas::width

    fn Canvas::width(self : Canvas) -> Int

    Canvas::write_patch

    fn Canvas::write_patch(self : Canvas, patch : PixelPatch) -> Int

    Apply a patch by replacing pixels rather than alpha blending.

    Canvas::yuv_adjust

    fn Canvas::yuv_adjust(self : Canvas, luma_gain : Int, chroma_gain : Int) -> Canvas

    Adjust luma and chroma independently without floating-point behavior.

    Canvas::yuv_roundtrip

    fn Canvas::yuv_roundtrip(self : Canvas) -> Canvas

    Convert a canvas through YUV with a configurable chroma subsampling step.

    CanvasComplexity

    pub(all) struct CanvasComplexity {
    pixels : Int
    opaque_pixels : Int
    unique_colors : Int
    edge_pixels : Int
    entropy_milli : Int
    luma_range : Int
    } derive(
    Debug
    )

    Structural analysis for choosing palettes, delta encoding, and previews.

    CanvasComplexity::edge_pixels

    fn CanvasComplexity::edge_pixels(self : CanvasComplexity) -> Int

    CanvasComplexity::entropy_milli

    fn CanvasComplexity::entropy_milli(self : CanvasComplexity) -> Int

    CanvasComplexity::luma_range

    fn CanvasComplexity::luma_range(self : CanvasComplexity) -> Int

    CanvasComplexity::opaque_pixels

    fn CanvasComplexity::opaque_pixels(self : CanvasComplexity) -> Int

    CanvasComplexity::pixels

    fn CanvasComplexity::pixels(self : CanvasComplexity) -> Int

    CanvasComplexity::unique_colors

    fn CanvasComplexity::unique_colors(self : CanvasComplexity) -> Int

    CanvasDigest

    pub(all) struct CanvasDigest {
    hash : UInt
    pixels : Int
    width : Int
    height : Int
    alpha_pixels : Int
    } derive(
    Debug
    )

    Export-oriented canvas helpers for deterministic previews and fixtures.

    CanvasDigest::alpha_pixels

    fn CanvasDigest::alpha_pixels(self : CanvasDigest) -> Int

    CanvasDigest::hash

    fn CanvasDigest::hash(self : CanvasDigest) -> UInt

    CanvasDigest::height

    fn CanvasDigest::height(self : CanvasDigest) -> Int

    CanvasDigest::pixels

    fn CanvasDigest::pixels(self : CanvasDigest) -> Int

    CanvasDigest::width

    fn CanvasDigest::width(self : CanvasDigest) -> Int

    CanvasPipeline

    pub(all) struct CanvasPipeline {
    stages : Array[PipelineStage]
    } derive(
    Debug
    )

    CanvasPipeline::add

    CanvasPipeline::apply

    fn CanvasPipeline::apply(self : CanvasPipeline, canvas : Canvas) -> Canvas

    Apply all stages in insertion order.

    CanvasPipeline::apply_animation

    fn CanvasPipeline::apply_animation(self : CanvasPipeline, animation : Animation) -> Animation

    Apply the same visual pipeline to every animation frame.

    CanvasPipeline::apply_animation_fit

    fn CanvasPipeline::apply_animation_fit(self : CanvasPipeline, animation : Animation, width : Int, height : Int) -> Animation

    A pipeline variant that can resize the logical screen to the final output.

    CanvasPipeline::blur

    fn CanvasPipeline::blur(self : CanvasPipeline, radius : Int) -> CanvasPipeline

    CanvasPipeline::describe

    fn CanvasPipeline::describe(self : CanvasPipeline) -> String

    Return a human-readable stage list for CLI help and diagnostics.

    CanvasPipeline::gray

    CanvasPipeline::invert

    CanvasPipeline::new

    CanvasPipeline::output_hash

    fn CanvasPipeline::output_hash(self : CanvasPipeline, canvas : Canvas) -> UInt

    Compute a simple deterministic checksum after all stages.

    CanvasPipeline::posterize

    fn CanvasPipeline::posterize(self : CanvasPipeline, levels : Int) -> CanvasPipeline

    CanvasPipeline::report

    fn CanvasPipeline::report(self : CanvasPipeline, canvas : Canvas) -> PipelineReport

    Return an auditable report for a single pipeline execution.

    CanvasPipeline::resize

    fn CanvasPipeline::resize(self : CanvasPipeline, width : Int, height : Int) -> CanvasPipeline

    CanvasPipeline::stage_count

    fn CanvasPipeline::stage_count(self : CanvasPipeline) -> Int

    CanvasPipeline::then

    Compose independent pipelines without exposing mutable internals.

    CanvasPipeline::threshold

    fn CanvasPipeline::threshold(self : CanvasPipeline, level : Byte) -> CanvasPipeline

    CanvasRotation

    pub(all) enum CanvasRotation {
    Clockwise90
    HalfTurn
    Clockwise270
    } derive(Eq,
    Debug
    )

    A geometric transform that preserves the pixel grid.

    CanvasStats

    pub(all) struct CanvasStats {
    pixel_count : Int
    opaque_count : Int
    transparent_count : Int
    minimum_luma : Byte
    maximum_luma : Byte
    average_luma : Int
    } derive(
    Debug
    )

    Pixel summary used to choose quantization and preview settings.

    CanvasStats::average_luma

    fn CanvasStats::average_luma(self : CanvasStats) -> Int

    CanvasStats::maximum_luma

    fn CanvasStats::maximum_luma(self : CanvasStats) -> Byte

    CanvasStats::minimum_luma

    fn CanvasStats::minimum_luma(self : CanvasStats) -> Byte

    CanvasStats::opaque_count

    fn CanvasStats::opaque_count(self : CanvasStats) -> Int

    CanvasStats::pixel_count

    fn CanvasStats::pixel_count(self : CanvasStats) -> Int

    CanvasStats::transparent_count

    fn CanvasStats::transparent_count(self : CanvasStats) -> Int

    ChannelStats

    pub(all) struct ChannelStats {
    channel : ColorChannel
    minimum : Byte
    maximum : Byte
    mean : Int
    nonzero : Int
    histogram : Array[Int]
    } derive(
    Debug
    )

    ChannelStats::channel

    fn ChannelStats::channel(self : ChannelStats) -> ColorChannel

    ChannelStats::histogram

    fn ChannelStats::histogram(self : ChannelStats) -> ArrayView[Int]

    ChannelStats::maximum

    fn ChannelStats::maximum(self : ChannelStats) -> Byte

    ChannelStats::mean

    fn ChannelStats::mean(self : ChannelStats) -> Int

    ChannelStats::minimum

    fn ChannelStats::minimum(self : ChannelStats) -> Byte

    ChannelStats::nonzero

    fn ChannelStats::nonzero(self : ChannelStats) -> Int

    ColorAdjustment

    pub(all) struct ColorAdjustment {
    brightness : Int
    contrast : Int
    saturation : Int
    hue_degrees : Int
    alpha : Int
    } derive(
    Debug
    )

    Parameters for a deterministic color adjustment pass.

    ColorAdjustment::alpha

    fn ColorAdjustment::alpha(self : ColorAdjustment, value : Int) -> ColorAdjustment

    ColorAdjustment::brightness

    fn ColorAdjustment::brightness(self : ColorAdjustment, value : Int) -> ColorAdjustment

    ColorAdjustment::contrast

    fn ColorAdjustment::contrast(self : ColorAdjustment, value : Int) -> ColorAdjustment

    ColorAdjustment::default

    ColorAdjustment::hue

    fn ColorAdjustment::hue(self : ColorAdjustment, value : Int) -> ColorAdjustment

    ColorAdjustment::saturation

    fn ColorAdjustment::saturation(self : ColorAdjustment, value : Int) -> ColorAdjustment

    ColorBox

    ColorChannel

    pub(all) enum ColorChannel {
    RedChannel
    GreenChannel
    BlueChannel
    AlphaChannel
    LumaChannel
    } derive(Eq,
    Debug
    )

    Individual image channels used by masks, color grading, and analysis.

    ColorMatrix

    pub(all) struct ColorMatrix {
    values : Array[Int]
    } derive(
    Debug
    )

    A 4x5 color matrix stored in row-major order, scaled by 256.

    ColorMatrix::apply

    fn ColorMatrix::apply(self : ColorMatrix, color : Rgba) -> Rgba

    ColorMatrix::brightness

    fn ColorMatrix::brightness(value : Int) -> ColorMatrix

    ColorMatrix::from_values

    fn ColorMatrix::from_values(values : ArrayView[Int]) -> ColorMatrix

    ColorMatrix::grayscale

    fn ColorMatrix::grayscale() -> ColorMatrix

    ColorMatrix::identity

    fn ColorMatrix::identity() -> ColorMatrix

    ColorMatrix::values

    fn ColorMatrix::values(self : ColorMatrix) -> ArrayView[Int]

    ColorTransform

    pub(all) enum ColorTransform {
    Identity
    Grayscale
    Invert
    Opaque
    Transparent
    } derive(Eq,
    Debug
    )

    Apply a deterministic color transform selected by a small enum.

    ComponentInfo

    pub(all) struct ComponentInfo {
    label : Int
    pixels : Int
    left : Int
    top : Int
    right : Int
    bottom : Int
    } derive(
    Debug
    )

    ComponentInfo::bounds

    fn ComponentInfo::bounds(self : ComponentInfo) -> GifRect

    ComponentInfo::label

    fn ComponentInfo::label(self : ComponentInfo) -> Int

    ComponentInfo::pixels

    fn ComponentInfo::pixels(self : ComponentInfo) -> Int

    CompositeAlignment

    pub(all) enum CompositeAlignment {
    TopLeft
    Center
    BottomRight
    Tile
    } derive(Eq,
    Debug
    )

    Multi-animation composition helpers for stickers and screen-recording scenes.

    CompositeOptions

    pub(all) struct CompositeOptions {
    alignment : CompositeAlignment
    gap : Int
    background : Rgba
    loop_to_longest : Bool
    } derive(
    Debug
    )

    CompositeOptions::alignment

    CompositeOptions::background

    fn CompositeOptions::background(self : CompositeOptions, value : Rgba) -> CompositeOptions

    CompositeOptions::default

    CompositeOptions::gap

    fn CompositeOptions::gap(self : CompositeOptions, value : Int) -> CompositeOptions

    CompositeOptions::loop_to_longest

    fn CompositeOptions::loop_to_longest(self : CompositeOptions, value : Bool) -> CompositeOptions

    ContactSheetOptions

    pub(all) struct ContactSheetOptions {
    columns : Int
    cell_width : Int
    cell_height : Int
    gap : Int
    background : Rgba
    labels : Bool
    } derive(
    Debug
    )

    ContactSheetOptions::background

    ContactSheetOptions::cell

    fn ContactSheetOptions::cell(self : ContactSheetOptions, width : Int, height : Int) -> ContactSheetOptions

    ContactSheetOptions::columns

    fn ContactSheetOptions::columns(self : ContactSheetOptions, value : Int) -> ContactSheetOptions

    ContactSheetOptions::default

    ContactSheetOptions::gap

    ContactSheetOptions::with_labels

    fn ContactSheetOptions::with_labels(self : ContactSheetOptions, enabled : Bool) -> ContactSheetOptions

    ConvolutionKernel

    pub(all) struct ConvolutionKernel {
    width : Int
    height : Int
    weights : Array[Int]
    divisor : Int
    bias : Int
    } derive(
    Debug
    )

    A square or rectangular convolution kernel used by the image effects API. Weights and divisor are integer-scaled so results are reproducible on all MoonBit backends.

    ConvolutionKernel::bias

    fn ConvolutionKernel::bias(self : ConvolutionKernel) -> Int

    ConvolutionKernel::box_blur

    fn ConvolutionKernel::box_blur(size? : Int) -> ConvolutionKernel

    ConvolutionKernel::divisor

    fn ConvolutionKernel::divisor(self : ConvolutionKernel) -> Int

    ConvolutionKernel::edge

    ConvolutionKernel::emboss

    ConvolutionKernel::gaussian_3

    ConvolutionKernel::height

    fn ConvolutionKernel::height(self : ConvolutionKernel) -> Int

    ConvolutionKernel::laplacian

    ConvolutionKernel::new

    fn ConvolutionKernel::new(width~ : Int, height~ : Int, weights~ : ArrayView[Int], divisor~ : Int, bias~ : Int) -> ConvolutionKernel

    ConvolutionKernel::sharpen

    ConvolutionKernel::unsharp

    ConvolutionKernel::weights

    fn ConvolutionKernel::weights(self : ConvolutionKernel) -> ArrayView[Int]

    ConvolutionKernel::width

    fn ConvolutionKernel::width(self : ConvolutionKernel) -> Int

    DeltaPlan

    pub(all) struct DeltaPlan {
    policy : DeltaPolicy
    items : Array[DeltaPlanItem]
    full_pixels : Int
    selected_pixels : Int
    } derive(
    Debug
    )

    DeltaPlan::full_pixels

    fn DeltaPlan::full_pixels(self : DeltaPlan) -> Int

    DeltaPlan::is_worthwhile

    fn DeltaPlan::is_worthwhile(self : DeltaPlan, minimum_saving_per_mille : Int) -> Bool

    Estimate whether delta encoding is likely to improve the final GIF size.

    DeltaPlan::items

    DeltaPlan::largest_changes

    fn DeltaPlan::largest_changes(self : DeltaPlan, count : Int) -> Array[DeltaPlanItem]

    Find the highest activity frames in a delta plan.

    DeltaPlan::policy

    fn DeltaPlan::policy(self : DeltaPlan) -> DeltaPolicy

    DeltaPlan::saving_per_mille

    fn DeltaPlan::saving_per_mille(self : DeltaPlan) -> Int

    DeltaPlan::selected_pixels

    fn DeltaPlan::selected_pixels(self : DeltaPlan) -> Int

    DeltaPlanItem

    pub(all) struct DeltaPlanItem {
    frame_index : Int
    changed : Bool
    rect : GifRect?
    source_pixels : Int
    encoded_pixels : Int
    saving_per_mille : Int
    } derive(
    Debug
    )

    DeltaPlanItem::changed

    fn DeltaPlanItem::changed(self : DeltaPlanItem) -> Bool

    DeltaPlanItem::encoded_pixels

    fn DeltaPlanItem::encoded_pixels(self : DeltaPlanItem) -> Int

    DeltaPlanItem::frame_index

    fn DeltaPlanItem::frame_index(self : DeltaPlanItem) -> Int

    DeltaPlanItem::rect

    fn DeltaPlanItem::rect(self : DeltaPlanItem) -> GifRect?

    DeltaPlanItem::saving_per_mille

    fn DeltaPlanItem::saving_per_mille(self : DeltaPlanItem) -> Int

    DeltaPlanItem::source_pixels

    fn DeltaPlanItem::source_pixels(self : DeltaPlanItem) -> Int

    DeltaPolicy

    pub(all) enum DeltaPolicy {
    AlwaysFull
    AlwaysDelta
    Threshold(per_mille~ : Int)
    Budget(max_pixels~ : Int)
    } derive(Eq,
    Debug
    )

    Policy for selecting between full-frame and delta-frame encoding.

    DeltaStats

    pub(all) struct DeltaStats {
    frame_count : Int
    full_pixels : Int
    delta_pixels : Int
    changed_frames : Int
    } derive(
    Debug
    )

    DeltaStats::changed_frames

    fn DeltaStats::changed_frames(self : DeltaStats) -> Int

    DeltaStats::delta_pixels

    fn DeltaStats::delta_pixels(self : DeltaStats) -> Int

    DeltaStats::frame_count

    fn DeltaStats::frame_count(self : DeltaStats) -> Int

    DeltaStats::full_pixels

    fn DeltaStats::full_pixels(self : DeltaStats) -> Int

    DeltaStats::saving_per_mille

    fn DeltaStats::saving_per_mille(self : DeltaStats) -> Int

    DiagnosticLevel

    pub(all) enum DiagnosticLevel {
    Info
    Warning
    Error
    } derive(Eq,
    Debug
    )

    A validation level suitable for command-line diagnostics and CI reports.

    Disposal

    pub(all) enum Disposal {
    Keep
    Background
    Previous
    } derive(Eq,
    Debug
    )

    DisposalHint

    pub(all) enum DisposalHint {
    Preserve
    ClearToBackground
    RestorePrevious
    } derive(Eq,
    Debug
    )

    Compatibility helpers for common GIF producer and consumer conventions.

    DisposalHint::to_disposal

    fn DisposalHint::to_disposal(self : DisposalHint) -> Disposal

    DitherMode

    pub(all) enum DitherMode {
    NoDither
    Ordered2x2
    FloydSteinberg
    } derive(Eq,
    Debug
    )

    Palette selection mode for quantized frames.

    Easing

    pub(all) enum Easing {
    Linear
    Step
    EaseIn
    EaseOut
    EaseInOut
    SmoothStep
    SineLike
    Bounce
    Pulse
    } derive(Eq,
    Debug
    )

    Easing curves for timeline and motion interpolation.

    Easing::sample

    fn Easing::sample(self : Easing, numerator : Int, denominator : Int) -> Int

    EditReport

    pub(all) struct EditReport {
    input_frames : Int
    output_frames : Int
    removed_frames : Int
    duration_before : Int
    duration_after : Int
    } derive(
    Debug
    )

    EditReport::duration_after

    fn EditReport::duration_after(self : EditReport) -> Int

    EditReport::duration_before

    fn EditReport::duration_before(self : EditReport) -> Int

    EditReport::input_frames

    fn EditReport::input_frames(self : EditReport) -> Int

    EditReport::output_frames

    fn EditReport::output_frames(self : EditReport) -> Int

    EditReport::removed_frames

    fn EditReport::removed_frames(self : EditReport) -> Int

    EncodeOptions

    pub(all) struct EncodeOptions {
    max_colors : Int
    default_delay_cs : Int
    emit_loop_extension : Bool
    } derive(
    Debug
    )

    Controls palette size and timeline metadata emitted by the GIF encoder.

    EncodeOptions::colors

    fn EncodeOptions::colors(self : EncodeOptions) -> Int

    EncodeOptions::default

    fn EncodeOptions::default() -> EncodeOptions

    EncodeOptions::default_delay

    fn EncodeOptions::default_delay(self : EncodeOptions) -> Int

    EncodeOptions::loop_extension

    fn EncodeOptions::loop_extension(self : EncodeOptions) -> Bool

    EncodeOptions::new

    fn EncodeOptions::new(max_colors~ : Int, default_delay_cs~ : Int) -> EncodeOptions

    EncodeOptions::with_loop_extension

    fn EncodeOptions::with_loop_extension(self : EncodeOptions, enabled : Bool) -> EncodeOptions

    EncodeOutcome

    pub(all) struct EncodeOutcome {
    bytes : Bytes?
    error_code : String?
    error_message : String?
    } derive(
    Debug
    )

    Safe boundary helpers for applications that prefer explicit status values.

    EncodeOutcome::bytes

    fn EncodeOutcome::bytes(self : EncodeOutcome) -> Bytes?

    EncodeOutcome::error_code

    fn EncodeOutcome::error_code(self : EncodeOutcome) -> String?

    EncodeOutcome::error_message

    fn EncodeOutcome::error_message(self : EncodeOutcome) -> String?

    EncodeOutcome::ok

    fn EncodeOutcome::ok(self : EncodeOutcome) -> Bool

    ExportPlan

    pub(all) struct ExportPlan {
    profile : ExportProfile
    optimization : OptimizationOptions
    encode : EncodeOptions
    estimated_bytes : Int
    quality_target : Int
    } derive(
    Debug
    )

    ExportPlan::encode

    fn ExportPlan::encode(self : ExportPlan) -> EncodeOptions

    ExportPlan::estimated_bytes

    fn ExportPlan::estimated_bytes(self : ExportPlan) -> Int

    ExportPlan::optimization

    fn ExportPlan::optimization(self : ExportPlan) -> OptimizationOptions

    ExportPlan::profile

    fn ExportPlan::profile(self : ExportPlan) -> ExportProfile

    ExportPlan::quality_target

    fn ExportPlan::quality_target(self : ExportPlan) -> Int

    ExportProfile

    pub(all) enum ExportProfile {
    Preview
    Balanced
    SmallFile
    Archive
    Sticker
    } derive(Eq,
    Debug
    )

    High-level export intent used by applications instead of raw encoder flags.

    ExportReport

    pub(all) struct ExportReport {
    profile : ExportProfile
    input_frames : Int
    output_frames : Int
    estimated_bytes : Int
    actual_bytes : Int
    retained_pixels_per_mille : Int
    quality_target : Int
    } derive(
    Debug
    )

    Produce a complete profile report for size and frame-retention review.

    ExportReport::actual_bytes

    fn ExportReport::actual_bytes(self : ExportReport) -> Int

    ExportReport::estimated_bytes

    fn ExportReport::estimated_bytes(self : ExportReport) -> Int

    ExportReport::input_frames

    fn ExportReport::input_frames(self : ExportReport) -> Int

    ExportReport::output_frames

    fn ExportReport::output_frames(self : ExportReport) -> Int

    ExportReport::profile

    fn ExportReport::profile(self : ExportReport) -> ExportProfile

    ExportReport::quality_target

    fn ExportReport::quality_target(self : ExportReport) -> Int

    ExportReport::retained_pixels_per_mille

    fn ExportReport::retained_pixels_per_mille(self : ExportReport) -> Int

    Frame

    pub(all) struct Frame {
    canvas : Canvas
    delay_cs : Int
    disposal : Disposal
    transparent : Rgba?
    left : Int
    top : Int
    } derive(
    Debug
    )

    A decoded or to-be-encoded animation frame.

    Frame::canvas

    fn Frame::canvas(self : Frame) -> Canvas

    Frame::clamp_delay

    fn Frame::clamp_delay(self : Frame) -> Frame

    Return a frame with its display delay clamped to GIF's 16-bit field.

    Frame::delay_cs

    fn Frame::delay_cs(self : Frame) -> Int

    Frame::disposal

    fn Frame::disposal(self : Frame) -> Disposal

    Frame::new

    fn Frame::new(canvas~ : Canvas, delay_cs~ : Int) -> Frame

    Frame::offset

    fn Frame::offset(self : Frame) -> (Int, Int)

    Frame::visible_delay_cs

    fn Frame::visible_delay_cs(self : Frame) -> Int

    Return one frame's delay, defaulting zero-delay frames to one centisecond.

    Frame::with_canvas

    fn Frame::with_canvas(self : Frame, canvas : Canvas) -> Frame

    Return a frame with the same timing and GIF metadata but a new canvas.

    Frame::with_delay

    fn Frame::with_delay(self : Frame, delay_cs~ : Int) -> Frame

    Frame::with_disposal

    fn Frame::with_disposal(self : Frame, disposal~ : Disposal) -> Frame

    Frame::with_offset

    fn Frame::with_offset(self : Frame, left~ : Int, top~ : Int) -> Frame

    Frame::with_transparent

    fn Frame::with_transparent(self : Frame, color~ : Rgba) -> Frame

    FrameEstimate

    pub(all) struct FrameEstimate {
    width : Int
    height : Int
    palette_bytes : Int
    lzw_bytes : Int
    total_bytes : Int
    } derive(
    Debug
    )

    A conservative encoded-size estimate for a single frame.

    FrameEstimate::height

    fn FrameEstimate::height(self : FrameEstimate) -> Int

    FrameEstimate::lzw_bytes

    fn FrameEstimate::lzw_bytes(self : FrameEstimate) -> Int

    FrameEstimate::palette_bytes

    fn FrameEstimate::palette_bytes(self : FrameEstimate) -> Int

    FrameEstimate::total_bytes

    fn FrameEstimate::total_bytes(self : FrameEstimate) -> Int

    FrameEstimate::width

    fn FrameEstimate::width(self : FrameEstimate) -> Int

    FrameRange

    pub(all) struct FrameRange {
    start : Int
    end : Int
    } derive(Eq,
    Debug
    )

    A half-open range of frame indices.

    FrameRange::contains

    fn FrameRange::contains(self : FrameRange, index : Int) -> Bool

    FrameRange::end

    fn FrameRange::end(self : FrameRange) -> Int

    FrameRange::length

    fn FrameRange::length(self : FrameRange) -> Int

    FrameRange::new

    fn FrameRange::new(start~ : Int, end~ : Int) -> FrameRange

    FrameRange::start

    fn FrameRange::start(self : FrameRange) -> Int

    GifByteIndex

    pub(all) struct GifByteIndex {
    bytes : Int
    header_bytes : Int
    trailer_offset : Int?
    frames : Array[GifIndexEntry]
    extension_count : Int
    } derive(
    Debug
    )

    GifByteIndex::bytes

    fn GifByteIndex::bytes(self : GifByteIndex) -> Int

    GifByteIndex::extension_count

    fn GifByteIndex::extension_count(self : GifByteIndex) -> Int

    GifByteIndex::frame_offsets

    fn GifByteIndex::frame_offsets(self : GifByteIndex) -> Array[Int]

    Return frame offsets in decode order for diagnostic output.

    GifByteIndex::frames

    GifByteIndex::header_bytes

    fn GifByteIndex::header_bytes(self : GifByteIndex) -> Int

    GifByteIndex::is_complete

    fn GifByteIndex::is_complete(self : GifByteIndex) -> Bool

    Check whether an index points to a complete GIF stream.

    GifByteIndex::trailer_offset

    fn GifByteIndex::trailer_offset(self : GifByteIndex) -> Int?

    GifByteStream

    pub(all) struct GifByteStream {
    bytes : Bytes
    chunk_size : Int
    } derive(
    Debug
    )

    GifByteStream::bytes

    fn GifByteStream::bytes(self : GifByteStream) -> Bytes

    GifByteStream::checksum

    fn GifByteStream::checksum(self : GifByteStream) -> UInt

    Return a stream digest suitable for resumable transfer logs.

    GifByteStream::chunk

    fn GifByteStream::chunk(self : GifByteStream, index : Int) -> GifChunk?

    GifByteStream::chunk_count

    fn GifByteStream::chunk_count(self : GifByteStream) -> Int

    GifByteStream::chunk_size

    fn GifByteStream::chunk_size(self : GifByteStream) -> Int

    GifByteStream::chunks

    fn GifByteStream::chunks(self : GifByteStream) -> Array[GifChunk]

    GifByteStream::length

    fn GifByteStream::length(self : GifByteStream) -> Int

    GifByteStream::new

    fn GifByteStream::new(bytes : Bytes, chunk_size : Int) -> GifByteStream

    GifChunk

    pub(all) struct GifChunk {
    index : Int
    offset : Int
    data : Bytes
    is_last : Bool
    } derive(
    Debug
    )

    A read-only chunk view over an encoded GIF for sockets and file sinks.

    GifChunk::data

    fn GifChunk::data(self : GifChunk) -> Bytes

    GifChunk::index

    fn GifChunk::index(self : GifChunk) -> Int

    GifChunk::is_final

    fn GifChunk::is_final(self : GifChunk) -> Bool

    GifChunk::offset

    fn GifChunk::offset(self : GifChunk) -> Int

    GifCliPlan

    pub(all) struct GifCliPlan {
    command : GifCommand
    animation : Animation?
    encode_options : EncodeOptions
    optimization_options : OptimizationOptions
    preview_size : (Int, Int)?
    } derive(
    Debug
    )

    GifCliPlan::animation

    fn GifCliPlan::animation(self : GifCliPlan) -> Animation?

    GifCliPlan::command

    fn GifCliPlan::command(self : GifCliPlan) -> GifCommand

    GifCliPlan::encode_options

    fn GifCliPlan::encode_options(self : GifCliPlan) -> EncodeOptions

    GifCliPlan::optimization_options

    fn GifCliPlan::optimization_options(self : GifCliPlan) -> OptimizationOptions

    GifCliPlan::preview_size

    fn GifCliPlan::preview_size(self : GifCliPlan) -> (Int, Int)?

    GifCliRequest

    pub(all) struct GifCliRequest {
    command : GifCommand
    input : String
    output : String
    width : Int?
    height : Int?
    colors : Int
    delay_cs : Int
    profile : ExportProfile
    } derive(
    Debug
    )

    GifCliRequest::colors

    fn GifCliRequest::colors(self : GifCliRequest, count : Int) -> GifCliRequest

    GifCliRequest::default

    fn GifCliRequest::default(command : GifCommand) -> GifCliRequest

    GifCliRequest::delay

    fn GifCliRequest::delay(self : GifCliRequest, delay_cs : Int) -> GifCliRequest

    GifCliRequest::input

    fn GifCliRequest::input(self : GifCliRequest, path : String) -> GifCliRequest

    GifCliRequest::output

    fn GifCliRequest::output(self : GifCliRequest, path : String) -> GifCliRequest

    GifCliRequest::profile

    fn GifCliRequest::profile(self : GifCliRequest, profile : ExportProfile) -> GifCliRequest

    GifCliRequest::size

    fn GifCliRequest::size(self : GifCliRequest, width : Int, height : Int) -> GifCliRequest

    GifCliResult

    pub(all) struct GifCliResult {
    command : GifCommand
    bytes : Bytes?
    animation : Animation?
    report : GifDocumentReport?
    messages : Array[String]
    } derive(
    Debug
    )

    Pure execution helpers behind the command-line entry point.

    GifCliResult::animation

    fn GifCliResult::animation(self : GifCliResult) -> Animation?

    GifCliResult::bytes

    fn GifCliResult::bytes(self : GifCliResult) -> Bytes?

    GifCliResult::command

    fn GifCliResult::command(self : GifCliResult) -> GifCommand

    GifCliResult::messages

    fn GifCliResult::messages(self : GifCliResult) -> ArrayView[String]

    GifCliResult::report

    GifCommand

    pub(all) enum GifCommand {
    Inspect
    Encode
    Decode
    Optimize
    Preview
    Benchmark
    } derive(Eq,
    Debug
    )

    Declarative CLI request model shared by examples and application wrappers.

    GifDiagnostic

    pub(all) struct GifDiagnostic {
    level : DiagnosticLevel
    code : String
    message : String
    frame_index : Int?
    } derive(
    Debug
    )

    GifDiagnostic::code

    fn GifDiagnostic::code(self : GifDiagnostic) -> String

    GifDiagnostic::frame

    fn GifDiagnostic::frame(self : GifDiagnostic) -> Int?

    GifDiagnostic::level

    GifDiagnostic::message

    fn GifDiagnostic::message(self : GifDiagnostic) -> String

    GifDocumentReport

    pub(all) struct GifDocumentReport {
    bytes : Int
    width : Int
    height : Int
    frames : Int
    duration_cs : Int
    encoded_pixels : Int
    unique_colors : Int
    entropy_milli : Int
    estimated_bytes : Int
    validation_errors : Int
    validation_warnings : Int
    complete_index : Bool
    } derive(
    Debug
    )

    A single report object for CLI diagnostics and benchmark artifacts.

    GifDocumentReport::bytes

    fn GifDocumentReport::bytes(self : GifDocumentReport) -> Int

    GifDocumentReport::complete_index

    fn GifDocumentReport::complete_index(self : GifDocumentReport) -> Bool

    GifDocumentReport::duration_cs

    fn GifDocumentReport::duration_cs(self : GifDocumentReport) -> Int

    GifDocumentReport::encoded_pixels

    fn GifDocumentReport::encoded_pixels(self : GifDocumentReport) -> Int

    GifDocumentReport::entropy_milli

    fn GifDocumentReport::entropy_milli(self : GifDocumentReport) -> Int

    GifDocumentReport::estimated_bytes

    fn GifDocumentReport::estimated_bytes(self : GifDocumentReport) -> Int

    GifDocumentReport::frames

    fn GifDocumentReport::frames(self : GifDocumentReport) -> Int

    GifDocumentReport::height

    fn GifDocumentReport::height(self : GifDocumentReport) -> Int

    GifDocumentReport::meets_invariants

    fn GifDocumentReport::meets_invariants(self : GifDocumentReport) -> Bool

    Report whether an export meets basic acceptance invariants.

    GifDocumentReport::summary

    fn GifDocumentReport::summary(self : GifDocumentReport) -> String

    Produce stable key/value text suitable for a benchmark log.

    GifDocumentReport::unique_colors

    fn GifDocumentReport::unique_colors(self : GifDocumentReport) -> Int

    GifDocumentReport::validation_errors

    fn GifDocumentReport::validation_errors(self : GifDocumentReport) -> Int

    GifDocumentReport::validation_warnings

    fn GifDocumentReport::validation_warnings(self : GifDocumentReport) -> Int

    GifDocumentReport::width

    fn GifDocumentReport::width(self : GifDocumentReport) -> Int

    GifHeader

    pub(all) struct GifHeader {
    version : GifVersion
    width : Int
    height : Int
    global_palette : Bool
    color_resolution : Int
    sorted_palette : Bool
    background_index : Int
    aspect_ratio : Int
    } derive(
    Debug
    )

    GifHeader::area

    fn GifHeader::area(self : GifHeader) -> Int

    Return the logical screen area, clamped to a safe integer range.

    GifHeader::aspect_ratio

    fn GifHeader::aspect_ratio(self : GifHeader) -> Int

    GifHeader::background_index

    fn GifHeader::background_index(self : GifHeader) -> Int

    GifHeader::color_resolution

    fn GifHeader::color_resolution(self : GifHeader) -> Int

    GifHeader::global_palette

    fn GifHeader::global_palette(self : GifHeader) -> Bool

    GifHeader::height

    fn GifHeader::height(self : GifHeader) -> Int

    GifHeader::sorted_palette

    fn GifHeader::sorted_palette(self : GifHeader) -> Bool

    GifHeader::version

    fn GifHeader::version(self : GifHeader) -> GifVersion

    GifHeader::width

    fn GifHeader::width(self : GifHeader) -> Int

    GifIndexEntry

    pub(all) struct GifIndexEntry {
    frame_index : Int
    marker_offset : Int
    descriptor_offset : Int
    extension_offset : Int?
    } derive(
    Debug
    )

    Byte offsets for lightweight GIF inspection and resumable processing.

    GifIndexEntry::descriptor_offset

    fn GifIndexEntry::descriptor_offset(self : GifIndexEntry) -> Int

    GifIndexEntry::extension_offset

    fn GifIndexEntry::extension_offset(self : GifIndexEntry) -> Int?

    GifIndexEntry::frame_index

    fn GifIndexEntry::frame_index(self : GifIndexEntry) -> Int

    GifIndexEntry::marker_offset

    fn GifIndexEntry::marker_offset(self : GifIndexEntry) -> Int

    GifInfo

    pub(all) struct GifInfo {
    version : String
    width : Int
    height : Int
    frame_count : Int
    has_global_palette : Bool
    uses_local_palettes : Bool
    uses_transparency : Bool
    loop_count : Int?
    compressed_bytes : Int
    } derive(
    Debug
    )

    Header-level information collected without expanding image pixels.

    GifInfo::compressed_bytes

    fn GifInfo::compressed_bytes(self : GifInfo) -> Int

    GifInfo::frame_count

    fn GifInfo::frame_count(self : GifInfo) -> Int

    GifInfo::has_global_palette

    fn GifInfo::has_global_palette(self : GifInfo) -> Bool

    GifInfo::height

    fn GifInfo::height(self : GifInfo) -> Int

    GifInfo::loop_count

    fn GifInfo::loop_count(self : GifInfo) -> Int?

    GifInfo::uses_local_palettes

    fn GifInfo::uses_local_palettes(self : GifInfo) -> Bool

    GifInfo::uses_transparency

    fn GifInfo::uses_transparency(self : GifInfo) -> Bool

    GifInfo::version

    fn GifInfo::version(self : GifInfo) -> String

    GifInfo::width

    fn GifInfo::width(self : GifInfo) -> Int

    GifLimits

    pub(all) struct GifLimits {
    max_dimension : Int
    max_colors : Int
    max_delay_cs : Int
    max_frames : Int
    max_comment_bytes : Int
    } derive(
    Debug
    )

    Centralized limits used by public APIs and command-line validation.

    GifLimits::clamp_delay

    fn GifLimits::clamp_delay(self : GifLimits, delay : Int) -> Int

    GifLimits::clamp_frames

    fn GifLimits::clamp_frames(self : GifLimits, count : Int) -> Int

    GifLimits::colors

    fn GifLimits::colors(self : GifLimits) -> Int

    GifLimits::comment_bytes

    fn GifLimits::comment_bytes(self : GifLimits) -> Int

    GifLimits::default

    fn GifLimits::default() -> GifLimits

    GifLimits::delay

    fn GifLimits::delay(self : GifLimits) -> Int

    GifLimits::dimension

    fn GifLimits::dimension(self : GifLimits) -> Int

    GifLimits::frames

    fn GifLimits::frames(self : GifLimits) -> Int

    GifLimits::valid_dimensions

    fn GifLimits::valid_dimensions(self : GifLimits, width : Int, height : Int) -> Bool

    GifMetadata

    pub(all) struct GifMetadata {
    kind : GifMetadataKind
    payload : Bytes
    } derive(
    Debug
    )

    A metadata record stored between the logical screen and image blocks.

    GifMetadata::application

    fn GifMetadata::application(identifier : String, authentication : String, payload : Bytes) -> GifMetadata

    GifMetadata::comment

    fn GifMetadata::comment(text : String) -> GifMetadata

    GifMetadata::encoded_length

    fn GifMetadata::encoded_length(self : GifMetadata) -> Int

    Return the number of extension bytes added by a metadata record.

    GifMetadata::is_valid

    fn GifMetadata::is_valid(self : GifMetadata) -> Bool

    Validate the identifier widths required by an application extension.

    GifMetadata::kind

    GifMetadata::payload

    fn GifMetadata::payload(self : GifMetadata) -> Bytes

    GifMetadataKind

    pub(all) enum GifMetadataKind {
    Comment
    Application(identifier~ : String, authentication~ : String)
    } derive(Eq,
    Debug
    )

    Metadata extension kinds that can be inserted into a GIF89a stream.

    GifPreflight

    pub(all) struct GifPreflight {
    signature : Bool
    header : GifHeader?
    bytes : Int
    dimensions_ok : Bool
    estimated_pixels : Int
    frame_count : Int
    extension_count : Int
    complete : Bool
    safe : Bool
    issues : Array[String]
    } derive(
    Debug
    )

    Cheap preflight checks for untrusted GIF data before full decoding.

    GifPreflight::allows_decode

    fn GifPreflight::allows_decode(self : GifPreflight) -> Bool

    Decide whether full decode is allowed under resource limits.

    GifPreflight::bytes

    fn GifPreflight::bytes(self : GifPreflight) -> Int

    GifPreflight::complete

    fn GifPreflight::complete(self : GifPreflight) -> Bool

    GifPreflight::decoded_memory_bytes

    fn GifPreflight::decoded_memory_bytes(self : GifPreflight) -> Int

    Return a conservative byte budget for decoded RGBA storage.

    GifPreflight::dimensions_ok

    fn GifPreflight::dimensions_ok(self : GifPreflight) -> Bool

    GifPreflight::estimated_pixels

    fn GifPreflight::estimated_pixels(self : GifPreflight) -> Int

    GifPreflight::extension_count

    fn GifPreflight::extension_count(self : GifPreflight) -> Int

    GifPreflight::frame_count

    fn GifPreflight::frame_count(self : GifPreflight) -> Int

    GifPreflight::header

    fn GifPreflight::header(self : GifPreflight) -> GifHeader?

    GifPreflight::issues

    fn GifPreflight::issues(self : GifPreflight) -> ArrayView[String]

    GifPreflight::reason

    fn GifPreflight::reason(self : GifPreflight) -> String

    Return a stable reason string for rejected data.

    GifPreflight::safe

    fn GifPreflight::safe(self : GifPreflight) -> Bool

    GifPreflight::signature

    fn GifPreflight::signature(self : GifPreflight) -> Bool

    GifRect

    pub(all) struct GifRect {
    left : Int
    top : Int
    width : Int
    height : Int
    } derive(Eq,
    Debug
    )

    A clipped rectangle in logical-screen coordinates.

    GifRect::area

    fn GifRect::area(self : GifRect) -> Int

    GifRect::bottom

    fn GifRect::bottom(self : GifRect) -> Int

    GifRect::height

    fn GifRect::height(self : GifRect) -> Int

    GifRect::left

    fn GifRect::left(self : GifRect) -> Int

    GifRect::new

    fn GifRect::new(left~ : Int, top~ : Int, width~ : Int, height~ : Int) -> GifRect

    GifRect::right

    fn GifRect::right(self : GifRect) -> Int

    GifRect::top

    fn GifRect::top(self : GifRect) -> Int

    GifRect::width

    fn GifRect::width(self : GifRect) -> Int

    GifStreamCollector

    pub(all) struct GifStreamCollector {
    parts : Array[Bytes]
    total_bytes : Int
    } derive(
    Debug
    )

    A collector for asynchronous or network-delivered GIF chunks.

    GifStreamCollector::decode

    Decode a collected stream after checking its byte-level structure.

    GifStreamCollector::finish

    fn GifStreamCollector::finish(self : GifStreamCollector) -> Bytes

    GifStreamCollector::new

    GifStreamCollector::part_count

    fn GifStreamCollector::part_count(self : GifStreamCollector) -> Int

    GifStreamCollector::push

    fn GifStreamCollector::push(self : GifStreamCollector, chunk : Bytes) -> GifStreamCollector

    GifStreamCollector::total_bytes

    fn GifStreamCollector::total_bytes(self : GifStreamCollector) -> Int

    GifValidationReport

    pub(all) struct GifValidationReport {
    diagnostics : Array[GifDiagnostic]
    frame_count : Int
    duration_cs : Int
    pixel_count : Int
    } derive(
    Debug
    )

    GifValidationReport::diagnostics

    GifValidationReport::duration_cs

    fn GifValidationReport::duration_cs(self : GifValidationReport) -> Int

    GifValidationReport::errors

    fn GifValidationReport::errors(self : GifValidationReport) -> Int

    GifValidationReport::first_error

    fn GifValidationReport::first_error(self : GifValidationReport) -> String?

    Return the first error code, if any, for simple command-line integrations.

    GifValidationReport::frame_count

    fn GifValidationReport::frame_count(self : GifValidationReport) -> Int

    GifValidationReport::frame_diagnostics

    fn GifValidationReport::frame_diagnostics(self : GifValidationReport, frame_index : Int) -> Int

    Count diagnostics for one frame, useful for editor overlays.

    GifValidationReport::is_valid

    fn GifValidationReport::is_valid(self : GifValidationReport) -> Bool

    GifValidationReport::pixel_count

    fn GifValidationReport::pixel_count(self : GifValidationReport) -> Int

    GifValidationReport::warnings

    fn GifValidationReport::warnings(self : GifValidationReport) -> Int

    GifVersion

    pub(all) enum GifVersion {
    Gif87a
    Gif89a
    } derive(Eq,
    Debug
    )

    Header and stream-level format helpers for integrations.

    GifVersion::name

    fn GifVersion::name(self : GifVersion) -> String

    Return a user-facing version string.

    GifWorkflow

    pub(all) struct GifWorkflow {
    steps : Array[GifWorkflowStep]
    profile : ExportProfile
    limits : GifLimits
    comment : String?
    reject_empty : Bool
    } derive(
    Debug
    )

    A reusable, inspectable GIF export plan.

    GifWorkflow::adjust

    fn GifWorkflow::adjust(self : GifWorkflow, adjustment : ColorAdjustment) -> GifWorkflow

    GifWorkflow::allow_empty

    fn GifWorkflow::allow_empty(self : GifWorkflow) -> GifWorkflow

    Empty animations can be useful as intermediate values, but export jobs normally reject them so a missing input cannot silently create a trailer.

    GifWorkflow::apply_animation

    fn GifWorkflow::apply_animation(self : GifWorkflow, animation : Animation) -> Animation

    Apply visual stages while keeping timing, disposal, offsets, and loop data.

    GifWorkflow::apply_canvas

    fn GifWorkflow::apply_canvas(self : GifWorkflow, canvas : Canvas) -> Canvas

    Apply only visual stages to one canvas. Timing and metadata steps are intentionally ignored here so callers can preview an image independently.

    GifWorkflow::background

    fn GifWorkflow::background(self : GifWorkflow, color : Rgba) -> GifWorkflow

    GifWorkflow::blur

    fn GifWorkflow::blur(self : GifWorkflow, radius : Int) -> GifWorkflow

    GifWorkflow::chroma_key

    fn GifWorkflow::chroma_key(self : GifWorkflow, key : Rgba, tolerance : Int) -> GifWorkflow

    GifWorkflow::clamp_limits

    fn GifWorkflow::clamp_limits(self : GifWorkflow) -> GifWorkflow

    GifWorkflow::clone

    fn GifWorkflow::clone(self : GifWorkflow) -> GifWorkflow

    Make an exact clone for callers that want to retain a named baseline.

    GifWorkflow::comment

    fn GifWorkflow::comment(self : GifWorkflow, text : String?) -> GifWorkflow

    Add a UTF-8 comment extension to the final GIF.

    GifWorkflow::comment_text

    fn GifWorkflow::comment_text(self : GifWorkflow) -> String?

    GifWorkflow::convolve

    fn GifWorkflow::convolve(self : GifWorkflow, kernel : ConvolutionKernel) -> GifWorkflow

    GifWorkflow::crop

    fn GifWorkflow::crop(self : GifWorkflow, x : Int, y : Int, width : Int, height : Int) -> GifWorkflow

    GifWorkflow::default

    fn GifWorkflow::default() -> GifWorkflow

    GifWorkflow::delay

    fn GifWorkflow::delay(self : GifWorkflow, delay_cs : Int) -> GifWorkflow

    Set a constant frame delay in centiseconds.

    GifWorkflow::dilate

    fn GifWorkflow::dilate(self : GifWorkflow, radius : Int, mode : MorphologyMode) -> GifWorkflow

    GifWorkflow::dry_run

    fn GifWorkflow::dry_run(self : GifWorkflow, animation : Animation) -> String

    Produce a compact deterministic dry-run line for a command-line preview.

    GifWorkflow::edge_map

    fn GifWorkflow::edge_map(self : GifWorkflow) -> GifWorkflow

    GifWorkflow::encode

    fn GifWorkflow::encode(self : GifWorkflow, animation : Animation) -> Bytes raise GifError

    Encode the workflow and return its exact output. Validation is reported by the normal GIF error channel only when the source is structurally invalid; callers can inspect validate first when they need all diagnostics.

    GifWorkflow::encode_report

    fn GifWorkflow::encode_report(self : GifWorkflow, animation : Animation) -> GifWorkflowReport raise GifError

    Encode and fill the report's measured byte field after the exact export.

    GifWorkflow::erode

    fn GifWorkflow::erode(self : GifWorkflow, radius : Int, mode : MorphologyMode) -> GifWorkflow

    GifWorkflow::estimate

    fn GifWorkflow::estimate(self : GifWorkflow, animation : Animation) -> GifWorkflowReport raise GifError

    Build a report without encoding; useful for UI sliders and dry-run modes.

    GifWorkflow::flip_horizontal

    fn GifWorkflow::flip_horizontal(self : GifWorkflow) -> GifWorkflow

    GifWorkflow::flip_vertical

    fn GifWorkflow::flip_vertical(self : GifWorkflow) -> GifWorkflow

    GifWorkflow::gaussian_blur

    fn GifWorkflow::gaussian_blur(self : GifWorkflow) -> GifWorkflow

    GifWorkflow::grain

    fn GifWorkflow::grain(self : GifWorkflow, amount : Int, seed : Int) -> GifWorkflow

    GifWorkflow::grayscale

    fn GifWorkflow::grayscale(self : GifWorkflow) -> GifWorkflow

    GifWorkflow::has_comment

    fn GifWorkflow::has_comment(self : GifWorkflow) -> Bool

    GifWorkflow::invert

    fn GifWorkflow::invert(self : GifWorkflow) -> GifWorkflow

    GifWorkflow::is_metadata_only

    fn GifWorkflow::is_metadata_only(self : GifWorkflow) -> Bool

    Return true when a workflow has no visual stages and is metadata-only.

    GifWorkflow::labels

    fn GifWorkflow::labels(self : GifWorkflow) -> Array[String]

    Return stable labels suitable for logs, telemetry, and a CLI dry run.

    GifWorkflow::limits

    fn GifWorkflow::limits(self : GifWorkflow) -> GifLimits

    GifWorkflow::loop_count

    fn GifWorkflow::loop_count(self : GifWorkflow, count : Int?) -> GifWorkflow

    GifWorkflow::new

    GifWorkflow::normalize_luma

    fn GifWorkflow::normalize_luma(self : GifWorkflow) -> GifWorkflow

    GifWorkflow::normalize_timeline

    fn GifWorkflow::normalize_timeline(self : GifWorkflow) -> GifWorkflow

    GifWorkflow::ordered_dither

    fn GifWorkflow::ordered_dither(self : GifWorkflow, levels : Int) -> GifWorkflow

    GifWorkflow::pixelate

    fn GifWorkflow::pixelate(self : GifWorkflow, block : Int) -> GifWorkflow

    GifWorkflow::posterize

    fn GifWorkflow::posterize(self : GifWorkflow, levels : Int) -> GifWorkflow

    GifWorkflow::profile

    fn GifWorkflow::profile(self : GifWorkflow, profile : ExportProfile) -> GifWorkflow

    GifWorkflow::report

    fn GifWorkflow::report(self : GifWorkflow, animation : Animation) -> GifWorkflowReport raise GifError

    Build a report from transformed frames and the exact optimizer estimate.

    GifWorkflow::resize

    fn GifWorkflow::resize(self : GifWorkflow, width : Int, height : Int) -> GifWorkflow

    Append an explicit nearest-neighbour resize stage.

    GifWorkflow::selected_profile

    fn GifWorkflow::selected_profile(self : GifWorkflow) -> ExportProfile

    GifWorkflow::sharpen

    fn GifWorkflow::sharpen(self : GifWorkflow) -> GifWorkflow

    GifWorkflow::step_count

    fn GifWorkflow::step_count(self : GifWorkflow) -> Int

    GifWorkflow::steps

    GifWorkflow::then

    fn GifWorkflow::then(self : GifWorkflow, next : GifWorkflow) -> GifWorkflow

    Append the steps of another workflow while using this workflow's profile.

    GifWorkflow::threshold

    fn GifWorkflow::threshold(self : GifWorkflow, level : Byte) -> GifWorkflow

    GifWorkflow::timing_stage_count

    fn GifWorkflow::timing_stage_count(self : GifWorkflow) -> Int

    Count frame-affecting timing operations for audit logs.

    GifWorkflow::tint

    fn GifWorkflow::tint(self : GifWorkflow, color : Rgba, strength : Int) -> GifWorkflow

    GifWorkflow::validate

    fn GifWorkflow::validate(self : GifWorkflow, animation : Animation) -> Array[String]

    Validate a source animation without changing it or touching the encoder.

    GifWorkflow::visual

    fn GifWorkflow::visual(self : GifWorkflow, stage : PipelineStage) -> GifWorkflow

    Append a low-level visual pipeline stage.

    GifWorkflow::visual_stage_count

    fn GifWorkflow::visual_stage_count(self : GifWorkflow) -> Int

    Count only visual stages, excluding timing and export policy edits.

    GifWorkflow::with_limits

    fn GifWorkflow::with_limits(self : GifWorkflow, limits : GifLimits) -> GifWorkflow

    GifWorkflow::with_profile

    fn GifWorkflow::with_profile(self : GifWorkflow, profile : ExportProfile) -> GifWorkflow

    Replace only the export profile, preserving the visual and timing plan.

    GifWorkflow::without_timing

    fn GifWorkflow::without_timing(self : GifWorkflow) -> GifWorkflow

    Return a copy with all timing changes removed.

    GifWorkflow::without_visuals

    fn GifWorkflow::without_visuals(self : GifWorkflow) -> GifWorkflow

    Return a copy with all visual stages removed, retaining export policy.

    GifWorkflowReport

    pub(all) struct GifWorkflowReport {
    valid : Bool
    issues : Array[String]
    input_width : Int
    input_height : Int
    output_width : Int
    output_height : Int
    input_frames : Int
    output_frames : Int
    input_pixels : Int
    output_pixels : Int
    encoded_bytes : Int
    estimated_bytes : Int
    comment_bytes : Int
    stage_count : Int
    profile : ExportProfile
    } derive(
    Debug
    )

    Metrics returned by a workflow before or after encoding.

    GifWorkflowReport::comment_bytes

    fn GifWorkflowReport::comment_bytes(self : GifWorkflowReport) -> Int

    GifWorkflowReport::encoded_bytes

    fn GifWorkflowReport::encoded_bytes(self : GifWorkflowReport) -> Int

    GifWorkflowReport::estimated_bytes

    fn GifWorkflowReport::estimated_bytes(self : GifWorkflowReport) -> Int

    GifWorkflowReport::input_dimensions

    fn GifWorkflowReport::input_dimensions(self : GifWorkflowReport) -> (Int, Int)

    GifWorkflowReport::input_frames

    fn GifWorkflowReport::input_frames(self : GifWorkflowReport) -> Int

    GifWorkflowReport::input_pixels

    fn GifWorkflowReport::input_pixels(self : GifWorkflowReport) -> Int

    GifWorkflowReport::issues

    fn GifWorkflowReport::issues(self : GifWorkflowReport) -> ArrayView[String]

    GifWorkflowReport::output_dimensions

    fn GifWorkflowReport::output_dimensions(self : GifWorkflowReport) -> (Int, Int)

    GifWorkflowReport::output_frames

    fn GifWorkflowReport::output_frames(self : GifWorkflowReport) -> Int

    GifWorkflowReport::output_pixels

    fn GifWorkflowReport::output_pixels(self : GifWorkflowReport) -> Int

    GifWorkflowReport::profile

    GifWorkflowReport::stage_count

    fn GifWorkflowReport::stage_count(self : GifWorkflowReport) -> Int

    GifWorkflowReport::valid

    fn GifWorkflowReport::valid(self : GifWorkflowReport) -> Bool

    GifWorkflowStep

    pub(all) enum GifWorkflowStep {
    Visual(stage~ : PipelineStage)
    Resize(width~ : Int, height~ : Int)
    SetDelay(delay_cs~ : Int)
    SetLoop(loop_count~ : Int?)
    SetBackground(color~ : Rgba)
    SetProfile(profile~ : ExportProfile)
    ClampLimits
    NormalizeTimeline
    } derive(
    Debug
    )

    A declarative export workflow for applications that need a stable GIF pipeline instead of assembling encoder flags at each call site.

    The workflow keeps visual stages, timing edits, safety checks, and the export profile in one value. It is intentionally independent of files or operating-system APIs, so the same plan can run in a CLI, a browser host, or an embedded MoonBit service.

    GradientMode

    pub(all) enum GradientMode {
    LinearHorizontal
    LinearVertical
    LinearDiagonal
    Radial
    Diamond
    } derive(Eq,
    Debug
    )

    A gradient interpolation strategy for procedural canvas backgrounds.

    GradientStop

    pub(all) struct GradientStop {
    position : Int
    color : Rgba
    } derive(
    Debug
    )

    GradientStop::color

    fn GradientStop::color(self : GradientStop) -> Rgba

    GradientStop::new

    fn GradientStop::new(position : Int, color : Rgba) -> GradientStop

    GradientStop::position

    fn GradientStop::position(self : GradientStop) -> Int

    HslColor

    pub(all) struct HslColor {
    hue : Int
    saturation : Byte
    lightness : Byte
    alpha : Byte
    } derive(Eq,
    Debug
    )

    A compact HSL color value. Hue is measured in degrees in the range 0..360.

    HslColor::alpha

    fn HslColor::alpha(self : HslColor) -> Byte

    HslColor::hue

    fn HslColor::hue(self : HslColor) -> Int

    HslColor::lightness

    fn HslColor::lightness(self : HslColor) -> Byte

    HslColor::saturation

    fn HslColor::saturation(self : HslColor) -> Byte

    HsvColor

    pub(all) struct HsvColor {
    hue : Int
    saturation : Byte
    value : Byte
    alpha : Byte
    } derive(Eq,
    Debug
    )

    A compact HSV color value. Hue is measured in degrees in the range 0..360, saturation and value are stored in the range 0..255.

    HsvColor::alpha

    fn HsvColor::alpha(self : HsvColor) -> Byte

    HsvColor::hue

    fn HsvColor::hue(self : HsvColor) -> Int

    HsvColor::saturation

    fn HsvColor::saturation(self : HsvColor) -> Byte

    HsvColor::value

    fn HsvColor::value(self : HsvColor) -> Byte

    ImageLayer

    pub(all) struct ImageLayer {
    name : String
    canvas : Canvas
    left : Int
    top : Int
    opacity : Byte
    blend_mode : BlendMode
    visible : Bool
    } derive(
    Debug
    )

    A positioned image layer used to compose stickers, captions, and overlays.

    ImageLayer::blend_mode

    fn ImageLayer::blend_mode(self : ImageLayer) -> BlendMode

    ImageLayer::canvas

    fn ImageLayer::canvas(self : ImageLayer) -> Canvas

    ImageLayer::hidden

    fn ImageLayer::hidden(self : ImageLayer) -> ImageLayer

    ImageLayer::move_to

    fn ImageLayer::move_to(self : ImageLayer, left : Int, top : Int) -> ImageLayer

    ImageLayer::name

    fn ImageLayer::name(self : ImageLayer) -> String

    ImageLayer::new

    fn ImageLayer::new(name : String, canvas : Canvas) -> ImageLayer

    ImageLayer::offset

    fn ImageLayer::offset(self : ImageLayer) -> (Int, Int)

    ImageLayer::opacity

    fn ImageLayer::opacity(self : ImageLayer) -> Byte

    ImageLayer::shown

    fn ImageLayer::shown(self : ImageLayer) -> ImageLayer

    ImageLayer::with_blend

    fn ImageLayer::with_blend(self : ImageLayer, mode : BlendMode) -> ImageLayer

    ImageLayer::with_opacity

    fn ImageLayer::with_opacity(self : ImageLayer, opacity : Byte) -> ImageLayer

    LayerStack

    pub(all) struct LayerStack {
    width : Int
    height : Int
    background : Rgba
    layers : Array[ImageLayer]
    } derive(
    Debug
    )

    LayerStack::add

    fn LayerStack::add(self : LayerStack, layer : ImageLayer) -> LayerStack

    LayerStack::background

    fn LayerStack::background(self : LayerStack, color : Rgba) -> LayerStack

    LayerStack::insert

    fn LayerStack::insert(self : LayerStack, index : Int, layer : ImageLayer) -> LayerStack

    LayerStack::layers

    fn LayerStack::layers(self : LayerStack) -> ArrayView[ImageLayer]

    LayerStack::new

    fn LayerStack::new(width~ : Int, height~ : Int) -> LayerStack

    LayerStack::remove

    fn LayerStack::remove(self : LayerStack, index : Int) -> LayerStack

    LayerStack::render

    fn LayerStack::render(self : LayerStack) -> Canvas

    Composite the visible layers from back to front.

    LayerStack::scale_layers

    fn LayerStack::scale_layers(self : LayerStack, scale_per_mille : Int) -> LayerStack

    Scale every layer around the stack center for a poster-style effect.

    LayerStack::visible_bounds

    fn LayerStack::visible_bounds(self : LayerStack) -> GifRect?

    Return the bounding rectangle of all visible layer pixels.

    LayoutDirection

    pub(all) enum LayoutDirection {
    Horizontal
    Vertical
    Grid(columns~ : Int)
    } derive(Eq,
    Debug
    )

    Layout helpers for contact sheets, sticker boards, and sprite previews.

    LayoutItem

    pub(all) struct LayoutItem {
    canvas : Canvas
    left : Int
    top : Int
    width : Int
    height : Int
    } derive(
    Debug
    )

    LayoutItem::canvas

    fn LayoutItem::canvas(self : LayoutItem) -> Canvas

    LayoutItem::position

    fn LayoutItem::position(self : LayoutItem) -> (Int, Int)

    LayoutItem::size

    fn LayoutItem::size(self : LayoutItem) -> (Int, Int)

    LayoutResult

    pub(all) struct LayoutResult {
    width : Int
    height : Int
    items : Array[LayoutItem]
    } derive(
    Debug
    )

    LayoutResult::height

    fn LayoutResult::height(self : LayoutResult) -> Int

    LayoutResult::items

    LayoutResult::render

    fn LayoutResult::render(self : LayoutResult, background : Rgba) -> Canvas

    Render a layout with clipped placement and alpha compositing.

    LayoutResult::width

    fn LayoutResult::width(self : LayoutResult) -> Int

    LzwRoundtripReport

    pub(all) struct LzwRoundtripReport {
    input_bytes : Int
    compressed_bytes : Int
    decoded_bytes : Int
    minimum_code_size : Int
    exact : Bool
    saving_per_mille : Int
    } derive(
    Debug
    )

    LZW diagnostics for compression tuning and test fixtures.

    LzwRoundtripReport::compressed_bytes

    fn LzwRoundtripReport::compressed_bytes(self : LzwRoundtripReport) -> Int

    LzwRoundtripReport::decoded_bytes

    fn LzwRoundtripReport::decoded_bytes(self : LzwRoundtripReport) -> Int

    LzwRoundtripReport::exact

    fn LzwRoundtripReport::exact(self : LzwRoundtripReport) -> Bool

    LzwRoundtripReport::input_bytes

    fn LzwRoundtripReport::input_bytes(self : LzwRoundtripReport) -> Int

    LzwRoundtripReport::minimum_code_size

    fn LzwRoundtripReport::minimum_code_size(self : LzwRoundtripReport) -> Int

    LzwRoundtripReport::saving_per_mille

    fn LzwRoundtripReport::saving_per_mille(self : LzwRoundtripReport) -> Int

    LzwStats

    pub(all) struct LzwStats {
    input_bytes : Int
    compressed_bytes : Int
    minimum_code_size : Int
    } derive(
    Debug
    )

    Compression metrics for an index stream.

    LzwStats::compressed_bytes

    fn LzwStats::compressed_bytes(self : LzwStats) -> Int

    LzwStats::input_bytes

    fn LzwStats::input_bytes(self : LzwStats) -> Int

    LzwStats::minimum_code_size

    fn LzwStats::minimum_code_size(self : LzwStats) -> Int

    LzwStats::saving_per_mille

    fn LzwStats::saving_per_mille(self : LzwStats) -> Int

    MaskStats

    pub(all) struct MaskStats {
    pixels : Int
    covered : Int
    partial : Int
    mean_alpha : Int
    bounds : GifRect?
    } derive(
    Debug
    )

    Alpha-mask utilities for transparent GIF composition and cleanup.

    MaskStats::bounds

    fn MaskStats::bounds(self : MaskStats) -> GifRect?

    MaskStats::covered

    fn MaskStats::covered(self : MaskStats) -> Int

    MaskStats::mean_alpha

    fn MaskStats::mean_alpha(self : MaskStats) -> Int

    MaskStats::partial

    fn MaskStats::partial(self : MaskStats) -> Int

    MaskStats::pixels

    fn MaskStats::pixels(self : MaskStats) -> Int

    MorphologyMode

    pub(all) enum MorphologyMode {
    Square
    Diamond
    Cross
    } derive(Eq,
    Debug
    )

    Neighborhood geometry used by mask cleanup and sprite extraction.

    MotionKeyframe

    pub(all) struct MotionKeyframe {
    time_cs : Int
    x : Int
    y : Int
    scale_per_mille : Int
    rotation : CanvasRotation
    opacity : Byte
    } derive(
    Debug
    )

    Position, scale, rotation, and opacity values sampled along a track.

    MotionKeyframe::new

    fn MotionKeyframe::new(time_cs~ : Int, x~ : Int, y~ : Int, scale_per_mille~ : Int, rotation~ : CanvasRotation, opacity~ : Byte) -> MotionKeyframe

    MotionKeyframe::opacity

    fn MotionKeyframe::opacity(self : MotionKeyframe) -> Byte

    MotionKeyframe::position

    fn MotionKeyframe::position(self : MotionKeyframe) -> (Int, Int)

    MotionKeyframe::rotation

    MotionKeyframe::scale

    fn MotionKeyframe::scale(self : MotionKeyframe) -> Int

    MotionKeyframe::time

    fn MotionKeyframe::time(self : MotionKeyframe) -> Int

    MotionSample

    pub(all) struct MotionSample {
    x : Int
    y : Int
    scale_per_mille : Int
    opacity : Byte
    rotation : CanvasRotation
    } derive(
    Debug
    )

    MotionSample::opacity

    fn MotionSample::opacity(self : MotionSample) -> Byte

    MotionSample::position

    fn MotionSample::position(self : MotionSample) -> (Int, Int)

    MotionSample::rotation

    fn MotionSample::rotation(self : MotionSample) -> CanvasRotation

    MotionSample::scale

    fn MotionSample::scale(self : MotionSample) -> Int

    MotionTrack

    pub(all) struct MotionTrack {
    keys : Array[MotionKeyframe]
    easing : Easing
    } derive(
    Debug
    )

    A sorted motion track. Keys added out of order are inserted into timeline order, making it safe for editors to build tracks incrementally.

    MotionTrack::add

    MotionTrack::easing

    fn MotionTrack::easing(self : MotionTrack) -> Easing

    MotionTrack::keys

    MotionTrack::new

    fn MotionTrack::new(easing~ : Easing) -> MotionTrack

    MotionTrack::sample

    fn MotionTrack::sample(self : MotionTrack, time_cs : Int) -> MotionSample

    NetpbmBuffer

    type NetpbmBuffer derive(
    Debug
    )

    NetpbmCursor

    type NetpbmCursor derive(
    Debug
    )

    NetpbmFormat

    pub(all) enum NetpbmFormat {
    PpmRgb
    PpmRgba
    PgmGray
    PamRgba
    } derive(Eq,
    Debug
    )

    Portable Netpbm encodings supported by the CLI and test fixtures.

    NetpbmOptions

    pub(all) struct NetpbmOptions {
    format : NetpbmFormat
    max_value : Int
    include_comments : Bool
    } derive(
    Debug
    )

    NetpbmOptions::comments

    fn NetpbmOptions::comments(self : NetpbmOptions, enabled : Bool) -> NetpbmOptions

    NetpbmOptions::default

    fn NetpbmOptions::default() -> NetpbmOptions

    NetpbmOptions::format

    fn NetpbmOptions::format(self : NetpbmOptions, format : NetpbmFormat) -> NetpbmOptions

    NetpbmOptions::max_value

    fn NetpbmOptions::max_value(self : NetpbmOptions, value : Int) -> NetpbmOptions

    NoiseBlend

    pub(all) enum NoiseBlend {
    AddNoise
    MultiplyNoise
    ReplaceLuma
    } derive(Eq,
    Debug
    )

    Procedural noise utilities for texture, dithering, and synthetic fixtures.

    OptimizationFrame

    pub(all) struct OptimizationFrame {
    index : Int
    source_pixels : Int
    encoded_pixels : Int
    palette_colors : Int
    compressed_bytes : Int
    estimated_bytes : Int
    changed : Bool
    } derive(
    Debug
    )

    OptimizationFrame::changed

    fn OptimizationFrame::changed(self : OptimizationFrame) -> Bool

    OptimizationFrame::compressed_bytes

    fn OptimizationFrame::compressed_bytes(self : OptimizationFrame) -> Int

    OptimizationFrame::encoded_pixels

    fn OptimizationFrame::encoded_pixels(self : OptimizationFrame) -> Int

    OptimizationFrame::estimated_bytes

    fn OptimizationFrame::estimated_bytes(self : OptimizationFrame) -> Int

    OptimizationFrame::index

    fn OptimizationFrame::index(self : OptimizationFrame) -> Int

    OptimizationFrame::palette_colors

    fn OptimizationFrame::palette_colors(self : OptimizationFrame) -> Int

    OptimizationFrame::source_pixels

    fn OptimizationFrame::source_pixels(self : OptimizationFrame) -> Int

    OptimizationOptions

    pub(all) struct OptimizationOptions {
    max_colors : Int
    difference_threshold : Int
    merge_equal_frames : Bool
    crop_delta_frames : Bool
    palette_strategy : PaletteStrategy
    default_delay_cs : Int
    } derive(
    Debug
    )

    OptimizationOptions::colors

    OptimizationOptions::crop_deltas

    fn OptimizationOptions::crop_deltas(self : OptimizationOptions, enabled : Bool) -> OptimizationOptions

    OptimizationOptions::default

    OptimizationOptions::merge_equal

    fn OptimizationOptions::merge_equal(self : OptimizationOptions, enabled : Bool) -> OptimizationOptions

    OptimizationOptions::palette

    OptimizationOptions::threshold

    fn OptimizationOptions::threshold(self : OptimizationOptions, value : Int) -> OptimizationOptions

    OptimizationReport

    pub(all) struct OptimizationReport {
    input_frames : Int
    output_frames : Int
    input_pixels : Int
    output_pixels : Int
    palette_bytes : Int
    compressed_bytes : Int
    estimated_bytes : Int
    changed_frames : Int
    frames : Array[OptimizationFrame]
    } derive(
    Debug
    )

    OptimizationReport::changed_frames

    fn OptimizationReport::changed_frames(self : OptimizationReport) -> Int

    OptimizationReport::compressed_bytes

    fn OptimizationReport::compressed_bytes(self : OptimizationReport) -> Int

    OptimizationReport::estimated_bytes

    fn OptimizationReport::estimated_bytes(self : OptimizationReport) -> Int

    OptimizationReport::frames

    OptimizationReport::input_frames

    fn OptimizationReport::input_frames(self : OptimizationReport) -> Int

    OptimizationReport::input_pixels

    fn OptimizationReport::input_pixels(self : OptimizationReport) -> Int

    OptimizationReport::output_frames

    fn OptimizationReport::output_frames(self : OptimizationReport) -> Int

    OptimizationReport::output_pixels

    fn OptimizationReport::output_pixels(self : OptimizationReport) -> Int

    OptimizationReport::palette_bytes

    fn OptimizationReport::palette_bytes(self : OptimizationReport) -> Int

    OptimizationReport::saving_per_mille

    fn OptimizationReport::saving_per_mille(self : OptimizationReport) -> Int

    Palette

    pub(all) struct Palette {
    colors : Array[Rgba]
    transparent_index : Int?
    } derive(
    Debug
    )

    A compact GIF color table and the optional transparent entry.

    Palette::color

    fn Palette::color(self : Palette, index : Int) -> Rgba?

    Palette::colors

    fn Palette::colors(self : Palette) -> ArrayView[Rgba]

    Palette::contains

    fn Palette::contains(self : Palette, color : Rgba) -> Bool

    Palette::len

    fn Palette::len(self : Palette) -> Int

    Palette::nearest

    fn Palette::nearest(self : Palette, color : Rgba) -> Int

    Palette::nearest_rgba

    fn Palette::nearest_rgba(self : Palette, color : Rgba) -> Int

    Return the closest palette entry using squared Euclidean RGBA distance.

    Palette::new

    fn Palette::new(colors~ : Array[Rgba], transparent_index~ : Int?) -> Palette

    Palette::to_rgb_bytes

    fn Palette::to_rgb_bytes(self : Palette, table_size~ : Int) -> Bytes

    Serialize an RGB color table without GIF sub-block framing.

    Palette::transparent_index

    fn Palette::transparent_index(self : Palette) -> Int?

    Palette::with_transparency

    fn Palette::with_transparency(self : Palette, color : Rgba) -> Palette

    Add a transparent entry while retaining a palette's existing colors.

    PaletteMap

    pub(all) struct PaletteMap {
    source : Palette
    target : Palette
    mapping : Array[Byte]
    } derive(
    Debug
    )

    Explicit palette maps for reusable indexed-frame transformations.

    PaletteMap::exact_entries

    fn PaletteMap::exact_entries(self : PaletteMap) -> Int

    Count the number of source colors that map exactly to the target palette.

    PaletteMap::mapping

    fn PaletteMap::mapping(self : PaletteMap) -> ArrayView[Byte]

    PaletteMap::source

    fn PaletteMap::source(self : PaletteMap) -> Palette

    PaletteMap::target

    fn PaletteMap::target(self : PaletteMap) -> Palette

    PalettePlan

    pub(all) struct PalettePlan {
    mode : PalettePlanMode
    max_colors : Int
    transparent : Rgba?
    } derive(
    Debug
    )

    PalettePlan::colors

    fn PalettePlan::colors(self : PalettePlan) -> Int

    PalettePlan::mode

    PalettePlan::new

    fn PalettePlan::new(mode : PalettePlanMode, max_colors : Int) -> PalettePlan

    PalettePlan::with_transparent

    fn PalettePlan::with_transparent(self : PalettePlan, color : Rgba?) -> PalettePlan

    PalettePlanMode

    pub(all) enum PalettePlanMode {
    LocalMedianCut
    SharedMedianCut
    OrderedShared
    FloydShared
    } derive(Eq,
    Debug
    )

    Palette strategy used by still-image and animation export paths.

    PaletteQuality

    pub(all) struct PaletteQuality {
    palette_size : Int
    pixels : Int
    mean_error : Int
    maximum_error : Int
    exact_pixels : Int
    } derive(
    Debug
    )

    PaletteQuality::exact_pixels

    fn PaletteQuality::exact_pixels(self : PaletteQuality) -> Int

    PaletteQuality::maximum_error

    fn PaletteQuality::maximum_error(self : PaletteQuality) -> Int

    PaletteQuality::mean_error

    fn PaletteQuality::mean_error(self : PaletteQuality) -> Int

    PaletteQuality::palette_size

    fn PaletteQuality::palette_size(self : PaletteQuality) -> Int

    PaletteQuality::pixels

    fn PaletteQuality::pixels(self : PaletteQuality) -> Int

    PaletteSample

    type PaletteSample derive(
    Debug
    )

    PaletteStrategy

    pub(all) enum PaletteStrategy {
    LocalPerFrame
    GlobalFirstFrame
    Adaptive
    } derive(Eq,
    Debug
    )

    Palette policy used by the size planner.

    PatchFrame

    pub(all) struct PatchFrame {
    patch : PixelPatch
    delay_cs : Int
    } derive(
    Debug
    )

    PatchFrame::delay_cs

    fn PatchFrame::delay_cs(self : PatchFrame) -> Int

    PatchFrame::patch

    fn PatchFrame::patch(self : PatchFrame) -> PixelPatch

    PatternKind

    pub(all) enum PatternKind {
    Checker
    Stripes
    Rings
    Waves
    Noise
    Gradient
    } derive(Eq,
    Debug
    )

    Deterministic procedural scenes used by examples, tests, and demos.

    PatternOptions

    pub(all) struct PatternOptions {
    kind : PatternKind
    scale : Int
    seed : Int
    first : Rgba
    second : Rgba
    } derive(
    Debug
    )

    PatternOptions::colors

    fn PatternOptions::colors(self : PatternOptions, first : Rgba, second : Rgba) -> PatternOptions

    PatternOptions::default

    PatternOptions::kind

    PatternOptions::scale

    fn PatternOptions::scale(self : PatternOptions, value : Int) -> PatternOptions

    PatternOptions::seed

    fn PatternOptions::seed(self : PatternOptions, value : Int) -> PatternOptions

    PipelineReport

    pub(all) struct PipelineReport {
    stage_count : Int
    input_pixels : Int
    output_pixels : Int
    labels : Array[String]
    } derive(
    Debug
    )

    PipelineReport::input_pixels

    fn PipelineReport::input_pixels(self : PipelineReport) -> Int

    PipelineReport::labels

    fn PipelineReport::labels(self : PipelineReport) -> ArrayView[String]

    PipelineReport::output_pixels

    fn PipelineReport::output_pixels(self : PipelineReport) -> Int

    PipelineReport::stage_count

    fn PipelineReport::stage_count(self : PipelineReport) -> Int

    PipelineStage

    pub(all) enum PipelineStage {
    Gray
    InvertColors
    Blur(radius~ : Int)
    GaussianBlur
    Sharpen
    Edge
    Posterize(levels~ : Int)
    Threshold(level~ : Byte)
    Normalize
    Dither(levels~ : Int)
    Pixelate(block~ : Int)
    Grain(amount~ : Int, seed~ : Int)
    Tint(color~ : Rgba, strength~ : Int)
    Adjust(adjustment~ : ColorAdjustment)
    Convolve(kernel~ : ConvolutionKernel)
    Dilate(radius~ : Int, mode~ : MorphologyMode)
    Erode(radius~ : Int, mode~ : MorphologyMode)
    ChromaKey(key~ : Rgba, tolerance~ : Int)
    Crop(x~ : Int, y~ : Int, width~ : Int, height~ : Int)
    Resize(width~ : Int, height~ : Int)
    FlipHorizontal
    FlipVertical
    } derive(
    Debug
    )

    Reusable image operations for command-line and embedding integrations.

    PixelHistogram

    pub(all) struct PixelHistogram {
    red : Array[Int]
    green : Array[Int]
    blue : Array[Int]
    alpha : Array[Int]
    luma : Array[Int]
    total : Int
    } derive(
    Debug
    )

    Per-channel 8-bit histogram collected in one pass over a canvas.

    PixelHistogram::alpha_bins

    fn PixelHistogram::alpha_bins(self : PixelHistogram) -> ArrayView[Int]

    PixelHistogram::blue_bins

    fn PixelHistogram::blue_bins(self : PixelHistogram) -> ArrayView[Int]

    PixelHistogram::blue_peak

    fn PixelHistogram::blue_peak(self : PixelHistogram) -> Byte

    PixelHistogram::green_bins

    fn PixelHistogram::green_bins(self : PixelHistogram) -> ArrayView[Int]

    PixelHistogram::green_peak

    fn PixelHistogram::green_peak(self : PixelHistogram) -> Byte

    PixelHistogram::luma_bins

    fn PixelHistogram::luma_bins(self : PixelHistogram) -> ArrayView[Int]

    PixelHistogram::luma_peak

    fn PixelHistogram::luma_peak(self : PixelHistogram) -> Byte

    PixelHistogram::mean_luma

    fn PixelHistogram::mean_luma(self : PixelHistogram) -> Int

    PixelHistogram::percentile_luma

    fn PixelHistogram::percentile_luma(self : PixelHistogram, percentile : Int) -> Byte

    PixelHistogram::red_bins

    fn PixelHistogram::red_bins(self : PixelHistogram) -> ArrayView[Int]

    PixelHistogram::red_peak

    fn PixelHistogram::red_peak(self : PixelHistogram) -> Byte

    PixelHistogram::total

    fn PixelHistogram::total(self : PixelHistogram) -> Int

    PixelPatch

    pub(all) struct PixelPatch {
    rect : GifRect
    pixels : Array[Rgba]
    } derive(
    Debug
    )

    A rectangular patch containing pixels that differ from a previous canvas.

    PixelPatch::area

    fn PixelPatch::area(self : PixelPatch) -> Int

    PixelPatch::as_frame

    fn PixelPatch::as_frame(self : PixelPatch, delay_cs~ : Int) -> Frame

    Return a patch suitable for a GIF local image descriptor.

    PixelPatch::is_empty

    fn PixelPatch::is_empty(self : PixelPatch) -> Bool

    PixelPatch::pixel_count

    fn PixelPatch::pixel_count(self : PixelPatch) -> Int

    PixelPatch::pixels

    fn PixelPatch::pixels(self : PixelPatch) -> ArrayView[Rgba]

    PixelPatch::rect

    fn PixelPatch::rect(self : PixelPatch) -> GifRect

    PlaybackMode

    pub(all) enum PlaybackMode {
    Once
    Loop
    PingPong
    Clamp
    } derive(Eq,
    Debug
    )

    Playback state for embedders that need deterministic frame stepping.

    PlaybackSnapshot

    pub(all) struct PlaybackSnapshot {
    time_cs : Int
    frame_index : Int
    progress_per_mille : Int
    playing : Bool
    } derive(
    Debug
    )

    Produce a playback snapshot suitable for a UI overlay.

    PlaybackSnapshot::frame_index

    fn PlaybackSnapshot::frame_index(self : PlaybackSnapshot) -> Int

    PlaybackSnapshot::playing

    fn PlaybackSnapshot::playing(self : PlaybackSnapshot) -> Bool

    PlaybackSnapshot::progress

    fn PlaybackSnapshot::progress(self : PlaybackSnapshot) -> Int

    PlaybackSnapshot::time

    fn PlaybackSnapshot::time(self : PlaybackSnapshot) -> Int

    PlaybackState

    pub(all) struct PlaybackState {
    animation : Animation
    mode : PlaybackMode
    time_cs : Int
    direction : Int
    playing : Bool
    } derive(
    Debug
    )

    PlaybackState::advance

    fn PlaybackState::advance(self : PlaybackState, elapsed_cs : Int) -> PlaybackState

    Advance playback by centiseconds, applying the selected mode at boundaries.

    PlaybackState::animation

    fn PlaybackState::animation(self : PlaybackState) -> Animation

    PlaybackState::current_frame

    fn PlaybackState::current_frame(self : PlaybackState) -> Frame?

    PlaybackState::mode

    PlaybackState::new

    fn PlaybackState::new(animation : Animation, mode : PlaybackMode) -> PlaybackState

    PlaybackState::pause

    PlaybackState::play

    PlaybackState::playing

    fn PlaybackState::playing(self : PlaybackState) -> Bool

    PlaybackState::progress

    fn PlaybackState::progress(self : PlaybackState) -> Int

    Return normalized playback progress in per mille.

    PlaybackState::reset

    PlaybackState::seek

    fn PlaybackState::seek(self : PlaybackState, time_cs : Int) -> PlaybackState

    PlaybackState::snapshot

    PlaybackState::step_frames

    fn PlaybackState::step_frames(self : PlaybackState, count : Int) -> PlaybackState

    Advance by a frame count using the animation's own delays.

    PlaybackState::time

    fn PlaybackState::time(self : PlaybackState) -> Int

    Point2i

    pub(all) struct Point2i {
    x : Int
    y : Int
    } derive(Eq,
    Debug
    )

    Small vector primitives used to draw overlays without a foreign runtime.

    Point2i::new

    fn Point2i::new(x : Int, y : Int) -> Point2i

    Point2i::offset

    fn Point2i::offset(self : Point2i, dx : Int, dy : Int) -> Point2i

    Point2i::x

    fn Point2i::x(self : Point2i) -> Int

    Point2i::y

    fn Point2i::y(self : Point2i) -> Int

    Polyline

    pub(all) struct Polyline {
    points : Array[Point2i]
    closed : Bool
    } derive(
    Debug
    )

    Polyline::bounds

    fn Polyline::bounds(self : Polyline) -> GifRect?

    Polyline::closed

    fn Polyline::closed(self : Polyline) -> Bool

    Polyline::new

    fn Polyline::new(points : Array[Point2i], closed : Bool) -> Polyline

    Polyline::points

    fn Polyline::points(self : Polyline) -> ArrayView[Point2i]

    Polyline::translated

    fn Polyline::translated(self : Polyline, dx : Int, dy : Int) -> Polyline

    QualityMetrics

    pub(all) struct QualityMetrics {
    pixels : Int
    differing_pixels : Int
    mean_squared_error : Int
    maximum_error : Int
    alpha_error : Int
    psnr_milli : Int
    } derive(
    Debug
    )

    Mean squared and perceptual error metrics for comparing encoded frames.

    QualityMetrics::alpha_error

    fn QualityMetrics::alpha_error(self : QualityMetrics) -> Int

    QualityMetrics::differing_pixels

    fn QualityMetrics::differing_pixels(self : QualityMetrics) -> Int

    QualityMetrics::maximum_error

    fn QualityMetrics::maximum_error(self : QualityMetrics) -> Int

    QualityMetrics::mean_squared_error

    fn QualityMetrics::mean_squared_error(self : QualityMetrics) -> Int

    QualityMetrics::pixels

    fn QualityMetrics::pixels(self : QualityMetrics) -> Int

    QualityMetrics::psnr_milli

    fn QualityMetrics::psnr_milli(self : QualityMetrics) -> Int

    QuantizedFrame

    pub(all) struct QuantizedFrame {
    palette : Palette
    indices : Array[Byte]
    } derive(
    Debug
    )

    Quantized pixels plus the palette used to encode them.

    QuantizedFrame::indices

    fn QuantizedFrame::indices(self : QuantizedFrame) -> ArrayView[Byte]

    QuantizedFrame::is_gif_compatible

    fn QuantizedFrame::is_gif_compatible(self : QuantizedFrame) -> Bool

    Report whether a quantized frame obeys GIF's 8-bit palette contract.

    QuantizedFrame::map_palette

    fn QuantizedFrame::map_palette(self : QuantizedFrame, map : PaletteMap) -> QuantizedFrame

    Apply a palette map without touching pixel geometry.

    QuantizedFrame::palette

    fn QuantizedFrame::palette(self : QuantizedFrame) -> Palette

    QuantizedFrame::to_canvas

    fn QuantizedFrame::to_canvas(self : QuantizedFrame, width~ : Int, height~ : Int) -> Canvas

    Reconstruct a canvas from a quantized frame.

    RegionSummary

    pub(all) struct RegionSummary {
    rect : GifRect
    pixels : Int
    opaque_pixels : Int
    transparent_pixels : Int
    average : Rgba
    minimum_luma : Byte
    maximum_luma : Byte
    } derive(
    Debug
    )

    Region-level statistics used for crop selection and scene analysis.

    RegionSummary::average

    fn RegionSummary::average(self : RegionSummary) -> Rgba

    RegionSummary::maximum_luma

    fn RegionSummary::maximum_luma(self : RegionSummary) -> Byte

    RegionSummary::minimum_luma

    fn RegionSummary::minimum_luma(self : RegionSummary) -> Byte

    RegionSummary::opaque_pixels

    fn RegionSummary::opaque_pixels(self : RegionSummary) -> Int

    RegionSummary::pixels

    fn RegionSummary::pixels(self : RegionSummary) -> Int

    RegionSummary::rect

    fn RegionSummary::rect(self : RegionSummary) -> GifRect

    RegionSummary::transparent_pixels

    fn RegionSummary::transparent_pixels(self : RegionSummary) -> Int

    ResampleFilter

    pub(all) enum ResampleFilter {
    NearestPixel
    BoxAverage
    BilinearInteger
    } derive(Eq,
    Debug
    )

    Resampling filters selected explicitly for quality or speed.

    ResampleReport

    pub(all) struct ResampleReport {
    input_width : Int
    input_height : Int
    output_width : Int
    output_height : Int
    filter : ResampleFilter
    input_pixels : Int
    output_pixels : Int
    } derive(
    Debug
    )

    ResampleReport::filter

    ResampleReport::input_pixels

    fn ResampleReport::input_pixels(self : ResampleReport) -> Int

    ResampleReport::input_size

    fn ResampleReport::input_size(self : ResampleReport) -> (Int, Int)

    ResampleReport::output_pixels

    fn ResampleReport::output_pixels(self : ResampleReport) -> Int

    ResampleReport::output_size

    fn ResampleReport::output_size(self : ResampleReport) -> (Int, Int)

    Rgba

    pub(all) struct Rgba {
    r : Byte
    g : Byte
    b : Byte
    a : Byte
    } derive(Eq,
    Debug
    )

    An RGBA color stored in the byte order used by GIF compositing.

    Rgba::alpha

    fn Rgba::alpha(self : Rgba) -> Byte

    Rgba::blend_over

    fn Rgba::blend_over(self : Rgba, destination : Rgba) -> Rgba

    Rgba::blue

    fn Rgba::blue(self : Rgba) -> Byte

    Rgba::distance

    fn Rgba::distance(self : Rgba, other : Rgba) -> Int

    Rgba::grayscale

    fn Rgba::grayscale(self : Rgba) -> Rgba

    Rgba::green

    fn Rgba::green(self : Rgba) -> Byte

    Rgba::hsl

    fn Rgba::hsl(self : Rgba) -> HslColor

    Convert an RGBA color to HSL.

    Rgba::hsv

    fn Rgba::hsv(self : Rgba) -> HsvColor

    Convert an RGBA color to HSV using integer arithmetic for deterministic results across native, JavaScript, and WebAssembly targets.

    Rgba::invert

    fn Rgba::invert(self : Rgba) -> Rgba

    Rgba::is_opaque

    fn Rgba::is_opaque(self : Rgba) -> Bool

    Rgba::is_transparent

    fn Rgba::is_transparent(self : Rgba) -> Bool

    Rgba::luma

    fn Rgba::luma(self : Rgba) -> Byte

    A perceptual-ish luminance value in the 0..255 range.

    Rgba::opaque_copy

    fn Rgba::opaque_copy(self : Rgba) -> Rgba

    Rgba::packed_rgb

    fn Rgba::packed_rgb(self : Rgba) -> Int

    Return a compact hexadecimal-like RGB triplet for diagnostics.

    Rgba::premultiply

    fn Rgba::premultiply(self : Rgba) -> Rgba

    Rgba::red

    fn Rgba::red(self : Rgba) -> Byte

    Rgba::to_yuv

    fn Rgba::to_yuv(self : Rgba) -> YuvColor

    Rgba::unpremultiply

    fn Rgba::unpremultiply(self : Rgba) -> Rgba

    Rgba::with_alpha

    fn Rgba::with_alpha(self : Rgba, alpha : Byte) -> Rgba

    SamplingMode

    pub(all) enum SamplingMode {
    Nearest
    BoxAverage
    } derive(Eq,
    Debug
    )

    Sampling policy for thumbnails and preview images.

    ScalePlan

    pub(all) struct ScalePlan {
    source_width : Int
    source_height : Int
    target_width : Int
    target_height : Int
    scale_per_mille : Int
    crop : Bool
    } derive(
    Debug
    )

    Scale planning helpers for screen recordings and sticker exports.

    ScalePlan::crop

    fn ScalePlan::crop(self : ScalePlan) -> Bool

    ScalePlan::scale

    fn ScalePlan::scale(self : ScalePlan) -> Int

    ScalePlan::source

    fn ScalePlan::source(self : ScalePlan) -> (Int, Int)

    ScalePlan::target

    fn ScalePlan::target(self : ScalePlan) -> (Int, Int)

    SpatialStats

    pub(all) struct SpatialStats {
    center : Rgba
    corners : Array[Rgba]
    quadrant_luma : Array[Int]
    opaque_bounds : GifRect?
    variance_milli : Int
    } derive(
    Debug
    )

    Additional spatial statistics for crop, quality, and scene detection.

    SpatialStats::center

    fn SpatialStats::center(self : SpatialStats) -> Rgba

    SpatialStats::corners

    fn SpatialStats::corners(self : SpatialStats) -> ArrayView[Rgba]

    SpatialStats::opaque_bounds

    fn SpatialStats::opaque_bounds(self : SpatialStats) -> GifRect?

    SpatialStats::quadrant_luma

    fn SpatialStats::quadrant_luma(self : SpatialStats) -> ArrayView[Int]

    SpatialStats::variance_milli

    fn SpatialStats::variance_milli(self : SpatialStats) -> Int

    SpriteAtlas

    pub(all) struct SpriteAtlas {
    pages : Array[AtlasPage]
    placements : Array[SpritePlacement]
    page_width : Int
    page_height : Int
    } derive(
    Debug
    )

    SpriteAtlas::extract

    fn SpriteAtlas::extract(self : SpriteAtlas, name : String) -> Canvas?

    Extract a named sprite from its atlas page.

    SpriteAtlas::find

    fn SpriteAtlas::find(self : SpriteAtlas, name : String) -> SpritePlacement?

    SpriteAtlas::page_count

    fn SpriteAtlas::page_count(self : SpriteAtlas) -> Int

    SpriteAtlas::pages

    SpriteAtlas::placements

    SpriteAtlas::to_animation

    fn SpriteAtlas::to_animation(self : SpriteAtlas, page_index : Int, delay_cs~ : Int) -> Animation

    Convert an atlas page into a new animation in placement order.

    SpritePlacement

    pub(all) struct SpritePlacement {
    name : String
    page : Int
    x : Int
    y : Int
    width : Int
    height : Int
    source_width : Int
    source_height : Int
    rotated : Bool
    } derive(
    Debug
    )

    A placement in a packed atlas page.

    SpritePlacement::name

    fn SpritePlacement::name(self : SpritePlacement) -> String

    SpritePlacement::page

    fn SpritePlacement::page(self : SpritePlacement) -> Int

    SpritePlacement::rect

    SpritePlacement::rotated

    fn SpritePlacement::rotated(self : SpritePlacement) -> Bool

    SpritePlacement::source_size

    fn SpritePlacement::source_size(self : SpritePlacement) -> (Int, Int)

    SpriteSource

    pub(all) struct SpriteSource {
    name : String
    canvas : Canvas
    padding : Int
    extrude : Bool
    } derive(
    Debug
    )

    A named sprite input for atlas packing.

    SpriteSource::canvas

    fn SpriteSource::canvas(self : SpriteSource) -> Canvas

    SpriteSource::extrude

    fn SpriteSource::extrude(self : SpriteSource) -> Bool

    SpriteSource::name

    fn SpriteSource::name(self : SpriteSource) -> String

    SpriteSource::new

    fn SpriteSource::new(name : String, canvas : Canvas) -> SpriteSource

    SpriteSource::padding

    fn SpriteSource::padding(self : SpriteSource) -> Int

    SpriteSource::with_extrude

    fn SpriteSource::with_extrude(self : SpriteSource, enabled : Bool) -> SpriteSource

    SpriteSource::with_padding

    fn SpriteSource::with_padding(self : SpriteSource, padding : Int) -> SpriteSource

    TileMode

    pub(all) enum TileMode {
    Repeat
    Mirror
    Clamp
    } derive(Eq,
    Debug
    )

    Integer-only geometric effects for deterministic sprite and GIF output.

    TimelineMarker

    pub(all) struct TimelineMarker {
    name : String
    time_cs : Int
    frame_index : Int
    color : Rgba
    } derive(
    Debug
    )

    Timeline marker for editors, captions, and export orchestration.

    TimelineMarker::color

    fn TimelineMarker::color(self : TimelineMarker) -> Rgba

    TimelineMarker::frame

    fn TimelineMarker::frame(self : TimelineMarker) -> Int

    TimelineMarker::name

    fn TimelineMarker::name(self : TimelineMarker) -> String

    TimelineMarker::new

    fn TimelineMarker::new(name : String, time_cs : Int, color : Rgba) -> TimelineMarker

    TimelineMarker::time

    fn TimelineMarker::time(self : TimelineMarker) -> Int

    TimelineMetrics

    pub(all) struct TimelineMetrics {
    frames : Int
    duration_cs : Int
    minimum_delay_cs : Int
    maximum_delay_cs : Int
    mean_delay_cs : Int
    empty_frames : Int
    active_pixels : Int
    } derive(
    Debug
    )

    Timeline metrics used to compare edits before exporting.

    TimelineMetrics::active_pixels

    fn TimelineMetrics::active_pixels(self : TimelineMetrics) -> Int

    TimelineMetrics::duration

    fn TimelineMetrics::duration(self : TimelineMetrics) -> Int

    TimelineMetrics::empty_frames

    fn TimelineMetrics::empty_frames(self : TimelineMetrics) -> Int

    TimelineMetrics::frames

    fn TimelineMetrics::frames(self : TimelineMetrics) -> Int

    TimelineMetrics::maximum_delay

    fn TimelineMetrics::maximum_delay(self : TimelineMetrics) -> Int

    TimelineMetrics::mean_delay

    fn TimelineMetrics::mean_delay(self : TimelineMetrics) -> Int

    TimelineMetrics::minimum_delay

    fn TimelineMetrics::minimum_delay(self : TimelineMetrics) -> Int

    TimelinePolicy

    pub(all) enum TimelinePolicy {
    KeepDurations
    Uniform
    PreserveTotal
    ClampToGif
    } derive(Eq,
    Debug
    )

    TimelinePosition

    pub(all) struct TimelinePosition {
    index : Int
    elapsed_cs : Int
    remaining_cs : Int
    } derive(Eq,
    Debug
    )

    A resolved position on an animation timeline.

    TimelinePosition::elapsed_cs

    fn TimelinePosition::elapsed_cs(self : TimelinePosition) -> Int

    TimelinePosition::index

    fn TimelinePosition::index(self : TimelinePosition) -> Int

    TimelinePosition::remaining_cs

    fn TimelinePosition::remaining_cs(self : TimelinePosition) -> Int

    ToneMap

    pub(all) enum ToneMap {
    Linear
    Filmic
    Reinhard
    HighlightRollOff
    } derive(Eq,
    Debug
    )

    Additional production filters built from the core integer raster API.

    TransitionKind

    pub(all) enum TransitionKind {
    CrossFade
    WipeLeft
    WipeRight
    WipeUp
    WipeDown
    ZoomIn
    ZoomOut
    Dissolve
    } derive(Eq,
    Debug
    )

    Transition shapes for generating in-between GIF frames.

    TransitionOptions

    pub(all) struct TransitionOptions {
    kind : TransitionKind
    steps : Int
    delay_cs : Int
    seed : Int
    } derive(
    Debug
    )

    TransitionOptions::default

    TransitionOptions::delay

    fn TransitionOptions::delay(self : TransitionOptions, value : Int) -> TransitionOptions

    TransitionOptions::kind

    TransitionOptions::seed

    fn TransitionOptions::seed(self : TransitionOptions, value : Int) -> TransitionOptions

    TransitionOptions::steps

    fn TransitionOptions::steps(self : TransitionOptions, value : Int) -> TransitionOptions

    VignetteOptions

    pub(all) struct VignetteOptions {
    radius_per_mille : Int
    strength : Int
    color : Rgba
    } derive(
    Debug
    )

    VignetteOptions::color

    fn VignetteOptions::color(self : VignetteOptions, value : Rgba) -> VignetteOptions

    VignetteOptions::default

    VignetteOptions::radius

    fn VignetteOptions::radius(self : VignetteOptions, value : Int) -> VignetteOptions

    VignetteOptions::strength

    fn VignetteOptions::strength(self : VignetteOptions, value : Int) -> VignetteOptions

    YuvColor

    pub(all) struct YuvColor {
    y : Int
    u : Int
    v : Int
    alpha : Byte
    } derive(Eq,
    Debug
    )

    Integer color-space conversions for export and palette preparation.

    YuvColor::alpha

    fn YuvColor::alpha(self : YuvColor) -> Byte

    YuvColor::chrominance_u

    fn YuvColor::chrominance_u(self : YuvColor) -> Int

    YuvColor::chrominance_v

    fn YuvColor::chrominance_v(self : YuvColor) -> Int

    YuvColor::luma

    fn YuvColor::luma(self : YuvColor) -> Int

    acceptance_benchmark_workload

    fn acceptance_benchmark_workload() -> BenchmarkWorkload

    Return a workload that exercises the full export path.

    analyze_lzw

    fn analyze_lzw(indices : ArrayView[Byte], min_code_size : Int) -> LzwStats raise GifError

    animation_from_canvases

    fn animation_from_canvases(canvases : ArrayView[Canvas], delay_cs~ : Int, loop_count? : Int) -> Animation

    Build a timeline from canvases with one delay value.

    animation_from_image_data

    fn animation_from_image_data(images : ArrayView[
    ImageData
    ], delay_cs? : Int, loop_count? : Int) -> Animation raise GifError

    Build an animation from RGBA images decoded or resized by mizchi/image.

    animation_from_patches

    fn animation_from_patches(width~ : Int, height~ : Int, background~ : Rgba, patches : ArrayView[PatchFrame], loop_count? : Int?) -> Animation

    Reconstruct full frames from patch frames.

    apply_patches

    fn apply_patches(width~ : Int, height~ : Int, background~ : Rgba, patches : ArrayView[PixelPatch]) -> Canvas

    Rebuild a full canvas by applying patches to a background.

    archive_workflow

    fn archive_workflow() -> GifWorkflow

    Return a high-fidelity plan for archival output.

    balanced_workflow

    fn balanced_workflow() -> GifWorkflow

    Return a balanced plan for ordinary web and documentation exports.

    benchmark_animation

    fn benchmark_animation(workload : BenchmarkWorkload) -> Animation

    Generate the shared benchmark workload without randomness or external files.

    benchmark_delta

    fn benchmark_delta(left : BenchmarkResult, right : BenchmarkResult) -> (Int, Int)

    Compare two benchmark runs by encoded size and quality error.

    blend_rgba_mode

    fn blend_rgba_mode(source : Rgba, destination : Rgba, mode : BlendMode) -> Rgba

    Blend two pixels while preserving source-over alpha semantics.

    board_animation

    fn board_animation(animation : Animation, columns : Int, cell_width : Int, cell_height : Int, gap : Int, background : Rgba) -> Canvas

    Render a frame sequence as a centered board with a fixed cell size.

    build_palette_map

    fn build_palette_map(source : Palette, target : Palette) -> PaletteMap

    Build a nearest-color map between two palettes.

    can_roundtrip

    fn can_roundtrip(data : Bytes) -> Bool

    Test whether a decoded animation can be re-encoded losslessly in shape.

    canvas_digest_equal

    fn canvas_digest_equal(left : Canvas, right : Canvas) -> Bool

    Return true when two canvases have equal dimensions and digest.

    canvas_from_image_data

    fn canvas_from_image_data(image :
    ImageData
    ) -> Canvas raise GifError

    Convert mizchi/image RGBA ImageData into the animation engine's Canvas.

    mizchi/image normalizes decoded PNG/BMP/JPEG data to four bytes per pixel. This adapter keeps that representation at the package boundary and lets the animation core own frame timing, disposal, and GIF indexing.

    canvas_from_rgba_bytes

    fn canvas_from_rgba_bytes(width~ : Int, height~ : Int, bytes : Bytes) -> Canvas raise GifError

    Construct a canvas from tightly packed RGBA bytes.

    centiseconds_to_milliseconds

    fn centiseconds_to_milliseconds(value : Int) -> Int

    Convert centiseconds to a display-friendly millisecond duration.

    changed_bounds

    fn changed_bounds(left : Canvas, right : Canvas) -> (Int, Int, Int, Int)?

    Return the smallest rectangle containing changed pixels, or None when equal.

    changed_rect

    fn changed_rect(left : Canvas, right : Canvas, threshold : Int) -> GifRect?

    Find changed pixels using a squared RGBA distance threshold.

    checkerboard_canvas

    fn checkerboard_canvas(width~ : Int, height~ : Int, cell_size? : Int, light? : Rgba, dark? : Rgba) -> Canvas

    Create a tiled checkerboard useful as a transparency preview background.

    choose_palette_budget

    fn choose_palette_budget(animation : Animation, budget_bytes : Int, options : OptimizationOptions) -> Int raise GifError

    Choose a palette budget that fits an estimated byte budget.

    clamp_palette_size

    fn clamp_palette_size(size : Int) -> Int

    Clamp an arbitrary palette budget to GIF's legal range.

    collect_chunks

    fn collect_chunks(chunks : ArrayView[GifChunk]) -> Bytes

    Feed chunks in arbitrary order and reassemble by their declared offset.

    command_description

    fn command_description(command : GifCommand) -> String

    Return a short command description for shell help.

    compare_animation_quality

    fn compare_animation_quality(left : Animation, right : Animation) -> AnimationQuality

    Compare matching frame positions using existing deterministic metrics.

    compare_timeline

    fn compare_timeline(left : Animation, right : Animation) -> (Int, Int, Int)

    Compare timeline structure without comparing pixels.

    compare_workflow_reports

    fn compare_workflow_reports(left : GifWorkflowReport, right : GifWorkflowReport) -> (Int, Int)

    Compare two workflow reports by encoded size and retained pixels.

    compatible_animation

    fn compatible_animation(width : Int, height : Int, frames : ArrayView[Canvas], delay_cs : Int) -> Animation

    Construct a GIF89a-compatible animation with a safe default delay.

    compose

    fn compose(animation : Animation) -> Array[Canvas]

    Compose frames in display order and apply GIF disposal semantics.

    The returned canvases are independent snapshots, so callers can render or compare them without mutating later frames. Background clears only the frame rectangle; Previous restores the canvas from before the frame.

    compose_layers

    fn compose_layers(base : Canvas, overlays : ArrayView[ImageLayer]) -> Canvas

    Construct a stack from one base canvas and ordered overlays.

    composite_activity

    fn composite_activity(base : Animation, overlay : Animation) -> Array[Int]

    Compute a frame-wise composite difference between two animations.

    composite_animations

    fn composite_animations(base : Animation, overlay : Animation, options? : CompositeOptions) -> Animation

    Composite one animation over another at a shared timeline position.

    composite_three

    fn composite_three(base : Animation, middle : Animation, front : Animation, options : CompositeOptions) -> Animation

    Compose three animation layers in back-to-front order.

    contain_layout

    fn contain_layout(canvas : Canvas, width : Int, height : Int, background : Rgba) -> Canvas

    Place a canvas inside a safe rectangle with letterboxing.

    crossfade

    fn crossfade(left : Animation, right : Animation, steps : Int, delay_cs? : Int) -> Animation

    Generate a cross-fade animation from the last frame of left to the first frame of right. steps is the number of intervals, so steps=1 emits the two endpoint frames.

    crossfade_animations

    fn crossfade_animations(left : Animation, right : Animation, steps : Int, delay_cs : Int) -> Animation

    Crossfade two complete animations by pairing frames cyclically.

    decode

    fn decode(data : Bytes) -> Animation raise GifError

    Decode a GIF87a/GIF89a stream into an animation.

    decode_after_preflight

    fn decode_after_preflight(data : Bytes, limits : GifLimits) -> Animation?

    Decode only after a successful preflight.

    decode_checked

    fn decode_checked(data : Bytes) -> Animation?

    Decode without throwing across an application callback boundary.

    decode_first_frame

    fn decode_first_frame(data : Bytes) -> Frame?

    Decode the first visible frame, if a stream contains one.

    decode_first_image_data

    fn decode_first_image_data(data : Bytes) ->
    ImageData
    raise GifError

    Decode the first composited frame into the upstream ImageData shape.

    decode_netpbm

    fn decode_netpbm(data : Bytes) -> Canvas raise GifError

    Decode binary PPM/PAM/PGM data into an RGBA canvas.

    difference_heatmap

    fn difference_heatmap(left : Canvas, right : Canvas) -> Canvas

    Build a heatmap of changes between two equally sized canvases.

    disposal_hint

    fn disposal_hint(disposal : Disposal) -> DisposalHint

    edit_report

    fn edit_report(before : Animation, after : Animation) -> EditReport

    Return a report for an edit operation without hiding the before/after data.

    encode

    fn encode(animation : Animation) -> Bytes raise GifError

    Encode with the standard 256-color palette budget and loop metadata.

    encode_batch

    fn encode_batch(items : ArrayView[BatchItem], profile : ExportProfile) -> (Array[(String, Bytes)], BatchReport)

    Encode a batch, retaining successful output and continuing after failures.

    encode_canvas_checked

    fn encode_canvas_checked(canvas : Canvas, colors : Int, delay_cs : Int) -> EncodeOutcome

    Encode a canvas with a single call and a safe palette budget.

    encode_checked

    fn encode_checked(animation : Animation, options : EncodeOptions) -> EncodeOutcome

    Encode without throwing across a foreign-function boundary.

    encode_chunks

    fn encode_chunks(animation : Animation, options? : EncodeOptions, chunk_size? : Int) -> Array[GifChunk] raise GifError

    Split an encoded animation into chunks without duplicating the source buffer.

    encode_image_data

    fn encode_image_data(image :
    ImageData
    , delay_cs? : Int) -> Bytes raise GifError

    Encode one mizchi/image ImageData using the extended GIF engine.

    encode_image_sequence

    fn encode_image_sequence(images : ArrayView[
    ImageData
    ], delay_cs? : Int, loop_count? : Int) -> Bytes raise GifError

    Encode a sequence of upstream ImageData values as a dynamic GIF.

    encode_netpbm

    fn encode_netpbm(canvas : Canvas, options : NetpbmOptions) -> Bytes

    Encode a canvas as binary PPM, PGM, or PAM.

    encode_stream

    fn encode_stream(animation : Animation, options? : EncodeOptions, chunk_size? : Int) -> GifByteStream raise GifError

    Encode an animation and expose the result as fixed-size chunks.

    encode_with_application

    fn encode_with_application(animation : Animation, identifier : String, authentication : String, payload : Bytes, options? : EncodeOptions) -> Bytes raise GifError

    Add a Netscape-compatible application payload without changing loop timing.

    encode_with_comment

    fn encode_with_comment(animation : Animation, comment : String, options? : EncodeOptions) -> Bytes raise GifError

    Add a UTF-8 comment to a freshly encoded animation.

    encode_with_metadata

    fn encode_with_metadata(animation : Animation, metadata : ArrayView[GifMetadata], options? : EncodeOptions) -> Bytes raise GifError

    Encode an animation and insert comment/application extensions before the trailer.

    encode_with_options

    fn encode_with_options(animation : Animation, options : EncodeOptions) -> Bytes raise GifError

    Encode an animation as a standards-compliant GIF89a byte sequence.

    Each frame receives a local palette except the first frame, whose palette becomes the logical screen's global table. This keeps frame-local colors independent while retaining a valid global screen descriptor.

    encoded_quality

    fn encoded_quality(source : Animation, encoded : Bytes) -> AnimationQuality?

    Compare decoded output against source animation shape and colors.

    estimate_frames

    fn estimate_frames(animation : Animation, max_colors? : Int) -> Array[FrameEstimate] raise GifError

    Estimate frame sizes using the same quantizer and LZW encoder as encode.

    estimate_size

    fn estimate_size(animation : Animation, max_colors? : Int) -> Int raise GifError

    Return an estimate for the whole encoded stream.

    explain_gif_error

    fn explain_gif_error(data : Bytes) -> String

    Return a human-readable message for an invalid buffer.

    extract_comments

    fn extract_comments(data : Bytes) -> Array[String] raise GifError

    Read all comment extension payloads without decoding pixel data.

    frame_difference

    fn frame_difference(left : Frame, right : Frame) -> Int

    Calculate how many pixels changed between two full-size frames.

    frame_from_image_data

    fn frame_from_image_data(image :
    ImageData
    , delay_cs? : Int) -> Frame raise GifError

    Build a frame from one mizchi/image image.

    grayscale_palette

    fn grayscale_palette(size : Int) -> Palette

    Build a grayscale palette with a deterministic alpha endpoint.

    grid_atlas

    fn grid_atlas(frames : ArrayView[Canvas], columns : Int, cell_width : Int, cell_height : Int, padding : Int) -> SpriteAtlas

    Build a regular grid atlas without searching for free rectangles.

    has_gif_signature

    fn has_gif_signature(data : Bytes) -> Bool

    Check only the signature, without requiring complete frame data.

    hue_palette

    fn hue_palette(size : Int, saturation : Byte, value : Byte) -> Palette

    Build a hue wheel palette for indexed previews and test patterns.

    index_gif

    fn index_gif(data : Bytes) -> GifByteIndex raise GifError

    Build a conservative frame/extension index without decoding LZW payloads.

    inspect

    fn inspect(data : Bytes) -> GifInfo raise GifError

    Inspect GIF structure while leaving compressed image data untouched.

    interpolate_canvases

    fn interpolate_canvases(first : Canvas, second : Canvas, count : Int, easing~ : Easing) -> Array[Canvas]

    Create intermediate frames between two canvases using an easing curve.

    is_valid

    fn is_valid(data : Bytes) -> Bool

    Return false instead of raising for callers that only need a quick probe.

    join_indices

    fn join_indices(parts : ArrayView[Array[Byte]]) -> Array[Byte]

    Join bounded slices while preserving all index bytes.

    layout_canvases

    fn layout_canvases(canvases : ArrayView[Canvas], direction : LayoutDirection, gap : Int, background : Rgba) -> LayoutResult

    Lay out canvases in a row, column, or fixed-column grid.

    lzw_decode

    fn lzw_decode(data : Bytes, min_code_size : Int, expected_len : Int) -> Array[Byte] raise GifError

    Decode a GIF LZW payload into palette indices.

    expected_len is checked when it is non-negative; the decoder rejects both truncated data and streams that expand beyond the declared image size.

    lzw_decode_sub_blocks

    fn lzw_decode_sub_blocks(data : Bytes, min_code_size : Int, expected_len : Int) -> Array[Byte] raise GifError

    Decode a complete GIF sub-block sequence containing an LZW payload.

    lzw_encode

    fn lzw_encode(indices : ArrayView[Byte], min_code_size : Int) -> Bytes raise GifError

    Encode palette indices into the GIF LZW bit stream.

    The returned bytes are the payload before GIF sub-block framing.

    lzw_encode_sub_blocks

    fn lzw_encode_sub_blocks(indices : ArrayView[Byte], min_code_size : Int) -> Bytes raise GifError

    Encode LZW data and immediately apply GIF sub-block framing.

    lzw_fixture

    fn lzw_fixture(length : Int, colors : Int) -> Array[Byte]

    Build a long-run fixture to exercise dictionary clear behavior.

    lzw_roundtrip

    fn lzw_roundtrip(indices : ArrayView[Byte], minimum_code_size : Int) -> LzwRoundtripReport raise GifError

    Encode and decode an index stream, reporting exactness and size.

    lzw_run_count

    fn lzw_run_count(indices : ArrayView[Byte]) -> Int

    Return the number of runs in a palette index stream.

    make_cli_plan

    fn make_cli_plan(request : GifCliRequest, animation : Animation?) -> GifCliPlan raise GifError

    Convert a request and source animation into an executable plan.

    make_scale_plan

    fn make_scale_plan(source_width : Int, source_height : Int, target_width : Int, target_height : Int, crop : Bool) -> ScalePlan

    Choose a contain or cover plan with integer aspect comparison.

    mask_intersection

    fn mask_intersection(left : Canvas, right : Canvas) -> Canvas

    Combine two masks with a minimum operation.

    mask_subtract

    fn mask_subtract(left : Canvas, right : Canvas) -> Canvas

    Subtract one alpha mask from another.

    mask_union

    fn mask_union(left : Canvas, right : Canvas) -> Canvas

    Combine two masks with a maximum operation.

    merge_palettes

    fn merge_palettes(left : Palette, right : Palette, limit : Int) -> Palette

    Merge two palettes while removing exact duplicates.

    milliseconds_to_centiseconds

    fn milliseconds_to_centiseconds(value : Int) -> Int

    Convert milliseconds to centiseconds using nearest integer rounding.

    minimum_code_size_for_colors

    fn minimum_code_size_for_colors(colors : Int) -> Int

    Estimate a legal GIF minimum code size from a palette count.

    mix_color

    fn mix_color(left : Rgba, right : Rgba, numerator : Int, denominator : Int) -> Rgba

    Linear interpolation in byte space.

    netpbm_format

    fn netpbm_format(data : Bytes) -> NetpbmFormat raise GifError

    Return the format marker without decoding pixel data.

    nine_patch

    fn nine_patch(source : Canvas, width : Int, height : Int, border : Int) -> Canvas

    Crop a nine-patch panel and fill its center without scaling borders.

    normalize_animation

    fn normalize_animation(animation : Animation) -> Animation

    Normalize all frames and preserve a useful placeholder when input is empty.

    normalize_empty_canvas

    fn normalize_empty_canvas(canvas : Canvas) -> Canvas

    Return a transparent placeholder for an empty input canvas.

    normalize_frame

    fn normalize_frame(frame : Frame, screen_width : Int, screen_height : Int) -> Frame?

    Normalize a frame for viewers that reject zero-sized or negative offsets.

    options_for_quality

    fn options_for_quality(target_per_mille : Int) -> OptimizationOptions

    Select a conservative encoding option from a quality target in per mille.

    pack_sprites

    fn pack_sprites(sources : ArrayView[SpriteSource], options : AtlasPackOptions) -> SpriteAtlas

    pack_sub_blocks

    fn pack_sub_blocks(payload : Bytes, block_size? : Int) -> Bytes

    Split a payload into GIF data sub-blocks. The returned bytes include the length byte for every block and the final zero terminator.

    parse_header

    fn parse_header(data : Bytes) -> GifHeader raise GifError

    Read the six-byte signature and logical screen descriptor.

    pattern_test_card

    fn pattern_test_card(width : Int, height : Int) -> Canvas

    Render a small test card containing all basic pattern modes.

    ping_pong_transition

    fn ping_pong_transition(left : Canvas, right : Canvas, steps : Int, delay_cs : Int) -> Animation

    Create a short ping-pong transition with explicit endpoint behavior.

    pixel_difference

    fn pixel_difference(left : Canvas, right : Canvas) -> Int

    Count pixels that differ between two canvases.

    preflight_gif

    fn preflight_gif(data : Bytes, limits : GifLimits) -> GifPreflight

    Inspect basic structure before allocating decoded pixel buffers.

    preview_workflow

    fn preview_workflow() -> GifWorkflow

    Return a plan tuned for a small preview suitable for a contact sheet.

    procedural_animation

    fn procedural_animation(width : Int, height : Int, frames : Int, options : PatternOptions, delay_cs? : Int) -> Animation

    Build a palette-friendly animation by shifting a pattern phase.

    procedural_pattern

    fn procedural_pattern(width : Int, height : Int, options? : PatternOptions) -> Canvas

    Render a deterministic procedural pattern at a requested size.

    quadratic_bezier

    fn quadratic_bezier(start : Point2i, control : Point2i, end : Point2i, samples : Int) -> Polyline

    Sample a quadratic Bezier curve into a polyline.

    quantify_animation

    fn quantify_animation(animation : Animation, plan : PalettePlan) -> Array[PaletteQuality]

    Return per-frame palette distortion for export reports.

    quantify_palette

    fn quantify_palette(canvas : Canvas, quantized : QuantizedFrame) -> PaletteQuality

    Measure palette distortion with deterministic integer arithmetic.

    quantize

    fn quantize(canvas : Canvas, max_colors? : Int, transparent? : Rgba) -> QuantizedFrame

    Quantize an RGBA canvas with a Median Cut palette.

    max_colors is clamped to the GIF range of 2..256. Transparent pixels are removed before quantization and receive a dedicated palette entry.

    quantize_animation

    fn quantize_animation(animation : Animation, plan : PalettePlan) -> Array[QuantizedFrame]

    Quantize every frame while making the palette-sharing decision explicit.

    quantize_dithered

    fn quantize_dithered(canvas : Canvas, max_colors : Int, transparent : Rgba?, mode : DitherMode) -> QuantizedFrame

    Quantize with optional ordered or Floyd-Steinberg error diffusion.

    quick_benchmark_workload

    fn quick_benchmark_workload() -> BenchmarkWorkload

    Return a workload scaled for a quick local smoke check.
    fn recommended_chunk_size(packet_budget : Int) -> Int

    Find a safe chunk size for a transport with a maximum packet budget.

    remap_animation_palette

    fn remap_animation_palette(animation : Animation, palette : Palette) -> Animation

    Remap all frames through a shared target palette.

    remap_to_palette

    fn remap_to_palette(canvas : Canvas, palette : Palette) -> QuantizedFrame

    Remap pixels to a supplied palette without changing canvas dimensions.

    render_clip_sequence

    fn render_clip_sequence(clips : ArrayView[AnimationClip]) -> Animation?

    Render multiple clips back-to-back with no implicit timing gap.

    render_clips_at_rate

    fn render_clips_at_rate(clips : ArrayView[AnimationClip], delay_cs : Int) -> Animation?

    Concatenate clips and normalize delays to a target frame duration.

    render_layers

    fn render_layers(width : Int, height : Int, stacks : ArrayView[LayerStack], delay_cs? : Int) -> Animation

    Render each layer stack into an animation frame.

    repair_animation

    fn repair_animation(animation : Animation) -> Animation

    Produce a normalized animation suitable for a best-effort export.

    report_animation

    fn report_animation(animation : Animation, options : OptimizationOptions) -> GifDocumentReport raise GifError

    Analyze source animation quality and predicted export cost.

    report_delta

    fn report_delta(before : GifDocumentReport, after : GifDocumentReport) -> (Int, Int, Int)

    Compare two reports and return byte, pixel, and quality deltas.

    report_gif

    fn report_gif(data : Bytes) -> GifDocumentReport raise GifError

    Analyze an encoded GIF without altering the input buffer.

    rgb

    fn rgb(r : Byte, g : Byte, b : Byte) -> Rgba

    Construct an opaque RGB color.

    rgb_from_packed

    fn rgb_from_packed(value : Int) -> Rgba

    Convert a packed RGB value into an opaque color.

    rgba

    fn rgba(r : Byte, g : Byte, b : Byte, a : Byte) -> Rgba

    Construct an RGBA color.

    rgba_from_hsl

    fn rgba_from_hsl(hue : Int, saturation : Byte, lightness : Byte, alpha : Byte) -> Rgba

    Construct an RGBA value from HSL components.

    rgba_from_hsv

    fn rgba_from_hsv(hue : Int, saturation : Byte, value : Byte, alpha : Byte) -> Rgba

    Construct an RGBA value from HSV components.

    rgba_from_yuv

    fn rgba_from_yuv(color : YuvColor) -> Rgba

    run_benchmark

    fn run_benchmark(workload : BenchmarkWorkload) -> BenchmarkResult raise GifError

    Run the complete encode/decode benchmark and collect correctness metrics.

    run_benchmark_request

    fn run_benchmark_request(request : GifCliRequest) -> GifCliResult raise GifError

    Run a deterministic benchmark request without filesystem access.

    run_cli_request

    fn run_cli_request(request : GifCliRequest, data : Bytes) -> GifCliResult

    Execute an inspect/decode request on an in-memory GIF.

    run_encode_request

    fn run_encode_request(request : GifCliRequest, animation : Animation) -> GifCliResult

    Execute an encode request on an animation and attach a structural report.

    sample_playback

    fn sample_playback(state : PlaybackState, samples : Int) -> Array[Int]

    Build a list of visible frame indices at regular playback intervals.

    single_frame_animation

    fn single_frame_animation(canvas : Canvas, delay_cs : Int) -> Animation

    Return a one-frame animation for a canvas with validated timing.

    small_file_workflow

    fn small_file_workflow() -> GifWorkflow

    Return a plan that favours compact transfer size while retaining motion.

    spatial_similarity

    fn spatial_similarity(left : Canvas, right : Canvas) -> Int

    Compare two images by structural statistics before running a full diff.

    split_indices

    fn split_indices(indices : ArrayView[Byte], chunk_size : Int) -> Array[Array[Byte]]

    Split indices into bounded slices for streaming quantization work.

    star_points

    fn star_points(center_x : Int, center_y : Int, outer_radius : Int, inner_radius : Int, points : Int) -> Array[(Int, Int)]

    Create the vertices of a star-like polygon without floating point math.

    sticker_workflow

    fn sticker_workflow() -> GifWorkflow

    Return a sticker-oriented plan with conservative timing defaults.

    transform_batch

    fn transform_batch(items : ArrayView[BatchItem], pipeline : CanvasPipeline) -> Array[BatchItem]

    Apply a pipeline to all batch items while preserving their names.

    transition_frames

    fn transition_frames(left : Frame, right : Frame, options? : TransitionOptions) -> Array[Frame]

    Insert a transition between two canvases, excluding duplicated endpoints.

    unpack_sub_blocks

    fn unpack_sub_blocks(data : Bytes) -> Bytes raise GifError

    Unpack a complete GIF sub-block sequence.

    validate_and_repair

    fn validate_and_repair(animation : Animation) -> (GifValidationReport, Animation, GifValidationReport)

    Validate, repair, and return both versions for an import pipeline.

    validate_animation

    fn validate_animation(animation : Animation) -> GifValidationReport

    Validate an in-memory animation before it reaches the encoder.

    validate_chunks

    fn validate_chunks(chunks : ArrayView[GifChunk]) -> Bool

    Validate monotonic, gap-free chunks before writing them to a sink.

    validate_cli_request

    fn validate_cli_request(request : GifCliRequest) -> Array[String]

    Validate request values before opening an input resource.

    validate_gif_bytes

    fn validate_gif_bytes(data : Bytes) -> GifValidationReport

    Validate encoded bytes and preserve a concise diagnostic report on failure.

    validate_limits

    fn validate_limits(animation : Animation, limits : GifLimits) -> Array[String]

    Count violations against canonical GIF limits.