UNPKG

@thi.ng/text-canvas

Version:

Text based canvas, drawing, plotting, tables with arbitrary formatting (incl. ANSI/HTML)

52 lines 2.5 kB
import { type Fn0, type ICopy, type IGrid2D, type NumOrString, type IEmpty, type IClear } from "@thi.ng/api"; import { type ClipRect, type StrokeStyle } from "./api.js"; export declare class Canvas implements IClear, ICopy<Canvas>, IEmpty<Canvas>, IGrid2D<Uint32Array, number> { data: Uint32Array; size: [number, number]; stride: [number, number]; format: number; defaultFormat: number; styles: StrokeStyle[]; clipRects: ClipRect[]; constructor(width: number, height: number, format?: number, style?: StrokeStyle); get width(): number; get height(): number; get offset(): number; get dim(): 2; copy(): Canvas; empty(): Canvas; clear(): void; order(): number[]; includes(d0: number, d1: number): boolean; indexAt(d0: number, d1: number): number; indexAtUnsafe(d0: number, d1: number): number; getAt(x: number, y: number): number; getAtUnsafe(x: number, y: number): number; setAt(x: number, y: number, val: NumOrString): boolean; setAtUnsafe(x: number, y: number, col: number): boolean; } export declare const canvas: (width: number, height: number, format?: number, style?: StrokeStyle) => Canvas; /** * Creates and returns a new {@link Canvas} from given string/lines array and * optional default `format` and/or initial `fill` value. * * @remarks * The canvas will use the longest line width as its width and the length of the * source array as height. * * @param lines * @param format * @param fill */ export declare const canvasFromText: (lines: string[], format?: number, fill?: NumOrString) => Canvas; export declare const beginClip: (canvas: Canvas, x: number, y: number, w: number, h: number) => void; export declare const endClip: (canvas: Canvas) => any; export declare const withClip: (canvas: Canvas, x: number, y: number, w: number, h: number, fn: Fn0<any>) => void; export declare const beginStyle: (canvas: Canvas, style: StrokeStyle) => void; export declare const endStyle: (canvas: Canvas) => any; export declare const withStyle: (canvas: Canvas, style: StrokeStyle, fn: Fn0<any>) => void; export declare const setFormat: (canvas: Canvas, format: number) => number; export declare const withFormat: (canvas: Canvas, format: number, fn: Fn0<any>) => void; export declare const getAt: (canvas: Canvas, x: number, y: number) => number; export declare const setAt: (canvas: Canvas, x: number, y: number, code: NumOrString, format?: number) => void; //# sourceMappingURL=canvas.d.ts.map