TermBuf::Blend
Stability: stable — changes only in a major release.
How a write settles the style of each cell it lands on: given the style already there, the style being written, and the cell's position, it returns the style to place.
dim = TermBuf::Style.blend { |under, over| under.merge(over).faint }
screen.write 0, 0, "over a shadow", Style::DEFAULT, blend: dim
Style::KEEP_BACKGROUND and Style::OVER cover the two common answers,
and Style.blend wraps a block that only wants the two styles.
The position is in the buffer's coordinates, not those of whatever view the write went through: a view translates the write before the buffer runs the blend, so a blend keyed on position sees where the cell actually is.
A blend is run per cell and its answer is interned, and StyleTable only
grows. One returning a colour computed from the position — a gradient —
therefore interns a style per cell. That is bounded by the screen for a
single frame and fine; recomputed every frame from different colours it is
unbounded, and an animation wanting that should draw from a fixed palette
of styles instead.