<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSCompositingOperation",
  "metadataVersion" : "0.1.0",
  "role" : "Enumeration",
  "symbol" : {
    "kind" : "Enumeration",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:@E@NSCompositingOperation"
  },
  "title" : "NSCompositingOperation"
}
-->

# NSCompositingOperation

Constants that describe compositing operators in terms of source and destination images, each having an opaque and transparent region.

```
enum NSCompositingOperation
```

## Overview

The type of operation, the source image, and the destination image determine the final output.

These compositing operators are defined in and used by [`compositeToPoint:fromRect:operation:`](/documentation/AppKit/NSImage/compositeToPoint:fromRect:operation:), [`compositeToPoint:operation:`](/documentation/AppKit/NSImage/compositeToPoint:operation:), [`compositeToPoint:fromRect:operation:fraction:`](/documentation/AppKit/NSImage/compositeToPoint:fromRect:operation:fraction:), [`compositeToPoint:operation:fraction:`](/documentation/AppKit/NSImage/compositeToPoint:operation:fraction:), [`draw(at:from:operation:fraction:)`](/documentation/AppKit/NSImage/draw(at:from:operation:fraction:)), and [`draw(in:from:operation:fraction:)`](/documentation/AppKit/NSImage/draw(in:from:operation:fraction:)). They are also used by drawing methods in other classes that take a compositing operator.

The equations after each constant represent the mathematical formulas for calculating the color value of the resulting pixel. The table below lists the meaning of each placeholder value in the equations.

|Placeholder|Meaning                                  |
|-----------|-----------------------------------------|
|`R`        |The premultiplied result color.          |
|`S`        |The source color.                        |
|`D`        |The destination color.                   |
|`Sa`       |The alpha value of the source color.     |
|`Da`       |The alpha value of the destination color.|

## Topics

### Operations for Compositing

[`NSCompositingOperation.clear`](/documentation/AppKit/NSCompositingOperation/clear)

Transparency everywhere.

[`NSCompositingOperation.copy`](/documentation/AppKit/NSCompositingOperation/copy)

The source image.

[`NSCompositingOperation.sourceOver`](/documentation/AppKit/NSCompositingOperation/sourceOver)

The source image wherever it is opaque, and the destination image elsewhere.

[`NSCompositingOperation.sourceIn`](/documentation/AppKit/NSCompositingOperation/sourceIn)

The source image wherever both images are opaque, and transparent elsewhere.

[`NSCompositingOperation.sourceOut`](/documentation/AppKit/NSCompositingOperation/sourceOut)

The source image wherever it is opaque and the destination image is transparent, and transparent elsewhere.

[`NSCompositingOperation.sourceAtop`](/documentation/AppKit/NSCompositingOperation/sourceAtop)

The source image wherever both images are opaque, the destination image wherever it is opaque but the source image is transparent, and transparent elsewhere

[`NSCompositingOperation.destinationOver`](/documentation/AppKit/NSCompositingOperation/destinationOver)

The destination image wherever it is opaque, and the source image elsewhere.

[`NSCompositingOperation.destinationIn`](/documentation/AppKit/NSCompositingOperation/destinationIn)

The destination image wherever both images are opaque, and transparent elsewhere.

[`NSCompositingOperation.destinationOut`](/documentation/AppKit/NSCompositingOperation/destinationOut)

The destination image wherever it is opaque and the source image is transparent, and transparent elsewhere.

[`NSCompositingOperation.destinationAtop`](/documentation/AppKit/NSCompositingOperation/destinationAtop)

The destination image wherever both images are opaque, the source image wherever it is opaque and the destination image is transparent, and transparent elsehwere.

[`NSCompositingOperation.xor`](/documentation/AppKit/NSCompositingOperation/xor)

Exclusive OR of the source and destination images.

[`NSCompositingOperation.plusDarker`](/documentation/AppKit/NSCompositingOperation/plusDarker)

The sum of the source and destination images, with color values approach 0 as a limit.

[`NSCompositingOperation.plusLighter`](/documentation/AppKit/NSCompositingOperation/plusLighter)

The sum of the source and destination images, with color values approach 1 as a limit.

[`NSCompositingOperation.multiply`](/documentation/AppKit/NSCompositingOperation/multiply)

The source color is multiplied by the destination color.

[`NSCompositingOperation.screen`](/documentation/AppKit/NSCompositingOperation/screen)

Multiplies the complement of the destination and source color values, and then complements the result.

[`NSCompositingOperation.overlay`](/documentation/AppKit/NSCompositingOperation/overlay)

Source colors overlay the destination.

