Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[ios, macos] Fixed color conversion on Sierra
Browse files Browse the repository at this point in the history
  • Loading branch information
1ec5 committed Mar 30, 2018
1 parent 087cf7a commit 99d02d4
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions platform/macos/src/NSColor+MGLAdditions.mm
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,18 @@ + (NSColor *)mgl_colorWithComponentExpressions:(NSArray<NSExpression *> *)compon
// Alpha
components.back() *= 255.0;

// The Mapbox Style Specification does not specify a color space, but it is
// assumed to be sRGB for consistency with CSS.
NSColor *color = [NSColor colorWithColorSpace:[NSColorSpace sRGBColorSpace]
components:&components[0]
count:components.size()];
// macOS 10.12 Sierra and below uses calibrated RGB by default.
if ([NSColor redColor].colorSpaceName == NSCalibratedRGBColorSpace) {
color = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
return [NSColor colorWithCalibratedRed:components[0]
green:components[1]
blue:components[2]
alpha:components[3]];
}
return color;
// The Mapbox Style Specification does not specify a color space, but it is
// assumed to be sRGB for consistency with CSS.
return [NSColor colorWithColorSpace:[NSColorSpace sRGBColorSpace]
components:&components[0]
count:components.size()];
}

@end

0 comments on commit 99d02d4

Please sign in to comment.