Skip to content

Latest commit

 

History

History
52 lines (43 loc) · 1.19 KB

File metadata and controls

52 lines (43 loc) · 1.19 KB

animation

动画格式

[line1, line2, line3] 每个元素是一行, 整个数组是一帧

固定形式

let term = $("body").terminal({});
term.echo(
  new $.terminal.FramesAnimation(
    [
      [".", "|", "."],
      [" .", " |", " ."],
      ["  .", "  |", "  ."],
      [" .", " |", " ."],
      [".", "|", "."],
    ],
    8
  )
);

8: 代表帧率, 如果是 60, 则会运行得非常的快(动画的速度是与帧率相关的)

动态生成

let term = $("body").terminal({});
class BarAnimation extends $.terminal.Animation {
  constructor(...args) {
    super(...args);
    this._i = 0;
  }
  render(term) {
    if (this._i > term.cols()) {
      this._i = 0;
    } else {
      this._i++;
    }
    return ["-".repeat(this._i), `${this._i}`];
  }
}
term.echo(new BarAnimation(50));