<!--
{
  "availability" : [
    "iOS: 5.0.0 -",
    "iPadOS: 5.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.4.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreImage",
  "identifier" : "/documentation/CoreImage/CIColor",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core Image"
    ],
    "preciseIdentifier" : "c:objc(cs)CIColor"
  },
  "title" : "CIColor"
}
-->

# CIColor

The Core Image class that defines a color object.

```
class CIColor
```

## Overview

Use `CIColor` instances in conjunction with other Core Image classes, such as [`CIFilter`](/documentation/CoreImage/CIFilter-swift.class) and [`CIKernel`](/documentation/CoreImage/CIKernel).
Many of the built-in Core Image filters have one or more `CIColor` inputs that you can set to affect the filter’s
behavior.

### Color Model

A color is defined as a N-dimensional model where each dimension’s color component is represented
by intensity values. A color component may also be referred to as a color channel. An RGB color model, for example,
is three-dimensional and the red, green, and blue component intensities define each unique color.

### Color Space

A color is also defined by a color space that locates the axes of N-dimensional model within the greater
volume of human perceivable colors.  Core Image uses `CGColorSpace` instances to specify a variety of different
color spaces such as sRGB, P3, BT.2020, etc. The `CGColorSpace` also defines if the color space is coded
linearly or in a non-linear perceptual curve.
(For more information on `CGColorSpace` see <doc://com.apple.documentation/documentation/CoreGraphics/CGColorSpace>)

### Color Range

Standard dynamic range (SDR) color color component values range from `0.0` to `1.0`, with `0.0`
representing an 0% of that component and `1.0` representing 100%. In contrast, high dynamic range (HDR) color values
can be less than `0.0` (for more saturation) or greater than `1.0` (for more brightness).

### Color Opacity

`CIColor` instances also have an alpha component, which represents the opacity of the color, with 0.0 meaning completely
transparent and 1.0 meaning completely opaque. If a color does not have an explicit alpha component, Core Image
assumes that the alpha component equals 1.0. With `CIColor` that color components values are not premultiplied.
So for example, a semi-transparent pure red `CIColor` is represented by RGB `1.0,0.0,0.0` and A `0.5`.  In contrast
color components values in [`CIImage`](/documentation/CoreImage/CIImage) buffers or read in [`CIKernel`](/documentation/CoreImage/CIKernel) samplers are premultiplied by default.

## Topics

### Initializing Color Objects

[`init(cgColor:)`](/documentation/CoreImage/CIColor/init(cgColor:)-1hzk4)

Create a Core Image color object with a Core Graphics color object.

[`init(color:)`](/documentation/CoreImage/CIColor/init(color:))

[`initWithRed:green:blue:`](/documentation/CoreImage/CIColor/initWithRed:green:blue:)

Initialize a Core Image color object in the sRGB color space
with the specified red, green, and blue component values.

[`init(red:green:blue:alpha:)`](/documentation/CoreImage/CIColor/init(red:green:blue:alpha:))

Initialize a Core Image color object in the sRGB color space
with the specified red, green, blue, and alpha component values.

### Creating Color Objects

[`colorWithCGColor:`](/documentation/CoreImage/CIColor/colorWithCGColor:)

Create a Core Image color object with a Core Graphics color object.

[`init(red:green:blue:)`](/documentation/CoreImage/CIColor/init(red:green:blue:))

Create a Core Image color object in the sRGB color space
with the specified red, green, and blue component values.

[`colorWithRed:green:blue:alpha:`](/documentation/CoreImage/CIColor/colorWithRed:green:blue:alpha:)

Create a Core Image color object in the sRGB color space
with the specified red, green, blue, and alpha component values.

[`init(string:)`](/documentation/CoreImage/CIColor/init(string:))

Create a Core Image color object in the sRGB color space using a string containing the RGBA color component values.

[`init(red:green:blue:colorSpace:)`](/documentation/CoreImage/CIColor/init(red:green:blue:colorSpace:)-2og6y)

Create a Core Image color object
with the specified red, green, and blue component values
as measured in the specified color space.

[`init(red:green:blue:alpha:colorSpace:)`](/documentation/CoreImage/CIColor/init(red:green:blue:alpha:colorSpace:)-5mvff)

Create a Core Image color object
with the specified red, green, blue, and alpha component values
as measured in the specified color space.

### Getting Color Components

[`colorSpace`](/documentation/CoreImage/CIColor/colorSpace)

Returns the `CGColorSpace` associated with the color

[`components`](/documentation/CoreImage/CIColor/components)

Return a pointer to an array of `CGFloat` values including alpha.

[`numberOfComponents`](/documentation/CoreImage/CIColor/numberOfComponents)

Returns the color components of the color including alpha.

[`red`](/documentation/CoreImage/CIColor/red-swift.property)

Returns the unpremultiplied red component of the color.

[`green`](/documentation/CoreImage/CIColor/green-swift.property)

Returns the unpremultiplied green component of the color.

[`blue`](/documentation/CoreImage/CIColor/blue-swift.property)

Returns the unpremultiplied blue component of the color.

[`alpha`](/documentation/CoreImage/CIColor/alpha)

Returns the alpha value of the color.

[`stringRepresentation`](/documentation/CoreImage/CIColor/stringRepresentation)

Returns a formatted string with the unpremultiplied color and alpha components of the color.

### Creating a CIColor Object with Preset Components

[`black`](/documentation/CoreImage/CIColor/black)

Returns a singleton Core Image color instance in the sRGB color space with RGB values `0,0,0` and alpha value `1`.

[`blue`](/documentation/CoreImage/CIColor/blue-swift.type.property)

Returns a singleton Core Image color instance in the sRGB color space with RGB values `0,0,1` and alpha value `1`.

[`clear`](/documentation/CoreImage/CIColor/clear)

Returns a singleton Core Image color instance in the sRGB color space with RGB values `0,0,0` and alpha value `0`.

[`cyan`](/documentation/CoreImage/CIColor/cyan)

Returns a singleton Core Image color instance in the sRGB color space with RGB values `0,1,1` and alpha value `1`.

[`gray`](/documentation/CoreImage/CIColor/gray)

Returns a singleton Core Image color instance in the sRGB color space with RGB values `0.5,0.5,0.5` and alpha value `1`.

[`green`](/documentation/CoreImage/CIColor/green-swift.type.property)

Returns a singleton Core Image color instance in the sRGB color space with RGB values `0,1,0` and alpha value `1`.

[`magenta`](/documentation/CoreImage/CIColor/magenta)

Returns a singleton Core Image color instance in the sRGB color space with RGB values `1,0,1` and alpha value `1`.

[`red`](/documentation/CoreImage/CIColor/red-swift.type.property)

Returns a singleton Core Image color instance in the sRGB color space with RGB values `1,0,0` and alpha value `1`.

[`white`](/documentation/CoreImage/CIColor/white)

Returns a singleton Core Image color instance in the sRGB color space with RGB values `1,1,1` and alpha value `1`.

[`yellow`](/documentation/CoreImage/CIColor/yellow)

Returns a singleton Core Image color instance in the sRGB color space with RGB values `1,1,0` and alpha value `1`.



---

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)