 
   color1.mixWith$(color2)
 
-  equals color1.r, 30
-  equals color1.g, (45 / 2).round()
-  equals color1.b, (76 / 2).round()
-  equals color1.a, 0.5 / 2
+  equalEnough color1.r, 30
+  equalEnough color1.g, (45 / 2).round()
+  equalEnough color1.b, (76 / 2).round()
+  equalEnough color1.a, 0.5 / 2
 
   color3.mixWith$(color2, 0.1)
 
-  equals color3.r, ((50 * 0.1) + (10 * 0.9)).round()
-  equals color3.g, ((40 * 0.1) + (5 * 0.9)).round()
-  equals color3.b, ((60 * 0.1) + (16 * 0.9)).round()
-  equals color3.a, (0.3 * 0.1) + (0.2 * 0.9) 
+  equalEnough color3.r, ((50 * 0.1) + (10 * 0.9)).round()
+  equalEnough color3.g, ((40 * 0.1) + (5 * 0.9)).round()
+  equalEnough color3.b, ((60 * 0.1) + (16 * 0.9)).round()
+  equalEnough color3.a, (0.3 * 0.1) + (0.2 * 0.9) 
 
 test "Color.random", ->
   color = Color2.random()


  hsl = color.toHsl()

  equal hsl[0].round(), 22
  equal hsl[1].toFixed(2), 0.38
  equal hsl[2].toFixed(2), 0.13
  equal hsl[3], 1.0

test "#hue", ->
  color = Color2(34, 54, 239)

  color2 = color.hue(60)

  equal color2.r, 218
  equal color2.g, 37
  equal color2.b, 239
  equal color2.a, 1.0

test "#hue$", ->
  color = Color2(34, 54, 239)

  color.hue$(60)

  equal color.r, 218
  equal color.g, 37
  equal color.b, 239
  equal color.a, 1.0

test "#complement", ->
  color = Color2(10, 30, 50)

  color2 = color.complement()

  equal color2.r, 51
  equal color2.g, 31
  equal color2.b, 10
  equal color2.a, 1.0

test "#complement$", ->
  color = Color2(10, 30, 50)

  color.complement$()

  equal color.r, 51
  equal color.g, 31
  equal color.b, 10
  equal color.a, 1.0

test "#grayscale", ->
  color = Color2(30, 40, 29)

  color2 = color.grayscale()

  equal color2.r, 35
  equal color2.g, 35
  equal color2.b, 35
  equal color2.a, 1.0

test "#grayscale$", ->
  color = Color2(30, 40, 29)

  color.grayscale$()

  equal color.r, 35
  equal color.g, 35
  equal color.b, 35
  equal color.a, 1.0

test "#saturate", ->
  color = Color2(100, 200, 150)

  color2 = color.saturate(0.3)

  equal color2.r, 69
  equal color2.g, 232
  equal color2.b, 150
  equal color2.a, 1.0

test "#saturate$", ->
  color = Color2(100, 200, 150)

  color.saturate$(0.3)

  equal color.r, 69
  equal color.g, 232
  equal color.b, 150
  equal color.a, 1.0

test "#desaturate", ->
  color = Color2(69, 232, 150)

  color2 = color.desaturate(0.3)

  equal color2.r, 100
  equal color2.g, 200
  equal color2.b, 150
  equal color2.a, 1.0

test "#desaturate$", ->
  color = Color2(69, 232, 150)

  color.desaturate$(0.3)

  equal color.r, 100
  equal color.g, 200
  equal color.b, 150
  equal color.a, 1.0

test "#darken", ->
  color = Color2(45, 64, 39)

  color2 = color.darken(0.1)

  equal color2.r, 22
  equal color2.g, 32
  equal color2.b, 19
  equal color2.a, 1.0

test "#darken$", ->
  color = Color2(45, 64, 39)

  color.darken$(0.1)

  equal color.r, 22
  equal color.g, 32
  equal color.b, 19
  equal color.a, 1.0

test "#lighten", ->
  color = Color2(22, 32, 19)

  color2 = color.lighten(0.1)

  equal color2.r, 45
  equal color2.g, 64
  equal color2.b, 39
  equal color2.a, 1.0

test "#lighten$", ->
  color = Color2(22, 32, 19)

  color.lighten$(0.1)

  equal color.r, 45
  equal color.g, 64
  equal color.b, 39
  equal color.a, 1.0

test "#mixWith", ->
  color1 = Color2(50, 40, 60, 0.3)


  mixedColor = Color2.mix(color1, color2)

  equalEnough mixedColor.r, 30
  equalEnough mixedColor.g, (45 / 2).round()
  equalEnough mixedColor.b, (76 / 2).round()
  equalEnough mixedColor.a, 0.5 / 2

  weightedMixedColor = Color2.mix(color1, color2, 0.1)

  equalEnough weightedMixedColor.r, ((50 * 0.1) + (10 * 0.9)).round()
  equalEnough weightedMixedColor.g, ((40 * 0.1) + (5 * 0.9)).round()
  equalEnough weightedMixedColor.b, ((60 * 0.1) + (16 * 0.9)).round()
  equalEnough weightedMixedColor.a, (0.3 * 0.1) + (0.2 * 0.9)  

test "accepts named colors", ->
  white = Color2("white")

  equalEnough white.r, 255
  equalEnough white.g, 255
  equalEnough white.b, 255
  equalEnough white.a, 1.0

  piPink = Color2("Paul Irish Pink")

  equalEnough piPink.r, 255
  equalEnough piPink.g, 94
  equalEnough piPink.b, 153
  equalEnough piPink.a, 1.0

module()

)()