griddle

Griddle 简化了在2D矩阵或网格中创建2D游戏或UI应用程序的概念,因此它成为适用于低保真度游戏或应用程序的跨平台图形框架。

On pub.dev Code coverage Github action status Dartdocs Style guide

受到启发

目的

创建在终端(或终端模拟器)中运行的简单2D程序很复杂。griddle的目标是将类终端屏幕抽象化为一个字符单元的2D网格

termpixels一样,该项目使终端更加易于访问和有趣,但它是用Dart实现的!

注意:要了解有关griddle设计的更多信息,请参阅DESIGN.md

用法

Example app running

import 'dart:math' as math;

import 'package:griddle/griddle.dart';

void main() {
  final screen = Screen.terminal(Terminal.usingAnsiStdio());
  const string = 'Hello World, from Griddle for Dart!';

  screen.onFrame.listen((_) {
    screen.clear();

    for (var i = 0; i < string.length; i++) {
      final t = DateTime.now().millisecondsSinceEpoch / 1000;
      final f = i / string.length;
      final c = Color.fromHSL(f * 300 + t, 1, 0.5);
      final x = screen.width ~/ 2 - string.length ~/ 2;
      final o = math.sin(t * 3 + f * 5) * 2;
      final y = (screen.height / 2 + o).round();

      screen.print(string[i], x + i, y, foreground: c);
    }

    screen.update();
  });
}

(有关完整示例,请参阅example/example.dart

贡献

本软件包欢迎新的问题拉取请求

不符合以下标准的更改或请求将被拒绝

  1. 贡献者公约描述的共同体面。
  2. 使此库脆弱/难以被其他库扩展。
  3. 添加特定于平台的函数。
  4. 一个有些随意的“复杂性”标准,一切都应易于使用

GitHub

查看 Github