getBlend<S, T> method

  1. @override
T Function(S src, T dst) getBlend<S, T>(
  1. PixelFormat<S, void> srcFormat,
  2. PixelFormat<T, void> dstFormat
)
override

Returns a function that blends two pixels together.

Implementation

@override
T Function(S src, T dst) getBlend<S, T>(
  PixelFormat<S, void> srcFormat,
  PixelFormat<T, void> dstFormat,
) {
  // Intentionally ignore the type check, we're performing it implicitly.
  // ignore: unrelated_type_equality_checks
  if (srcFormat == floatRgba && dstFormat == floatRgba) {
    return _blendFloatRgba as T Function(S src, T dst);
  }
  return (src, dst) {
    final srcRgba = srcFormat.toFloatRgba(src);
    final dstRgba = dstFormat.toFloatRgba(dst);
    final result = _blendFloatRgba(srcRgba, dstRgba);
    return dstFormat.fromFloatRgba(result);
  };
}