distanceFrom method

int distanceFrom(
  1. Color other
)

Calculates the square of the Euclidean distance from another color.

The distance is calculated using the rgb channels and ignores the alpha channel.

Implementation

int distanceFrom(Color other) {
  return math.pow(other.red - red, 2) +
      math.pow(other.blue - blue, 2) +
      math.pow(other.green - green, 2) as int;
}