<!--
{
  "documentType" : "article",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/color-creation",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Color creation"
}
-->

# Color creation

Load colors from asset catalogs, and create colors from raw component values, such as those used by grayscale, RGB, HSB, and CMYK colors.

## Topics

### Loading color objects from asset catalogs

[`init(named:)`](/documentation/AppKit/NSColor/init(named:))

Creates a color object from the provided name, which corresponds to a color in the default asset catalog of the app’s main bundle.

[`init(named:bundle:)`](/documentation/AppKit/NSColor/init(named:bundle:))

Creates a color object from the provided name, which corresponds to a color in the default asset catalog of the specified bundle.

[`init(catalogName:colorName:)`](/documentation/AppKit/NSColor/init(catalogName:colorName:))

Creates a color object using the specified asset catalog and color names.

[`NSColor.Name`](/documentation/AppKit/NSColor/Name)

The name of a color.

### Creating a color using RGB components

[`init(srgbRed:green:blue:alpha:)`](/documentation/AppKit/NSColor/init(srgbRed:green:blue:alpha:)-9oz51)

Creates a color object from the specified components in the sRGB colorspace.

[`init(displayP3Red:green:blue:alpha:)`](/documentation/AppKit/NSColor/init(displayP3Red:green:blue:alpha:))

Creates a color object from the specified components in the Display P3 color space.

[`init(red:green:blue:alpha:)`](/documentation/AppKit/NSColor/init(red:green:blue:alpha:))

Creates a color object with the specified red, green, blue, and alpha channel values.

[`init(calibratedRed:green:blue:alpha:)`](/documentation/AppKit/NSColor/init(calibratedRed:green:blue:alpha:))

Creates a color object using the given opacity and RGB components.

[`init(deviceRed:green:blue:alpha:)`](/documentation/AppKit/NSColor/init(deviceRed:green:blue:alpha:))

Creates a color object using the given opacity value and RGB components.

### Creating a color using HSB components

[`init(calibratedHue:saturation:brightness:alpha:)`](/documentation/AppKit/NSColor/init(calibratedHue:saturation:brightness:alpha:))

Creates a color object using the given opacity and HSB color space components.

[`init(deviceHue:saturation:brightness:alpha:)`](/documentation/AppKit/NSColor/init(deviceHue:saturation:brightness:alpha:))

Creates a color object using the given opacity value and HSB color space components.

[`init(hue:saturation:brightness:alpha:)`](/documentation/AppKit/NSColor/init(hue:saturation:brightness:alpha:))

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

[`init(colorSpace:hue:saturation:brightness:alpha:)`](/documentation/AppKit/NSColor/init(colorSpace:hue:saturation:brightness:alpha:))

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

### Creating a color using CMYK components

[`init(deviceCyan:magenta:yellow:black:alpha:)`](/documentation/AppKit/NSColor/init(deviceCyan:magenta:yellow:black:alpha:))

Creates a color object using the given opacity value and CMYK components.

### Creating a color using white components

[`init(white:alpha:)`](/documentation/AppKit/NSColor/init(white:alpha:))

Creates a color object with the specified brightness and alpha channel values.

[`init(calibratedWhite:alpha:)`](/documentation/AppKit/NSColor/init(calibratedWhite:alpha:))

Creates a color object using the given opacity and grayscale values.

[`init(deviceWhite:alpha:)`](/documentation/AppKit/NSColor/init(deviceWhite:alpha:))

Creates a color object using the given opacity and grayscale values.

[`init(genericGamma22White:alpha:)`](/documentation/AppKit/NSColor/init(genericGamma22White:alpha:))

Returns a color object with the specified white and alpha values in the GenericGamma22 colorspace.

### Creating a high dynamic range (HDR) color

[`init(red:green:blue:alpha:linearExposure:)`](/documentation/AppKit/NSColor/init(red:green:blue:alpha:linearExposure:))

Generates an HDR color in the extended sRGB colorspace by applying an exposure to the SDR color defined by the red, green, and blue components. The `red`, `green`, and `blue` components have a nominal range of [0..1], `linearExposure` is a value >= 1. To produce an HDR color, we process the given color in a linear color space, multiplying component values by `linearExposure `. The produced color will have a `contentHeadroom` equal to `linearExposure`. Each doubling of `linearExposure` produces a color that is twice as bright.

[`init(red:green:blue:alpha:exposure:)`](/documentation/AppKit/NSColor/init(red:green:blue:alpha:exposure:))

Generates an HDR color in the extended sRGB colorspace by applying an exposure to the SDR color defined by the red, green, and blue components. The `red`, `green`, and `blue` components have a nominal range of [0..1], `exposure` is a value >= 0. To produce an HDR color, we process the given color in a linear color space, multiplying component values by `2^exposure`. The produced color will have a `contentHeadroom` equal to the linearized exposure value. Each whole value of exposure produces a color that is twice as bright.

### Creating a pattern-based color

[`init(patternImage:)`](/documentation/AppKit/NSColor/init(patternImage:))

Creates a color object that uses the specified image pattern to paint the target area.

[`patternImage`](/documentation/AppKit/NSColor/patternImage)

The pattern image used to paint the target area.

### Creating a color dynamically

[`init(name:dynamicProvider:)`](/documentation/AppKit/NSColor/init(name:dynamicProvider:))

Creates a dynamic catalog color with a provider that’s used to resolve the exact color value, calculated on first use.

### Creating a color in an arbitrary color space

[`init(colorSpace:components:count:)`](/documentation/AppKit/NSColor/init(colorSpace:components:count:))

Creates a color object from the specified components of the given color space.

### Creating a system tint color

[`init(for:)`](/documentation/AppKit/NSColor/init(for:))

Returns the color object specified by the given control tint.

[`NSControlTint`](/documentation/AppKit/NSControlTint)

Constants for specifying a cell’s tint color.

### Converting other types of color objects

[`init(_:)`](/documentation/AppKit/NSColor/init(_:))

[`init(cgColor:)`](/documentation/AppKit/NSColor/init(cgColor:)-1hzl8)

Creates a color object using the specified Core Graphics color.

[`init(CIColor:)`](/documentation/AppKit/NSColor/init(CIColor:)-3rxsk)

Creates a color object from the specified Core Image color.

### Creating color objects

[`init()`](/documentation/AppKit/NSColor/init())

Initializes the color object.

[`init(coder:)`](/documentation/AppKit/NSColor/init(coder:))

Creates a color object from data in an unarchiver.

[`init(resource:)`](/documentation/AppKit/NSColor/init(resource:))

Initialize a `NSColor` with a color resource.



---

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)