init(hue:saturation:brightness:opacity:)
Creates a constant color from hue, saturation, and brightness values.
Declaration
init(hue: Double, saturation: Double, brightness: Double, opacity: Double = 1)Parameters
- hue:
A value in the range
0to1that maps to an angle from 0° to 360° to represent a shade on the color wheel. - saturation:
A value in the range
0to1that indicates how strongly the hue affects the color. A value of0removes the effect of the hue, resulting in gray. As the value increases, the hue becomes more prominent. - brightness:
A value in the range
0to1that indicates how bright a color is. A value of0results in black, regardless of the other components. The color lightens as you increase this component. - opacity:
An optional degree of opacity, given in the range
0to1. A value of0means 100% transparency, while a value of1means 100% opacity. The default is1.
Discussion
This initializer creates a constant color that doesn’t change based on context. For example, it doesn’t have distinct light and dark appearances, unlike various system-defined colors, or a color that you load from an Asset Catalog with init(_:bundle:).