One Logo Pool Ball
SwiftUICore · IOS API REFERENCE

GraphicsContext.BlendMode

struct · iOS 15.0+ · SDK 27.1

@frozen struct BlendMode

The ways that a graphics context combines new content with background content. Use one of these values to set the ``GraphicsContext/blendMode-swift.property`` property of a ``GraphicsContext``. The value that you set affects how content that you draw replaces or combines with content that you previously drew into the context.

Members (30)

get · iOS 15.0+

colorDodge

TypeScript
get colorDodge(): GraphicsContext_BlendMode
Swift declaration
static var colorDodge: GraphicsContext.BlendMode { get }

A mode that brightens the background image samples to reflect the source image samples. Source image sample values that specify black do not produce a change.

get · iOS 15.0+

difference

TypeScript
get difference(): GraphicsContext_BlendMode
Swift declaration
static var difference: GraphicsContext.BlendMode { get }

A mode that subtracts the brighter of the source image sample color or the background image sample color from the other. Source image sample values that are black produce no change; white inverts the background color values.

get · iOS 15.0+

luminosity

TypeScript
get luminosity(): GraphicsContext_BlendMode
Swift declaration
static var luminosity: GraphicsContext.BlendMode { get }

A mode that uses the hue and saturation of the background with the luminance of the source image. This mode creates an effect that is inverse to the effect created by the ``color`` mode.

get · iOS 15.0+

plusDarker

TypeScript
get plusDarker(): GraphicsContext_BlendMode
Swift declaration
static var plusDarker: GraphicsContext.BlendMode { get }

A mode that adds the inverse of the color components of the source and background images, and then inverts the result, producing a darkened composite. This mode implements the equation `R = MAX(0, 1 - ((1 - D) + (1 - S)))` where * `R` is the composite image. * `S` is the source image. * `D` is the background.

get · iOS 15.0+

saturation

TypeScript
get saturation(): GraphicsContext_BlendMode
Swift declaration
static var saturation: GraphicsContext.BlendMode { get }

A mode that uses the luminance and hue values of the background with the saturation of the source image. Areas of the background that have no saturation --- namely, pure gray areas --- don't produce a change.

get · iOS 15.0+

sourceAtop

TypeScript
get sourceAtop(): GraphicsContext_BlendMode
Swift declaration
static var sourceAtop: GraphicsContext.BlendMode { get }

A mode that you use to paint the opaque parts of the source image onto the opaque parts of the background. This mode implements the equation `R = S*Da + D*(1 - Sa)` where * `R` is the composite image. * `S` is the source image. * `D` is the background. * `Sa` is the source image's alpha value. * `Da` is the source background's alpha value.

get · iOS 15.0+

plusLighter

TypeScript
get plusLighter(): GraphicsContext_BlendMode
Swift declaration
static var plusLighter: GraphicsContext.BlendMode { get }

A mode that adds the components of the source and background images, resulting in a lightened composite. This mode implements the equation `R = MIN(1, S + D)` where * `R` is the composite image. * `S` is the source image. * `D` is the background.

get · iOS 15.0+

destinationIn

TypeScript
get destinationIn(): GraphicsContext_BlendMode
Swift declaration
static var destinationIn: GraphicsContext.BlendMode { get }

A mode that you use to erase any of the background that isn't covered by opaque source pixels. This mode implements the equation `R = D*Sa` where * `R` is the composite image. * `S` is the source image. * `Da` is the source background's alpha value.

get · iOS 15.0+

destinationOut

TypeScript
get destinationOut(): GraphicsContext_BlendMode
Swift declaration
static var destinationOut: GraphicsContext.BlendMode { get }

A mode that you use to erase any of the background that is covered by opaque source pixels. This mode implements the equation `R = D*(1 - Sa)` where * `R` is the composite image. * `D` is the background. * `Sa` is the source image's alpha value.

get · iOS 15.0+

destinationAtop

TypeScript
get destinationAtop(): GraphicsContext_BlendMode
Swift declaration
static var destinationAtop: GraphicsContext.BlendMode { get }

