premultiply
Multiplies the color channels by the alpha channel (premultiplied alpha), the form compositing and GPU blending work in. The channels are returned as they are, not rounded, so that unpremultiply gives the color back.
Available since v3.1.8
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
color | RgbColor | A straight (non-premultiplied) color; a missing alpha is 1 |
Returns
Section titled “Returns”RgbColor — The premultiplied color
Examples
Section titled “Examples”Premultiply a half-transparent color
Section titled “Premultiply a half-transparent color”The channels are scaled by the alpha, the form GPU blending and canvas pixels use.
An opaque color is unchanged
Section titled “An opaque color is unchanged”A missing alpha counts as 1.
Related Types
Section titled “Related Types”RgbColor
Section titled “RgbColor”An RGB(A) color with channels expressed as plain numbers, convenient for further conversion or manipulation.
