globalCompositeOperation

globalCompositeOperation property

Gets or sets a value that indicates how source images are drawn onto a destination image.

HTML Canvas 2D Context level 2

 

Syntax

JavaScript

p = object.globalCompositeOperation

 

Property values

Type: string

source-atop

The source image (A) is copied on top of the destination image (B). The source image is displayed where both images are opaque. The destination image is displayed where the destination image is opaque and the source image is transparent. Other regions are transparent.

source-in

The source image (A) is copied in to the destination image (B). The source image is displayed where both the source and destination are opaque. Other regions are transparent.

source-out

The source image (A) is copied out of the destination image (B). The source image is displayed where the source is opaque and the destination is transparent. Other regions are transparent.

source-over

Default. The source image (A) is copied over the destination image (B). The source image is displayed where the source image is opaque. The destination image is displayed elsewhere.

destination-atop

The destination image (B) is copied on top of the source image (A). The destination image is displayed where both images are opaque. The source image is displayed where the source image is opaque and the destination image is transparent. Other regions are transparent.

destination-in

The destination image (B) is copied into the source image (A). The destination image is displayed where both the source and destination are opaque. Other regions are transparent.

destination-out

The destination image (B) is copied out of the source image (A). The destination image is displayed where the destination is opaque and the source is transparent. Other regions are transparent.

destination-over

The destination image (B) is copied over the source image (A). The destination image is displayed where the destination image is opaque. The source image is displayed elsewhere.

lighter

The source image (A) is copied plus the destination image (B). The sum of the source image and destination image is displayed. Color values approach 1 as a limit.

copy

The source image (A) is copied to the destination image (B). The destination image is ignored.

xor

The source image (A) is combined by using an exclusive OR (XOR) with the destination image (B).

normal

Specifies no blending. The final color is the source color.

multiply

Multiplies the source and backdrop colors. Multiplying with black results in a black color. Multiplying with white has no change on the original color.

screen

The source color and backdrop colors are inverted, multiplied, and the resulting value is inverted. Multiplying with black has no change on the color. Multiplying with white results in a white final color.

darken

The darker color is selected from the backdrop or source color.

lighten

The lighter color is selected from the backdrop or source color.

overlay

Multiplies or screens the colors. Multiply is used if the backdrop color is darker. Screen is used if the backdrop color is lighter.

color-dodge

The backdrop color is brightened to reflect the source color. A black source color has no change on the final color.

color-burn

The backdrop color is darkened to reflect the source color. A white source color has no change on the final color.

hard-light

Multiplies or screens the colors. Multiply is used if the backdrop color is lighter. Screen is used if the backdrop color is darker. This is similar to shining a harsh spotlight on the backdrop.

soft-light

Similar to hard-light, but softer. Multiplies or screens the colors. Multiply is used if the backdrop color is lighter. Screen is used if the backdrop color is darker. This is similar to shining a diffused spotlight on the backdrop.

difference

Subtracts the darker of the colors from the lighter one. A black layer has no change. A white layer inverts the backdrop color.

exclusion

Similar to difference but lower in contrast. A black layer has no change. A white layer inverts the backdrop color.

hue

The final color has the saturation and luminosity of the backdrop color and the hue of the source color.

saturation

The final color as the hue and luminosity of the backdrop color and the saturation of the source color.

color

The final color has the luminosity of the backdrop color and the hue and saturation of the source color. This preserves the gray levels of the backdrop.

luminosity

The final color has the hue and saturation of the backdrop color and the luminosity of the source color.

Standards information

Remarks

Values are case-sensitive. If you set an unsupported or unrecognized value, globalCompositeOperation retains the previous value.

See also

CanvasRenderingContext2D
globalAlpha

 

 

Show:
© 2016 Microsoft