/

HTML / CSS / JavaScript Tutorial

JavaScript canvas2d object property: globalCompositeOperation

[this page | pdf | back links]

The globalCompositeOperation property of the JavaScript DOM object returned by the getContext("2d") method applied to the HTML <canvas> element sets / returns how new images are drawn onto existing images.

 

It can take the following values:

 

Value

Meaning

copy

Source image only (destination image is ignored)

destination-atop

As per source-atop but with source and destination flipped

destination-in

As per source-in but with source and destination flipped

destination-out

As per source-out but with source and destination flipped

destination-over

As per source-over but with source and destination flipped

lighter

Source image + destination image

source-atop

Source image on top of destination image (part of source image outside destination image is ignored)

source-in

Source image into destination image (only part of source image inside destination image is shown, destination image is transparent)

source-out

Source image out of destination image (only part of source image outside destination image is shown, destination image is transparent)

source-over

(default). Source image over destination image

xor

Source and destination images combined using XOR operation

 


NAVIGATION LINKS
Contents | Prev | Next | JavaScript DOM (and BOM)


Desktop view | Switch to Mobile