<!--
{
  "availability" : [
    "macOS: 10.12.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSColor/init(colorSpace:hue:saturation:brightness:alpha:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSColor(cm)colorWithColorSpace:hue:saturation:brightness:alpha:"
  },
  "title" : "init(colorSpace:hue:saturation:brightness:alpha:)"
}
-->

# init(colorSpace:hue:saturation:brightness:alpha:)

Creates a color object with the specified color space, hue, saturation, brightness, and alpha channel values.

```
init(colorSpace space: NSColorSpace, hue: CGFloat, saturation: CGFloat, brightness: CGFloat, alpha: CGFloat)
```

## Parameters

`space`

An `NSColorSpace` object representing a color space. An exception is raised if the color model of the provided color space is not RGB.

`hue`

The hue (color) component, expressed as a floating-point value in the range 0–1.0.

`saturation`

The color saturation component, expressed as a floating-point value in the range 0–1.0.

`brightness`

The brightness component, expressed as a floating-point value in the range 0–1.0.

`alpha`

The alpha (opacity), expressed as a floating-point value in the range 0 (transparent) to 1.0 (opaque).

## Return Value

The color object.

## Discussion

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)