Skip to content

Commit 1129537

Browse files
authored
Add ColorRenderingMode implementation (#138)
1 parent 667fdbc commit 1129537

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
//
2+
// ColorRenderingMode.swift
3+
// OpenSwiftUICore
4+
//
5+
// Audited for RELEASE_2024
6+
// Status: Complete
7+
8+
/// The set of possible working color spaces for color-compositing operations.
9+
///
10+
/// Each color space guarantees the preservation of a particular range of color
11+
/// values.
12+
public enum ColorRenderingMode: Sendable {
13+
/// The non-linear sRGB working color space.
14+
///
15+
/// Color component values outside the range `[0, 1]` produce undefined
16+
/// results. This color space is gamma corrected.
17+
case nonLinear
18+
19+
/// The linear sRGB working color space.
20+
///
21+
/// Color component values outside the range `[0, 1]` produce undefined
22+
/// results. This color space isn't gamma corrected.
23+
case linear
24+
25+
/// The extended linear sRGB working color space.
26+
///
27+
/// Color component values outside the range `[0, 1]` are preserved.
28+
/// This color space isn't gamma corrected.
29+
case extendedLinear
30+
}
31+
32+
extension ColorRenderingMode: Equatable {}
33+
extension ColorRenderingMode: Hashable {}
34+
35+
extension ColorRenderingMode: ProtobufEnum {
36+
package var protobufValue: UInt {
37+
switch self {
38+
case .nonLinear:
39+
return 0
40+
case .linear:
41+
return 1
42+
case .extendedLinear:
43+
return 2
44+
}
45+
}
46+
package init?(protobufValue value: UInt) {
47+
switch value {
48+
case 0:
49+
self = .nonLinear
50+
case 1:
51+
self = .linear
52+
case 2:
53+
self = .extendedLinear
54+
default:
55+
return nil
56+
}
57+
}
58+
}

0 commit comments

Comments
 (0)