Malison is a small Dart library for drawing old school ASCII terminals in
the browser. I harvested it from my roguelike game, Hauberk and it's aimed
primarily at web games ASCII graphics. Think of it like curses for the web.
Using it
Add it to your package's pubspec:
dependencies:
malison: any
Then use the library:
import 'dart:html';
import 'package:malison/malison.dart';
void main() {
var canvas = new CanvasElement();
document.body.children.add(canvas);
var terminal = new RetroTerminal.dos(80, 40, canvas);
terminal.writeAt(0, 0, "This is a terminal!");
terminal.writeAt(0, 1, "This is blue on green", Color.blue, Color.green);
terminal.drawGlyph(3, 4, new Glyph.fromCharCode(CharCode.blackHeartSuit,
Color.red, Color.white));
terminal.render();
}
Example
The repo includes a little example web application so you can see it in action.
From the root of repo, run:
$ dart run build_runner serve
Then in your browser of choice, navigate to http://localhost:8080.