bufferPushOpacity method
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.
bufferDrawTexttakes 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 to1.0. Only0.0reads as transparent, and it does so through a separate early-out. Blending is observable through bufferSetCellWithAlphaBlending and bufferFillRect. AnOpacitywidget cannot be built on this alone. - The push multiplies with the current value rather than replacing
it, so
0.5inside0.5yields0.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);
});
}