RetroTerminal constructor
RetroTerminal(})
Creates a new terminal using a font image at imageUrl
.
Implementation
factory RetroTerminal(int width, int height, String imageUrl,
{html.CanvasElement? canvas,
required int charWidth,
required int charHeight,
int? scale}) {
scale ??= html.window.devicePixelRatio.toInt();
// If not given a canvas, create one, automatically size it, and add it to
// the page.
if (canvas == null) {
canvas = html.CanvasElement();
var canvasWidth = charWidth * width;
var canvasHeight = charHeight * height;
canvas.width = canvasWidth * scale;
canvas.height = canvasHeight * scale;
canvas.style.width = '${canvasWidth}px';
canvas.style.height = '${canvasHeight}px';
html.document.body!.append(canvas);
}
var display = Display(width, height);
return RetroTerminal._(display, charWidth, charHeight, canvas,
html.ImageElement(src: imageUrl), scale);
}