[`NSCompositingOperation.darken`](/documentation/AppKit/NSCompositingOperation/darken)

Use the darker of the source and destination colors.

[`NSCompositingOperation.lighten`](/documentation/AppKit/NSCompositingOperation/lighten)

Use the lighter of the source and destination colors.

[`NSCompositingOperation.colorDodge`](/documentation/AppKit/NSCompositingOperation/colorDodge)

Brightens the destination to reflect the source.

[`NSCompositingOperation.colorBurn`](/documentation/AppKit/NSCompositingOperation/colorBurn)

Darkens the destination color to reflect the source.

[`NSCompositingOperation.softLight`](/documentation/AppKit/NSCompositingOperation/softLight)

Darkens or lightens colors, with the effect of shining a diffused spotlight on the destination.

[`NSCompositingOperation.hardLight`](/documentation/AppKit/NSCompositingOperation/hardLight)

Multiplies or screens colors, with the effect of shining a spotlight on the destination.

[`NSCompositingOperation.difference`](/documentation/AppKit/NSCompositingOperation/difference)

Subtracts the darker value from the lighter value.

[`NSCompositingOperation.exclusion`](/documentation/AppKit/NSCompositingOperation/exclusion)

Subtracts the darker value from the lighter value, except lower in contrast.

[`NSCompositingOperation.hue`](/documentation/AppKit/NSCompositingOperation/hue)

Uses the hue of the source and the saturation and luminosity of the destination.

[`NSCompositingOperation.saturation`](/documentation/AppKit/NSCompositingOperation/saturation)

Uses the saturation value of the source and the hue and luminosity of the destination.

[`NSCompositingOperation.color`](/documentation/AppKit/NSCompositingOperation/color)

Uses the hue and saturation of the source and the luminosity of the destination.

[`NSCompositingOperation.luminosity`](/documentation/AppKit/NSCompositingOperation/luminosity)

Uses the luminosity of the source and the hue and saturation of the destination.

### Deprecated Compositing Modes

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

Transparent. (`R = 0`)

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

Source image. (`R = S`)

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

Source image wherever source image is opaque, and destination image elsewhere. (`R = S + D*(1 - Sa)`)

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

Source image wherever both images are opaque, and transparent elsewhere. (`R = S*Da`)

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

Source image wherever source image is opaque but destination image is transparent, and transparent elsewhere. (`R = S*(1 - Da)`)

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

Source image wherever both images are opaque, destination image wherever destination image is opaque but source image is transparent, and transparent elsewhere. (`R = S*Da + D*(1 - Sa)`)

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

Destination image wherever destination image is opaque, and source image elsewhere. (`R = S*(1 - Da) + D`)

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

Destination image wherever both images are opaque, and transparent elsewhere. (`R = D*Sa`)

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

Destination image wherever destination image is opaque but source image is transparent, and transparent elsewhere. (`R = D*(1 - Sa)`)

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

Destination image wherever both images are opaque, source image wherever source image is opaque but destination image is transparent, and transparent elsewhere. (`R = S*(1 - Da) + D*Sa`)

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

Exclusive OR of source and destination images. (`R = S*(1 - Da) + D*(1 - Sa)`)

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

Sum of source and destination images, with color values approaching 0 as a limit. (`R = MAX(0, (1 - D) + (1 - S))`)

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

Sum of source and destination images, with color values approaching 1 as a limit. (`R = MIN(1, S + D)`)

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

The source color is multiplied by the destination color.

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

Multiplies the complement of the destination and source color values, and then complements the result.

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

Source colors overlay the destination.

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

Use the darker of the source and destination colors.

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

Use the lighter of the source and destination colors.

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

Brightens the destination to reflect the source.

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

Darkens the destination color to reflect the source.

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

Darkens or lightens colors, with the effect of shining a diffused spotlight on the destination.

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

Multiplies or screens colors, with the effect of shining a spotlight on the destination.

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

Subtracts the darker value from the lighter value.

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

Subtracts the darker value from the lighter value, except lower in contrast.

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

Uses the hue of the source and the saturation and luminosity of the destination.

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

Uses the saturation value of the source and the hue and luminosity of the destination.

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

Uses the hue and saturation of the source and the luminosity of the destination.

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

Uses the luminosity of the source and the hue and saturation of the destination.

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

Source image wherever source image is opaque, and destination image elsewhere.

[`NSCompositingOperationHighlight`](/documentation/AppKit/NSCompositingOperation/NSCompositingOperationHighlight)

The source image wherever it is opaque, and the destination image elsewhere.



---

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)