A mode that you use to paint the source image under the background, while erasing any of the background not matched by opaque pixels from the source image. This mode implements the equation `R = S*(1 - Da) + D*Sa` where * `R` is the composite image. * `S` is the source image. * `D` is the background. * `Sa` is the source image's alpha value. * `Da` is the source background's alpha value.

get · iOS 15.0+

destinationOver

TypeScript
get destinationOver(): GraphicsContext_BlendMode
Swift declaration
static var destinationOver: GraphicsContext.BlendMode { get }

A mode that you use to paint the source image under the background. This mode implements the equation `R = S*(1 - Da) + D` where * `R` is the composite image. * `S` is the source image. * `D` is the background. * `Da` is the source background's alpha value.

get · iOS 15.0+

hue

TypeScript
get hue(): GraphicsContext_BlendMode
Swift declaration
static var hue: GraphicsContext.BlendMode { get }

A mode that uses the luminance and saturation values of the background with the hue of the source image.

get · iOS 15.0+

xor

TypeScript
get xor(): GraphicsContext_BlendMode
Swift declaration
static var xor: GraphicsContext.BlendMode { get }

A mode that you use to clear pixels where both the source and background images are opaque. This mode implements the equation `R = S*(1 - Da) + D*(1 - Sa)` where * `R` is the composite image. * `S` is the source image. * `D` is the background. * `Sa` is the source image's alpha value. * `Da` is the source background's alpha value. This XOR mode is only nominally related to the classical bitmap XOR operation, which SwiftUI doesn't support.

get · iOS 15.0+

copy

TypeScript
get copy(): GraphicsContext_BlendMode
Swift declaration
static var copy: GraphicsContext.BlendMode { get }

A mode that replaces background image samples with source image samples. Unlike the ``normal`` mode, the source image completely replaces the background, so that even transparent pixels in the source image replace opaque pixels in the background, rather than letting the background show through. This mode implements the equation `R = S` where * `R` is the composite image. * `S` is the source image.

get · iOS 15.0+

clear

TypeScript
get clear(): GraphicsContext_BlendMode
Swift declaration
static var clear: GraphicsContext.BlendMode { get }

A mode that clears any pixels that the source image overwrites. With this mode, you can use the source image like an eraser. This mode implements the equation `R = 0` where `R` is the composite image.

get · iOS 15.0+

color

TypeScript
get color(): GraphicsContext_BlendMode
Swift declaration
static var color: GraphicsContext.BlendMode { get }

A mode that uses the luminance values of the background with the hue and saturation values of the source image. This mode preserves the gray levels in the image. You can use this mode to color monochrome images or to tint color images.

get · iOS 15.0+

darken

TypeScript
get darken(): GraphicsContext_BlendMode
Swift declaration
static var darken: GraphicsContext.BlendMode { get }

A mode that creates composite image samples by choosing the darker samples from either the source image or the background. When you draw in this mode, source image samples that are darker than the background replace the background. Otherwise, the background image samples remain unchanged.

get · iOS 15.0+

normal

TypeScript
get normal(): GraphicsContext_BlendMode
Swift declaration
static var normal: GraphicsContext.BlendMode { get }

A mode that paints source image samples over the background image samples. This is the default blend mode.

get · iOS 15.0+

screen

TypeScript
get screen(): GraphicsContext_BlendMode
Swift declaration
static var screen: GraphicsContext.BlendMode { get }

A mode that multiplies the inverse of the source image samples with the inverse of the background image samples. Drawing in this mode results in colors that are at least as light as either of the two contributing sample colors.

get · iOS 15.0+

lighten

TypeScript
get lighten(): GraphicsContext_BlendMode
Swift declaration
static var lighten: GraphicsContext.BlendMode { get }

A mode that creates composite image samples by choosing the lighter samples from either the source image or the background. When you draw in this mode, source image samples that are lighter than the background replace the background. Otherwise, the background image samples remain unchanged.

get · iOS 15.0+

overlay

TypeScript
get overlay(): GraphicsContext_BlendMode
Swift declaration
static var overlay: GraphicsContext.BlendMode { get }

A mode that either multiplies or screens the source image samples with the background image samples, depending on the background color. Drawing in this mode overlays the existing image samples while preserving the highlights and shadows of the background. The background color mixes with the source image to reflect the lightness or darkness of the background.

get · iOS 15.0+

multiply

TypeScript
get multiply(): GraphicsContext_BlendMode
Swift declaration
static var multiply: GraphicsContext.BlendMode { get }

A mode that multiplies the source image samples with the background image samples. Drawing in this mode results in colors that are at least as dark as either of the two contributing sample colors.

init · iOS 15.0+

init

TypeScript
init(rawValue: number): GraphicsContext_BlendMode
Swift declaration
init(rawValue: Int32)

Creates a new instance with the specified raw value. If there is no value of the type that corresponds with the specified raw value, this initializer returns `nil`. For example: enum PaperSize: String { case A4, A5, Letter, Legal } print(PaperSize(rawValue: "Legal")) // Prints "Optional(PaperSize.Legal)" print(PaperSize(rawValue: "Tabloid")) // Prints "nil" - Parameter rawValue: The raw value to use for the new instance.

get · iOS 15.0+

rawValue

TypeScript
getRawValue($self: GraphicsContext_BlendMode): number
Swift declaration
let rawValue: Int32

The corresponding value of the raw type. A new instance initialized with `rawValue` will be equivalent to this instance. For example: enum PaperSize: String { case A4, A5, Letter, Legal } let selectedSize = PaperSize.Letter print(selectedSize.rawValue) // Prints "Letter" print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!) // Prints "true"

get · iOS 15.0+

sourceIn

TypeScript
get sourceIn(): GraphicsContext_BlendMode
Swift declaration
static var sourceIn: GraphicsContext.BlendMode { get }

A mode that you use to paint the source image, including its transparency, onto the opaque parts of the background. This mode implements the equation `R = S*Da` where * `R` is the composite image. * `S` is the source image. * `Da` is the source background's alpha value.

get · iOS 15.0+

colorBurn

TypeScript
get colorBurn(): GraphicsContext_BlendMode
Swift declaration
static var colorBurn: GraphicsContext.BlendMode { get }

A mode that darkens background image samples to reflect the source image samples. Source image sample values that specify white do not produce a change.

get · iOS 15.0+

exclusion

TypeScript
get exclusion(): GraphicsContext_BlendMode
Swift declaration
static var exclusion: GraphicsContext.BlendMode { get }

A mode that produces an effect similar to that produced by the difference blend mode, but with lower contrast. Source image sample values that are black don't produce a change; white inverts the background color values.

get · iOS 15.0+

hardLight

TypeScript
get hardLight(): GraphicsContext_BlendMode
Swift declaration
static var hardLight: GraphicsContext.BlendMode { get }

A mode that either multiplies or screens colors, depending on the source image sample color. If the source image sample color is lighter than 50% gray, the background is lightened, similar to screening. If the source image sample color is darker than 50% gray, the background is darkened, similar to multiplying. If the source image sample color is equal to 50% gray, the source image is not changed. Image samples that are equal to pure black or pure white result in pure black or white. The overall effect is similar to what you'd achieve by shining a harsh spotlight on the source image. Use this to add highlights to a scene.

get · iOS 15.0+

softLight

TypeScript
get softLight(): GraphicsContext_BlendMode
Swift declaration
static var softLight: GraphicsContext.BlendMode { get }

A mode that either darkens or lightens colors, depending on the source image sample color. If the source image sample color is lighter than 50% gray, the background is lightened, similar to dodging. If the source image sample color is darker than 50% gray, the background is darkened, similar to burning. If the source image sample color is equal to 50% gray, the background is not changed. Image samples that are equal to pure black or pure white produce darker or lighter areas, but do not result in pure black or white. The overall effect is similar to what you'd achieve by shining a diffuse spotlight on the source image. Use this to add highlights to a scene.

get · iOS 15.0+

sourceOut

TypeScript
get sourceOut(): GraphicsContext_BlendMode
Swift declaration
static var sourceOut: GraphicsContext.BlendMode { get }

A mode that you use to paint the source image onto the transparent parts of the background, while erasing the background. This mode implements the equation `R = S*(1 - Da)` where * `R` is the composite image. * `S` is the source image. * `Da` is the source background's alpha value.

Skipped declarations

No declarations were skipped in this snapshot.

All SwiftUICore types →