Skip to content

Instantly share code, notes, and snippets.

@ateliercw
Created February 26, 2016 15:41
Show Gist options
  • Save ateliercw/b7265bed9cfd118b6597 to your computer and use it in GitHub Desktop.
Save ateliercw/b7265bed9cfd118b6597 to your computer and use it in GitHub Desktop.
func differenceFrom(otherRGBA: UIImage.RGBA) -> Int {
let aDiff = Int(max(alpha, otherRGBA.alpha) - min(alpha, otherRGBA.alpha))
let rDiff = Int(max(red, otherRGBA.red) - min(red, otherRGBA.red))
let gDiff = Int(max(green, otherRGBA.green) - min(green, otherRGBA.green))
let bDiff = Int(max(blue, otherRGBA.green) - min(blue, otherRGBA.blue))
return aDiff + rDiff + gDiff + bDiff
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment