Skip to content

Commit aa6b25b

Browse files
Remove dependencies on AppKit/UIKit
rdar://118261740
1 parent 7b5f149 commit aa6b25b

File tree

2 files changed

+0
-74
lines changed

2 files changed

+0
-74
lines changed

Sources/SwiftDocC/Infrastructure/Communication/Code colors/SRGBColor.swift

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@
1010

1111
import Foundation
1212

13-
#if canImport(UIKit)
14-
import UIKit
15-
#elseif canImport(AppKit)
16-
import AppKit
17-
#endif
18-
1913
/// A color in the sRGB color space, with normalized components.
2014
public struct SRGBColor: Codable, Equatable {
2115
/// The normalized red component of the color.
@@ -39,34 +33,4 @@ public struct SRGBColor: Codable, Equatable {
3933
self.blue = blue
4034
self.alpha = alpha
4135
}
42-
43-
#if canImport(UIKit)
44-
45-
/// Creates a new instance from the given `UIColor`.
46-
public init?(from uiColor: UIColor) {
47-
guard let components = uiColor.cgColor.components, components.count >= 4 else { return nil }
48-
49-
self.red = UInt8(Double(components[0]) * 255.0)
50-
self.green = UInt8(Double(components[1]) * 255.0)
51-
self.blue = UInt8(Double(components[2]) * 255.0)
52-
self.alpha = Double(components[3])
53-
}
54-
55-
#elseif canImport(AppKit)
56-
57-
/// Creates a new instance from the given `NSColor`.
58-
public init?(from nsColor: NSColor) {
59-
// The normalization factor this initializer uses to convert between NSColor and sRGB
60-
// color spaces as described by
61-
// <https://developer.apple.com/library/content/qa/qa1576/_index.html>.
62-
let normalizationFactor = 255.99999
63-
64-
guard let color = nsColor.usingColorSpace(.sRGB) else { return nil }
65-
66-
self.red = UInt8(Double(color.redComponent) * normalizationFactor)
67-
self.green = UInt8(Double(color.greenComponent) * normalizationFactor)
68-
self.blue = UInt8(Double(color.blueComponent) * normalizationFactor)
69-
self.alpha = Double(color.alphaComponent)
70-
}
71-
#endif
7236
}

Tests/SwiftDocCTests/Infrastructure/Communication/SRGBColorTests.swift

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)