 	a = 1
 	ok = false
 
-	if typeof color == 'string'
-		color = stringToObject(color)
-
-	if typeof color == 'object'
-
-		if color.hasOwnProperty('red') or color.hasOwnProperty('green') or color.hasOwnProperty('blue')
-			rgb = rgbToRgb(color.red, color.green, color.blue)
-			ok = true
-
-		else if color.hasOwnProperty('r') or color.hasOwnProperty('g') or color.hasOwnProperty('b')
-			rgb = rgbToRgb(color.r, color.g, color.b)
-			ok = true
-
-		else if color.hasOwnProperty('h') or color.hasOwnProperty('s')
-
-			h = if isNumeric(color.h) then color.h else 0
-			s = if isNumeric(color.s) then convertToPercentage(color.s) else 1
-
-			if color.hasOwnProperty('v')
-				v = if isNumeric(color.v) then convertToPercentage(color.v) else 0
-				rgb = hsvToRgb(h, s, v)
-			else
-				l = if isNumeric(color.l) then convertToPercentage(color.l) else 50
-				rgb = hslToRgb(h, s, l)
-
-			ok = true
-
-		if color.hasOwnProperty('a')
-			a = color.a
-		else if color.hasOwnProperty('alpha')
-			a = color.alpha
+	if color == null
+		a = 0
+	else
+
+		if typeof color == 'string'
+			color = stringToObject(color)
+
+		if typeof color == 'object'
+
+			if color.hasOwnProperty('r') or color.hasOwnProperty('g') or color.hasOwnProperty('b')
+				rgb = rgbToRgb(color.r, color.g, color.b)
+				ok = true
+
+			else if color.hasOwnProperty('h') or color.hasOwnProperty('s')
+
+				h = if isNumeric(color.h) then color.h else 0
+				s = if isNumeric(color.s) then convertToPercentage(color.s) else 1
+
+				if color.hasOwnProperty('v')
+					v = if isNumeric(color.v) then convertToPercentage(color.v) else 0
+					rgb = hsvToRgb(h, s, v)
+				else
+					l = if isNumeric(color.l) then convertToPercentage(color.l) else 50
+					rgb = hslToRgb(h, s, l)
+
+				ok = true
+
+			if color.hasOwnProperty('a')
+				a = color.a
+			else if color.hasOwnProperty('alpha')
+				a = color.alpha
 
 	a = correctAlpha(a)
 


		if fromColor not instanceof Color and toColor instanceof Color
			fromColor = toColor.copy()
			fromColor.a = 0
		else if fromColor instanceof Color and fromColor._a == 0 and toColor instanceof Color and toColor._a != 0
			fromColor = toColor.copy()
			fromColor.a = 0
		else if toColor not instanceof Color and fromColor instanceof Color
			toColor = fromColor.copy()
			toColor.a = 0
		else if toColor instanceof Color and toColor._a == 0 and fromColor instanceof Color and fromColor._a != 0
			toColor = fromColor.copy()
			toColor.a = 0

		if toColor instanceof Color


		# If input already is a Color object return input
		if (color instanceof Color) then return color

		# Convert input to RGB
		rgb = inputToRGB(color)

		@_r = rgb.r
		@_g = rgb.g
		@_b = rgb.b
		@_a = rgb.a
		@_roundA = Math.round(100*@_a) / 100

	@define "r",
		get: -> @_r
		set: (value) -> throw "r is readonly"

	@define "g",
		get: -> @_g
		set: (value) -> throw "g is readonly"

	@define "b",
		get: -> @_b
		set: (value) -> throw "b is readonly"

	@define "a",
		get: -> @_a
		set: (value) -> throw "a is readonly"

	toHex: (allow3Char) ->
		return rgbToHex(@_r, @_g, @_b, allow3Char)
