Add hex init to Color, cleanup assertionFailure (#69)
* Add hex init to Color, cleanup assertionFailure * Add doc comment
This commit is contained in:
parent
7d6107740a
commit
156b775c4e
|
@ -35,3 +35,14 @@ public struct Color: Equatable {
|
|||
public static var green = Color(red: 0.0, green: 1.0, blue: 0.0, alpha: 1.0)
|
||||
public static var blue = Color(red: 0.0, green: 0.0, blue: 1.0, alpha: 1.0)
|
||||
}
|
||||
|
||||
extension Color: ExpressibleByIntegerLiteral {
|
||||
/// Allows initializing value of `Color` type from hex values
|
||||
public init(integerLiteral bitMask: UInt32) {
|
||||
red = Double((bitMask & 0xFF0000) >> 16) / 255
|
||||
green = Double((bitMask & 0x00FF00) >> 8) / 255
|
||||
blue = Double(bitMask & 0x0000FF) / 255
|
||||
alpha = 1
|
||||
space = .sRGB
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ public final class Hooks {
|
|||
defer { refIndex += 1 }
|
||||
|
||||
guard let component = component else {
|
||||
assertionFailure("hooks.state should only be called within `render`")
|
||||
assertionFailure("hooks.ref should only be called within `render`")
|
||||
return initial
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue