PorterDuff
Porter-Duff refers to a formal set of image compositing rules used to determine how a source image blends with a destination image in alpha-based rendering. Introduced by Matt Porter and Tom Duff in 1984, the framework provides a concise mathematical model for combining two RGBA pixels to produce a new color and transparency.
The model identifies a family of binary operations that depend on the source (S) and destination (D)
The standard Porter-Duff operators (SRC/DST) include:
- Clear: result is fully transparent.
- Source (SRC): result is exactly the source.
- Destination (DST): result is exactly the destination.
- SourceOver: standard alpha over operation.
- DestinationOver: destination drawn underneath the source.
- SourceIn: keep source where destination exists.
- DestinationIn: keep destination where source exists.
- SourceOut: keep source where destination is absent.
- DestinationOut: keep destination where source is absent.
- SourceAtop: source on top of destination where both overlap.
- DestinationAtop: destination on top of source where both overlap.
- XOR: only the non-overlapping regions contribute.
Modern implementations often assume pre-multiplied alpha, simplifying calculations. Graphics APIs and tools—such as HTML canvas, SVG,