Permalink
Browse files

Adjusted colour conversions to account for 255 rgb values and 360 hue…

…. Adjusted tests.
  • Loading branch information...
debreuil committed Jun 25, 2014
1 parent e90788c commit 648fc8601a30717eadac1c018eb4be5cc12b0458
@@ -19,7 +19,7 @@ - (id)initWithColor:(UIColor *)color
[color getHue:&hue saturation:&saturation brightness:&brightness alpha:&alpha];
return [self initWithHue:hue saturation:saturation brightness:brightness alpha:alpha];
return [self initWithHue:hue * 360.0 saturation:saturation brightness:brightness alpha:alpha];
}
- (id)initWithHue:(double)hue saturation:(double)saturation brightness:(double)brightness
@@ -56,7 +56,7 @@ - (NSString *)stringValue
- (UIColor *)colorValue
{
return [UIColor colorWithHue:_hue saturation:_saturation brightness:_brightness alpha:_alpha];
return [UIColor colorWithHue:_hue / 360.0 saturation:_saturation brightness:_brightness alpha:_alpha];
}
- (PXHSBColorValue *)hsbColorValue
@@ -19,7 +19,7 @@ - (id)initWithColor:(UIColor *)color
[color getHue:&hue saturation:&saturation brightness:&lightness alpha:&alpha];
return [self initWithHue:hue saturation:saturation lightness:lightness alpha:alpha];
return [self initWithHue:hue * 360.0 saturation:saturation lightness:lightness alpha:alpha];
}
- (id)initWithHue:(double)hue saturation:(double)saturation lightness:(double)lightness
@@ -56,7 +56,7 @@ - (NSString *)stringValue
- (UIColor *)colorValue
{
return [UIColor colorWithHue:_hue saturation:_saturation lightness:_lightness alpha:_alpha];
return [UIColor colorWithHue:_hue / 360.0 saturation:_saturation lightness:_lightness alpha:_alpha];
}
- (PXHSLColorValue *)hslColorValue
@@ -18,7 +18,7 @@ - (id)initWithColor:(UIColor *)color
[color getRed:&red green:&green blue:&blue alpha:&alpha];
return [self initWithRed:red green:green blue:blue alpha:alpha];
return [self initWithRed:red * 255.0 green:green * 255.0 blue:blue * 255.0 alpha:alpha];
}
- (id)initWithRed:(double)red green:(double)green blue:(double)blue
@@ -67,7 +67,7 @@ - (PXRGBColorValue *)rgbColorValue
- (NSString *)description
{
return [NSString stringWithFormat:@"rgba(%g,%g,%g,%g)", _red, _green, _blue, _alpha];
return [NSString stringWithFormat:@"rgba(%d,%d,%d,%g)", (int)_red, (int)_green, (int)_blue, _alpha];
}
@end
@@ -46,7 +46,7 @@ - (void)testColorGetterAutoWrapped
id<PXExpressionValue> result = [wrapper valueForPropertyName:@"color"];
XCTAssertTrue([@"rgba(1,0,0,0)" isEqualToString:result.description], @"Colors do not match");
XCTAssertTrue([@"rgba(255,0,0,1)" isEqualToString:result.description], @"Colors do not match");
}
- (void)testColorSetterAutoWrapped
@@ -59,7 +59,7 @@ - (void)testColorSetterAutoWrapped
[wrapper setValue:color forPropertyName:@"color"];
id<PXExpressionValue> result = [wrapper valueForPropertyName:@"color"];
XCTAssertTrue([@"rgba(0.75,0.375,0.375,0)" isEqualToString:result.description], @"Colors do not match");
XCTAssertTrue([@"rgba(95,191,191,1)" isEqualToString:result.description], @"Colors do not match");
}
- (void)testColorValueGetterAutoWrapped

0 comments on commit 648fc86

Please sign in to comment.