mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-14 06:31:27 +00:00
Fixed: CPColor colorWithCSSString did not properly handle the alpha component of the CSS rbga() syntax. Fixes #687.
This commit is contained in:
+1
-1
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user