Skip to content

Commit

Permalink
Improve color equality
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Treub committed Jun 28, 2017
1 parent bfaf154 commit 714bc24
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions framer/Color.coffee
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -303,10 +303,12 @@ class exports.Color extends BaseClass
colorA = new Color(colorA) colorA = new Color(colorA)
colorB = new Color(colorB) colorB = new Color(colorB)


return false if Math.round(colorA.r) isnt Math.round(colorB.r) tolerance = 1
return false if Math.round(colorA.g) isnt Math.round(colorB.g) alphaTolerance = 0.01
return false if Math.round(colorA.b) isnt Math.round(colorB.b) return false if Math.abs(colorA.r - colorB.r) >= tolerance
return false if Math.round(colorA.a) isnt Math.round(colorB.a) return false if Math.abs(colorA.g - colorB.g) >= tolerance
return false if Math.abs(colorA.b - colorB.b) >= tolerance
return false if Math.abs(colorA.a - colorB.a) >= alphaTolerance
return true return true


@rgbToHsl: (a, b, c) -> @rgbToHsl: (a, b, c) ->
Expand Down

0 comments on commit 714bc24

Please sign in to comment.