Fixed: CPColor colorWithCSSString did not properly handle the alpha component of the CSS rbga() syntax. Fixes #687.

This commit is contained in:
Alexander Ljungberg
2011-04-10 22:16:28 -04:00
parent e44ffdc7f4
commit ff7f469f9f
2 changed files with 11 additions and 1 deletions
+1 -1
View File
@@ -416,7 +416,7 @@ var cachedBlackColor,
parseInt(parts[0], 10) / 255.0,
parseInt(parts[1], 10) / 255.0,
parseInt(parts[2], 10) / 255.0,
parts[3] ? parseInt(parts[3], 10) / 255.0 : 1.0
parts[3] ? parseFloat(parts[3], 10) : 1.0
];
_cssString = aString;
+10
View File
@@ -11,4 +11,14 @@
[self assert: colors[i] equals: [[CPColor colorWithHexString: colors[i]] hexString]];
}
- (void)testColorWithCSSString
{
var rgbaColour = [CPColor colorWithCSSString:@"rgba(32, 64, 128, 0.5)"];
[self assert:32 equals:Math.round([rgbaColour redComponent] * 255) message:"red component"];
[self assert:64 equals:Math.round([rgbaColour greenComponent] * 255) message:"green component"];
[self assert:128 equals:Math.round([rgbaColour blueComponent] * 255) message:"blue component"];
[self assert:128 equals:Math.round([rgbaColour alphaComponent] * 255) message:"alpha component"];
}
@end