RetroTerminal constructor
RetroTerminal(})
Creates a new terminal using a font image at imageUrl.
Implementation
factory RetroTerminal(
int width,
int height,
String imageUrl, {
web.HTMLCanvasElement? canvas,
required int charWidth,
required int charHeight,
int? scale,
}) {
scale ??= web.window.devicePixelRatio.toInt();
// If not given a canvas, create one, automatically size it, and add it to
// the page.
if (canvas == null) {
canvas = web.HTMLCanvasElement();
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';
web.document.body!.append(canvas);
}
var display = Display(width, height);
var image = web.HTMLImageElement();
image.src = imageUrl;
return RetroTerminal._(
display,
charWidth,
charHeight,
canvas,
image,
scale,
);
}