1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//! Color compositing helpers shared by the paint pass and the
//! buffer's cell-write methods.
//!
//! `alpha_blend(src, alpha, dst)` performs straight-alpha
//! composition: `out = α·src + (1-α)·dst`. The function used to
//! live in `paint_pass/mod.rs`, where it pre-blended an element's
//! colors against the resolved `parent_bg` at cascade time (Phase
//! 1 of the opacity rollout). Phase 2 moved the call site to the
//! buffer's cell-write path so the blend resolves against the
//! cell's actual `bg` — correct for z-stacked overlays where the
//! cell underneath has a different bg from the painter's DOM
//! parent. The function itself is unchanged; only its callers moved.
use crateColor;
/// Alpha-blend `src` over `dst` using `alpha` ∈ [0, 1].
/// Straight-alpha compositing: `out = α·src + (1-α)·dst`.
///
/// - `alpha >= 1.0` → returns `src` unchanged.
/// - `src == Color::Reset` → returns `Color::Reset` (no source color
/// to blend; preserves the "transparent" sentinel).
/// - `src` is non-`Rgb` (Indexed, ANSI palette) → returns `src`
/// unchanged. T6 collapsed ANSI to RGB at the cascade level, but
/// the through-path is preserved for defensive parsing.
/// - `dst == Color::Reset` (or other non-`Rgb`) → blends against the
/// `#000000` canvas model. Terminals don't expose their actual
/// default bg, so we pick a deterministic fallback.
pub