pub trait BufferTransition: Send + Sync {
// Required methods
fn transition(
&self,
from: &Buffer,
to: &Buffer,
dst: &mut Buffer,
progress: f32,
);
fn name(&self) -> &'static str;
}Expand description
字符级页面转场特效 trait
与 BufferEffect 不同,BufferTransition 接受两个源 Buffer (from/to), 根据 progress 将它们混合到目标 Buffer。
§工作原理
┌─────────────┐ ┌─────────────┐
│ from Buffer │ │ to Buffer │
│ (页面 A) │ │ (页面 B) │
└──────┬──────┘ └──────┬──────┘
│ │
└─────────┬─────────┘
▼
┌─────────────────────┐
│ BufferTransition │ ← progress (0.0~1.0)
│ (字符级混合) │
└──────────┬──────────┘
▼
┌─────────────┐
│ dst Buffer │
└─────────────┘§Example
ⓘ
let wipe = WipeTransition::left();
wipe.transition(&page_a, &page_b, &mut output, 0.5);
// output 左半部分是 page_b,右半部分是 page_a