Reputation: 32073
The Color
initializer init(hue:saturation:brightness:opacity:)
is undocumented.
I think I can safely assume that saturation
, brightness
, and opacity
normalize to the range of 0...1
, where values outside that range are valid only for wide-gamut displays.
But I can't make this guess for hue
. Is is 0...1
, 0...τ
, or 0...360
?
Upvotes: 0
Views: 664
Reputation: 32073
Happily, it's easy to test this quickly.
I tossed this code into a new SwiftUI app and just looked at the preview to see the results. Turns out, it's 0...1
!
import SwiftUI
struct ContentView: View {
var body: some View {
VStack(spacing: 0) {
Color(hue: 0/6, saturation: 1, brightness: 1)
Color(hue: 1/6, saturation: 1, brightness: 1)
Color(hue: 2/6, saturation: 1, brightness: 1)
Color(hue: 3/6, saturation: 1, brightness: 1)
Color(hue: 4/6, saturation: 1, brightness: 1)
Color(hue: 5/6, saturation: 1, brightness: 1)
Color(hue: 6/6, saturation: 1, brightness: 1)
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Upvotes: 2