Fix `final func toRGBAComponents()` on macOS for non-RGB colors

This commit is contained in:
Vincent Esche 2020-01-13 17:13:46 +01:00
parent 1e85f9461f
commit 04f7891d8c
1 changed files with 3 additions and 6 deletions

View File

@ -62,14 +62,11 @@ public extension DynamicColor {
return (r, g, b, a)
#elseif os(OSX)
if isEqual(DynamicColor.black) {
return (0, 0, 0, 0)
}
else if isEqual(DynamicColor.white) {
return (1, 1, 1, 1)
guard let rgbaColor = self.usingColorSpace(.deviceRGB) else {
fatalError("Could not convert color to RGBA.")
}
getRed(&r, green: &g, blue: &b, alpha: &a)
rgbaColor.getRed(&r, green: &g, blue: &b, alpha: &a)
return (r, g, b, a)
#endif