Skip to content

Commit f0107f9

Browse files
authored
Impl Color.opacity(_:) and Color.clear from SwiftUI (#95)
1 parent 9cd4256 commit f0107f9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Sources/SwiftCrossUI/Color.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,22 @@ public struct Color {
2222
self.alpha = alpha
2323
}
2424

25+
/// Multiplies the opacity of the color by the given amount.
26+
public consuming func opacity(
27+
_ opacity: Float
28+
) -> Color {
29+
self.alpha *= opacity
30+
return self
31+
}
32+
2533
/// Pure black.
2634
public static let black = Color(0.00, 0.00, 0.00)
2735
/// Pure blue.
2836
public static let blue = Color(0.00, 0.48, 1.00)
2937
/// Pure brown.
3038
public static let brown = Color(0.64, 0.52, 0.37)
39+
/// Completely clear.
40+
public static let clear = Color(0.50, 0.50, 0.50, 0.00)
3141
/// Pure cyan.
3242
public static let cyan = Color(0.33, 0.75, 0.94)
3343
/// Pure gray.

0 commit comments

Comments
 (0)