Figler.Render.PixelDiff (figler v0.1.0-beta.1)

Copy Markdown View Source

Thresholded RGBA comparison for rendering-oracle tests.

Inputs are decoded, tightly packed RGBA buffers such as the maps returned by Skia.to_raw/1. Metrics remain backend-neutral so OpenPencil reference renders can be decoded by any test adapter.

Summary

Functions

Compares two decoded RGBA buffers using configurable error thresholds.

Types

metrics()

@type metrics() :: %{
  width: pos_integer(),
  height: pos_integer(),
  changed_pixels: non_neg_integer(),
  changed_ratio: float(),
  mean_channel_delta: float(),
  max_channel_delta: 0..255,
  passed?: boolean()
}

raw_image()

@type raw_image() :: %{width: pos_integer(), height: pos_integer(), data: binary()}

Functions

compare(expected, actual, opts \\ [])

@spec compare(raw_image(), raw_image(), keyword()) ::
  {:ok, metrics()} | {:error, term()}

Compares two decoded RGBA buffers using configurable error thresholds.