Skip to content

Commit 5c014dd

Browse files
committed
Add CGBlendModeUtil
1 parent f917bde commit 5c014dd

File tree

4 files changed

+40
-33
lines changed

4 files changed

+40
-33
lines changed

Sources/OpenSwiftUICore/Render/CoreAnimation/CAFrameRateRangeUtil.swift renamed to Sources/OpenSwiftUICore/Render/Util/CAFrameRateRangeUtil.swift

File renamed without changes.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//
2+
// CGBlendModeUtil.swift
3+
// OpenSwiftUICore
4+
//
5+
// Audited for 6.5.4
6+
// Status: Complete
7+
8+
#if canImport(CoreGraphics)
9+
package import CoreGraphics
10+
11+
extension BlendMode {
12+
package init(_ blendMode: CGBlendMode) {
13+
self = switch blendMode {
14+
case .normal: .normal
15+
case .multiply: .multiply
16+
case .screen: .screen
17+
case .overlay: .overlay
18+
case .darken: .darken
19+
case .lighten: .lighten
20+
case .colorDodge: .colorDodge
21+
case .colorBurn: .colorBurn
22+
case .softLight: .softLight
23+
case .hardLight: .hardLight
24+
case .difference: .difference
25+
case .exclusion: .exclusion
26+
case .hue: .hue
27+
case .saturation: .saturation
28+
case .color: .color
29+
case .luminosity: .luminosity
30+
case .sourceAtop: .sourceAtop
31+
case .destinationOver: .destinationOver
32+
case .destinationOut: .destinationOut
33+
case .plusDarker: .plusDarker
34+
case .plusLighter: .plusLighter
35+
default: .normal
36+
}
37+
}
38+
}
39+
#endif

Sources/OpenSwiftUICore/Shape/ShapeStyle/BlendMode.swift

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// MARK: - BlendMode
99

1010
/// Modes for compositing a view with overlapping content.
11+
@available(OpenSwiftUI_v1_0, *)
1112
public enum BlendMode: Sendable {
1213
case normal
1314
case multiply
@@ -32,39 +33,6 @@ public enum BlendMode: Sendable {
3233
case plusLighter
3334
}
3435

35-
#if canImport(CoreGraphics)
36-
package import CoreGraphics
37-
38-
extension BlendMode {
39-
package init(_ blendMode: CGBlendMode) {
40-
self = switch blendMode {
41-
case .normal: .normal
42-
case .multiply: .multiply
43-
case .screen: .screen
44-
case .overlay: .overlay
45-
case .darken: .darken
46-
case .lighten: .lighten
47-
case .colorDodge: .colorDodge
48-
case .colorBurn: .colorBurn
49-
case .softLight: .softLight
50-
case .hardLight: .hardLight
51-
case .difference: .difference
52-
case .exclusion: .exclusion
53-
case .hue: .hue
54-
case .saturation: .saturation
55-
case .color: .color
56-
case .luminosity: .luminosity
57-
case .sourceAtop: .sourceAtop
58-
case .destinationOver: .destinationOver
59-
case .destinationOut: .destinationOut
60-
case .plusDarker: .plusDarker
61-
case .plusLighter: .plusLighter
62-
default: .normal
63-
}
64-
}
65-
}
66-
#endif
67-
6836
extension ShapeStyle {
6937
/// Returns a new style based on `self` that applies the specified
7038
/// blend mode when drawing.

Tests/OpenSwiftUICoreTests/Render/CoreAnimation/CAFrameRateRangeUtilTests.swift renamed to Tests/OpenSwiftUICoreTests/Render/Util/CAFrameRateRangeUtilTests.swift

File renamed without changes.

0 commit comments

Comments
 (0)