paintThrough

Show a paint through the child, so the child becomes the mask.

paintThrough(paint: Paint, opts: {by?: 'alpha' | 'luminance'} = {}): PointwiseEffect

Import paintThrough from shaders/std.

Like CSS mask-image the other way round: the paint is the content and the child decides where it shows. by: 'alpha' (the default) reveals the paint wherever the child is opaque, which gives a gradient through text. by: 'luminance' reveals it where the child is bright. The paint's own alpha still applies. Pointwise.

Parameters

NameTypeNotes
paintPaint
opts{by?: 'alpha' | 'luminance'}Optional. Default {}.

Example

effect: paintThrough(paint.rampOver(paint.dist.radial({center: p('center'), radius: p('radius'), aspect: 1, skew: 0}), paint.pair(p('colorA'), p('colorB'), p('colorSpace'))))

See also

  • tintToward — Mix the child's color toward one color by an amount, leaving its alpha alone.
  • pointwise — Write your own pointwise effect: a function of the child's color at this pixel.