distance method

  1. @override
  2. @nonVirtual
double distance(
  1. int a,
  2. int b
)
inherited

Returns the distance between two pixels in the pixel format.

What constitutes distance is not defined by this method, and is up to the pixel format to define. For example, both abgr8888 and floatRgba use cartesian distance to compare pixels.

Implementation

@override
@nonVirtual
double distance(int a, int b) {
  final dr = getRed(a) - getRed(b);
  final dg = getGreen(a) - getGreen(b);
  final db = getBlue(a) - getBlue(b);
  final da = getAlpha(a) - getAlpha(b);
  return (dr * dr + dg * dg + db * db + da * da).toDouble();
}