bufferPushOpacity method

void bufferPushOpacity(
  1. OptimizedBufferHandle buffer,
  2. double opacity
)

Pushes opacity onto buffer's native opacity stack.

Noir rejects an opacity outside 0.0..1.0 so the domain stays explicit, and clears the stack as each frame borrows its buffer for the same reason as bufferPushScissorRect.

This primitive is far narrower than its name suggests, all upstream:

  • It does not fade ordinary text. bufferDrawText takes an ASCII fast path whenever the foreground and background are both fully opaque, writing cells directly and skipping the opacity funnel, so any value in (0.0, 1.0) paints identically to 1.0. Only 0.0 reads as transparent, and it does so through a separate early-out. Blending is observable through bufferSetCellWithAlphaBlending and bufferFillRect. An Opacity widget cannot be built on this alone.
  • The push multiplies with the current value rather than replacing it, so 0.5 inside 0.5 yields 0.25.
  • drawFrameBuffer reads the destination's stack and ignores the source's, so pushing opacity onto an offscreen layer does nothing.

Implementation

void bufferPushOpacity(OptimizedBufferHandle buffer, double opacity) {
  if (opacity.isNaN || opacity < 0.0 || opacity > 1.0) {
    throw RangeError.range(opacity, 0, 1, 'opacity');
  }
  _guard('Failed to push opacity', () {
    _native.bufferPushOpacity(buffer.value, opacity);
  });
}