withAlpha
A color with its alpha replaced by a separately built mask.
withAlpha(color: PaintSlot, alpha: PaintSlot): PatternPaint
Import patterns from shaders/std and use patterns.withAlpha.
The usual way to hang a pattern under one color: the mask becomes the coverage and the color's own alpha is dropped.
Parameters
| Name | Type | Notes |
|---|---|---|
color | PaintSlot | |
alpha | PaintSlot |
Example
paint: withAlpha(p('color'), dotLattice({density: p('density'), dotSize: p('dotSize'), offset: p('offset'), speedVariance: p('speedVariance'), twinkle: p('twinkle')}))
Tip. To keep the color's own alpha as well, multiply it in:
withAlpha(color, times(alphaOf(color), mask)).
See also
alphaOf— The alpha channel of a color, as a number per pixel.times— The product of two values: a mask scaled by a prop, an RGB dimmed by a shade, two masks combined.opaque— An RGB value finished as a fully opaque color.