Skip to main content

BufferTransition

Trait BufferTransition 

Source
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

Required Methods§

Source

fn transition( &self, from: &Buffer, to: &Buffer, dst: &mut Buffer, progress: f32, )

执行页面转场

§Parameters
  • from: 起始页面 Buffer
  • to: 目标页面 Buffer
  • dst: 输出 Buffer
  • progress: 转场进度 (0.0 = 全部显示from, 1.0 = 全部显示to)
Source

fn name(&self) -> &'static str

获取转场名称

Implementors§