malwoden
Version:
   
54 lines (53 loc) • 1.69 kB
TypeScript
import { TerminalConfig, BaseTerminal } from "./terminal";
import { Display } from "./display";
import { Glyph } from "./glyph";
import { Vector2 } from "../struct/vector";
export declare class Font {
readonly family: string;
readonly size: number;
constructor(family: string, size: number);
}
interface CanvasTerminalConfig extends TerminalConfig {
font: Font;
mountNode?: HTMLElement;
}
/**
* Renders a display by writing fonts to a canvas.
*/
export declare class CanvasTerminal extends BaseTerminal {
readonly display: Display;
private readonly canvas;
private readonly context;
readonly font: Font;
readonly scale: number;
private charWidth;
private lineHeight;
/**
* Creates a new CanvasTerminal.
*
* @param config - The config for the CanvasTerminal
* @param config.width - The width of the terminal in characters.
* @param config.height - The height of the terminal in characters.
* @param config.font Font - A font object
* @param config.mountNode - Will mount the canvas as a child of this node if provided.
*/
constructor(config: CanvasTerminalConfig);
/**
* Draws a glyph on the display.
*
* @param pos Vector2 - Position of the Glyph
* @param glyph Glyph - The Glyph to render
*/
drawGlyph(pos: Vector2, glyph: Glyph): void;
/**
* Renders the display to the canvas.
* Usually drawn once per animation frame.
*/
render(): void;
windowToTilePoint(pixel: Vector2): Vector2;
/**
* Deletes the terminal, removing the canvas.
*/
delete(): void;
}
export {};