textmode.js 0.3.2-beta.1 → 0.3.2-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/textmode.esm.js +850 -746
- package/dist/textmode.esm.min.js +869 -765
- package/dist/textmode.umd.js +6 -6
- package/dist/textmode.umd.min.js +7 -7
- package/dist/types/export/index.d.ts +0 -2
- package/dist/types/export/svg/SVGPathGenerator.d.ts +2 -9
- package/dist/types/index.d.ts +2 -0
- package/dist/types/textmode/Textmodifier.d.ts +5 -29
- package/dist/types/textmode/font/TextmodeFont.d.ts +10 -1
- package/dist/types/textmode/mixins/index.d.ts +0 -1
- package/dist/types/textmode/plugins/PluginManager.d.ts +45 -0
- package/package.json +3 -3
- package/dist/types/export/image/ImageContentGenerator.d.ts +0 -27
- package/dist/types/export/image/ImageDataExtractor.d.ts +0 -16
- package/dist/types/export/image/ImageExporter.d.ts +0 -38
- package/dist/types/export/image/ImageFileHandler.d.ts +0 -27
- package/dist/types/export/image/index.d.ts +0 -6
- package/dist/types/export/image/types.d.ts +0 -62
- package/dist/types/export/txt/TXTContentGenerator.d.ts +0 -14
- package/dist/types/export/txt/TXTDataExtractor.d.ts +0 -19
- package/dist/types/export/txt/TXTExporter.d.ts +0 -31
- package/dist/types/export/txt/TXTFileHandler.d.ts +0 -19
- package/dist/types/export/txt/index.d.ts +0 -5
- package/dist/types/export/txt/types.d.ts +0 -55
- package/dist/types/textmode/mixins/ExportMixin.d.ts +0 -128
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Textmodifier } from '../Textmodifier';
|
|
2
|
+
import type { GLRenderer } from '../../rendering/webgl/Renderer';
|
|
3
|
+
import type { GLFramebuffer } from '../../rendering';
|
|
4
|
+
import type { TextmodeFont } from '../font';
|
|
5
|
+
import type { TextmodeGrid } from '../Grid';
|
|
6
|
+
import type { TextmodeCanvas } from '../Canvas';
|
|
7
|
+
export type TextmodePluginHook = () => void;
|
|
8
|
+
export interface TextmodePluginContext {
|
|
9
|
+
readonly renderer: GLRenderer;
|
|
10
|
+
readonly font: TextmodeFont;
|
|
11
|
+
readonly grid: TextmodeGrid;
|
|
12
|
+
readonly canvas: TextmodeCanvas;
|
|
13
|
+
readonly drawFramebuffer: GLFramebuffer;
|
|
14
|
+
readonly asciiFramebuffer: GLFramebuffer;
|
|
15
|
+
flushDrawCommands(): void;
|
|
16
|
+
}
|
|
17
|
+
export interface TextmodePluginAPI extends TextmodePluginContext {
|
|
18
|
+
registerPreDrawHook(callback: TextmodePluginHook): () => void;
|
|
19
|
+
registerPostDrawHook(callback: TextmodePluginHook): () => void;
|
|
20
|
+
}
|
|
21
|
+
export interface TextmodePlugin {
|
|
22
|
+
name: string;
|
|
23
|
+
version?: string;
|
|
24
|
+
install(textmodifier: Textmodifier, api: TextmodePluginAPI): void | Promise<void>;
|
|
25
|
+
uninstall?(textmodifier: Textmodifier, api: TextmodePluginAPI): void | Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
export declare class PluginManager {
|
|
28
|
+
private readonly _textmodifier;
|
|
29
|
+
private readonly _plugins;
|
|
30
|
+
private readonly _installationOrder;
|
|
31
|
+
private readonly _preDrawHooks;
|
|
32
|
+
private readonly _postDrawHooks;
|
|
33
|
+
constructor(textmodifier: Textmodifier);
|
|
34
|
+
installMany(plugins: TextmodePlugin[]): Promise<void>;
|
|
35
|
+
use(plugin: TextmodePlugin): Promise<void>;
|
|
36
|
+
unuse(pluginName: string): Promise<void>;
|
|
37
|
+
has(pluginName: string): boolean;
|
|
38
|
+
runPreDrawHooks(): void;
|
|
39
|
+
runPostDrawHooks(): void;
|
|
40
|
+
disposeAll(): Promise<void>;
|
|
41
|
+
private _createAPI;
|
|
42
|
+
private _registerHook;
|
|
43
|
+
private _removePluginHooks;
|
|
44
|
+
private _runHooks;
|
|
45
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "textmode.js",
|
|
3
|
-
"version": "0.3.2-beta.
|
|
3
|
+
"version": "0.3.2-beta.3",
|
|
4
4
|
"description": "textmode.js is a lightweight creative coding library for creating real-time ASCII art on the web.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"build": "vite build && vite build --mode min && tsc",
|
|
24
24
|
"build:full": "vite build && tsc",
|
|
25
25
|
"build:min": "vite build --mode min && tsc",
|
|
26
|
-
"build
|
|
27
|
-
"dev
|
|
26
|
+
"build:docs": "typedoc",
|
|
27
|
+
"dev:docs": "typedoc --watch",
|
|
28
28
|
"preview": "vite preview",
|
|
29
29
|
"test": "vitest",
|
|
30
30
|
"test:ui": "vitest --ui",
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { ImageGenerationOptions } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Content generator for image export.
|
|
4
|
-
* Handles the conversion of canvas data to different image formats.
|
|
5
|
-
*/
|
|
6
|
-
export declare class ImageContentGenerator {
|
|
7
|
-
/**
|
|
8
|
-
* Generates image data from canvas
|
|
9
|
-
* @param canvas The canvas containing the image data
|
|
10
|
-
* @param options Generation options with format, quality, etc.
|
|
11
|
-
* @returns Data URL string containing the image data
|
|
12
|
-
*/
|
|
13
|
-
$generateImageData(canvas: HTMLCanvasElement, options: ImageGenerationOptions): string;
|
|
14
|
-
/**
|
|
15
|
-
* Generates image blob from canvas
|
|
16
|
-
* @param canvas The canvas containing the image data
|
|
17
|
-
* @param options Generation options with format, quality, etc.
|
|
18
|
-
* @returns Promise that resolves to a Blob containing the image data
|
|
19
|
-
*/
|
|
20
|
-
$generateImageBlob(canvas: HTMLCanvasElement, options: ImageGenerationOptions): Promise<Blob>;
|
|
21
|
-
/**
|
|
22
|
-
* Gets the MIME type for a given image format
|
|
23
|
-
* @param format The image format
|
|
24
|
-
* @returns The corresponding MIME type
|
|
25
|
-
*/
|
|
26
|
-
private _getMimeType;
|
|
27
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { TextmodeCanvas } from '../../index';
|
|
2
|
-
import { DataExtractor } from '../base/DataExtractor';
|
|
3
|
-
/**
|
|
4
|
-
* Data extractor for image export.
|
|
5
|
-
* Captures the current visual state of the textmode canvas for image generation.
|
|
6
|
-
*/
|
|
7
|
-
export declare class ImageDataExtractor extends DataExtractor {
|
|
8
|
-
/**
|
|
9
|
-
* Captures the current state of the textmode canvas as image data
|
|
10
|
-
* @param canvas The canvas data containing the rendered textmode graphics
|
|
11
|
-
* @param scale Scale factor for the output image
|
|
12
|
-
* @param backgroundColor Background color for formats that don't support transparency
|
|
13
|
-
* @returns Canvas element containing the captured image data
|
|
14
|
-
*/
|
|
15
|
-
$captureCanvasData(canvas: TextmodeCanvas, scale?: number, backgroundColor?: string): HTMLCanvasElement;
|
|
16
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { ImageExportOptions, ImageGenerationOptions } from './types';
|
|
2
|
-
import type { TextmodeCanvas } from '../../index';
|
|
3
|
-
/**
|
|
4
|
-
* Main image exporter for the textmode.js library.
|
|
5
|
-
* Orchestrates the image export process by coordinating canvas capture,
|
|
6
|
-
* format conversion, and file handling.
|
|
7
|
-
*/
|
|
8
|
-
export declare class ImageExporter {
|
|
9
|
-
private _dataExtractor;
|
|
10
|
-
private _contentGenerator;
|
|
11
|
-
private _fileHandler;
|
|
12
|
-
constructor();
|
|
13
|
-
/**
|
|
14
|
-
* Applies default values to image export options
|
|
15
|
-
* @param options User-provided options
|
|
16
|
-
* @returns Complete options with defaults applied
|
|
17
|
-
*/
|
|
18
|
-
private _applyDefaultOptions;
|
|
19
|
-
/**
|
|
20
|
-
* Validates export options and browser support
|
|
21
|
-
* @param options The options to validate
|
|
22
|
-
* @throws Error if options are invalid or format is not supported
|
|
23
|
-
*/
|
|
24
|
-
private _validateOptions;
|
|
25
|
-
/**
|
|
26
|
-
* Generates image blob from textmode rendering without saving to file
|
|
27
|
-
* @param canvasData The canvas data containing the rendered textmode graphics
|
|
28
|
-
* @param options Export options
|
|
29
|
-
* @returns Promise that resolves to a Blob containing the image data
|
|
30
|
-
*/
|
|
31
|
-
$generateImageBlob(canvas: TextmodeCanvas, options: ImageGenerationOptions): Promise<Blob>;
|
|
32
|
-
/**
|
|
33
|
-
* Exports image to a downloadable file
|
|
34
|
-
* @param canvas The canvas data containing the rendered textmode graphics
|
|
35
|
-
* @param options Export options
|
|
36
|
-
*/
|
|
37
|
-
$saveImage(canvas: TextmodeCanvas, options?: ImageExportOptions): Promise<void>;
|
|
38
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { FileHandler } from '../base/FileHandler';
|
|
2
|
-
import type { ImageFormat } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* File handler for image export operations.
|
|
5
|
-
* Manages saving image files to disk with proper MIME types and extensions.
|
|
6
|
-
*/
|
|
7
|
-
export declare class ImageFileHandler extends FileHandler {
|
|
8
|
-
/**
|
|
9
|
-
* Saves image content as a downloadable file
|
|
10
|
-
* @param content The image content (data URL or blob)
|
|
11
|
-
* @param filename The filename (without extension)
|
|
12
|
-
* @param format The image format
|
|
13
|
-
*/
|
|
14
|
-
$saveImage(content: Blob, filename: string, format: ImageFormat): void;
|
|
15
|
-
/**
|
|
16
|
-
* Saves image from blob
|
|
17
|
-
* @param blob The blob containing image data
|
|
18
|
-
* @param filename The complete filename with extension
|
|
19
|
-
*/
|
|
20
|
-
private _saveImageFromBlob;
|
|
21
|
-
/**
|
|
22
|
-
* Validates if the browser supports saving files in the specified format
|
|
23
|
-
* @param format The image format to validate
|
|
24
|
-
* @returns True if the format is supported for saving
|
|
25
|
-
*/
|
|
26
|
-
$validateSaveSupport(format: ImageFormat): boolean;
|
|
27
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { ImageExporter } from './ImageExporter';
|
|
2
|
-
export { ImageDataExtractor } from './ImageDataExtractor';
|
|
3
|
-
export { ImageContentGenerator } from './ImageContentGenerator';
|
|
4
|
-
export { ImageFileHandler } from './ImageFileHandler';
|
|
5
|
-
export type { ImageExportOptions, ImageGenerationOptions, ImageFormat, } from './types';
|
|
6
|
-
export { IMAGE_MIME_TYPES, IMAGE_EXTENSIONS } from './types';
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Image-specific type definitions for the textmode.js library.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Supported image formats for export.
|
|
6
|
-
*/
|
|
7
|
-
export type ImageFormat = 'png' | 'jpg' | 'webp';
|
|
8
|
-
/**
|
|
9
|
-
* Options for exporting the textmode content to image format.
|
|
10
|
-
*/
|
|
11
|
-
export type ImageExportOptions = {
|
|
12
|
-
/**
|
|
13
|
-
* The filename to save the image file as (without extension).
|
|
14
|
-
*/
|
|
15
|
-
filename?: string;
|
|
16
|
-
/**
|
|
17
|
-
* The image format to export (`'png'`, `'jpg'`, or `'webp'`).
|
|
18
|
-
*/
|
|
19
|
-
format?: 'png' | 'jpg' | 'webp';
|
|
20
|
-
/**
|
|
21
|
-
* Image quality for lossy formats (`'jpg'`, `'webp'`).
|
|
22
|
-
*
|
|
23
|
-
* Range: `0.0` to `1.0`, where `1.0` is highest quality.
|
|
24
|
-
*
|
|
25
|
-
* Default is `1.0`. Ignored for `'png'` format.
|
|
26
|
-
*/
|
|
27
|
-
quality?: number;
|
|
28
|
-
/**
|
|
29
|
-
* Scale factor for the output image.
|
|
30
|
-
*
|
|
31
|
-
* `1.0` = original size, `2.0` = double size, `0.5` = half size.
|
|
32
|
-
*
|
|
33
|
-
* Default is `1.0`.
|
|
34
|
-
*/
|
|
35
|
-
scale?: number;
|
|
36
|
-
/**
|
|
37
|
-
* Background color for formats that don't support transparency (`'jpg'`).
|
|
38
|
-
*
|
|
39
|
-
* **Format:** CSS color string.
|
|
40
|
-
*
|
|
41
|
-
* Default is `'black'`.
|
|
42
|
-
*/
|
|
43
|
-
backgroundColor?: string;
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* Internal options used by image generation (with all defaults applied).
|
|
47
|
-
*/
|
|
48
|
-
export interface ImageGenerationOptions {
|
|
49
|
-
filename: string;
|
|
50
|
-
format: ImageFormat;
|
|
51
|
-
quality: number;
|
|
52
|
-
scale: number;
|
|
53
|
-
backgroundColor: string;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* MIME type mapping for image formats.
|
|
57
|
-
*/
|
|
58
|
-
export declare const IMAGE_MIME_TYPES: Record<ImageFormat, string>;
|
|
59
|
-
/**
|
|
60
|
-
* File extension mapping for image formats.
|
|
61
|
-
*/
|
|
62
|
-
export declare const IMAGE_EXTENSIONS: Record<ImageFormat, string>;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { TXTGenerationOptions } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Generates TXT content from character grid data.
|
|
4
|
-
* This class handles the conversion of character arrays into formatted text strings.
|
|
5
|
-
*/
|
|
6
|
-
export declare class TXTContentGenerator {
|
|
7
|
-
/**
|
|
8
|
-
* Generates TXT content from a 2D character array
|
|
9
|
-
* @param characterGrid 2D array of characters (rows x columns)
|
|
10
|
-
* @param options Generation options
|
|
11
|
-
* @returns TXT content as string
|
|
12
|
-
*/
|
|
13
|
-
$generateTXTContent(characterGrid: string[][], options: TXTGenerationOptions): string;
|
|
14
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { FramebufferData } from './types';
|
|
2
|
-
import { DataExtractor } from '../base';
|
|
3
|
-
import type { TextmodeGrid } from '../../textmode/Grid';
|
|
4
|
-
import type { TextmodeFont } from '../../textmode/font';
|
|
5
|
-
/**
|
|
6
|
-
* Extracts and processes data from framebuffers for TXT generation.
|
|
7
|
-
* This class handles the conversion of raw pixel data into character arrays.
|
|
8
|
-
*/
|
|
9
|
-
export declare class TXTDataExtractor extends DataExtractor {
|
|
10
|
-
/**
|
|
11
|
-
* Extracts character data for TXT generation
|
|
12
|
-
* @param framebufferData Framebuffer pixel data
|
|
13
|
-
* @param grid Grid information
|
|
14
|
-
* @param font Font information
|
|
15
|
-
* @param emptyCharacter Character to use for empty cells
|
|
16
|
-
* @returns 2D array of characters (rows x columns)
|
|
17
|
-
*/
|
|
18
|
-
$extractCharacterGrid(framebufferData: FramebufferData, grid: TextmodeGrid, font: TextmodeFont, emptyCharacter?: string): string[][];
|
|
19
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { TXTExportOptions, TextmodeRenderingData } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Main TXT exporter for the textmode.js library.
|
|
4
|
-
* Orchestrates the TXT export process by coordinating data extraction,
|
|
5
|
-
* content generation, and file handling.
|
|
6
|
-
*/
|
|
7
|
-
export declare class TXTExporter {
|
|
8
|
-
private _dataExtractor;
|
|
9
|
-
private _contentGenerator;
|
|
10
|
-
private _fileHandler;
|
|
11
|
-
constructor();
|
|
12
|
-
/**
|
|
13
|
-
* Applies default values to TXT export options
|
|
14
|
-
* @param options User-provided options
|
|
15
|
-
* @returns Complete options with defaults applied
|
|
16
|
-
*/
|
|
17
|
-
private _applyDefaultOptions;
|
|
18
|
-
/**
|
|
19
|
-
* Generates TXT content from textmode rendering data without saving to file
|
|
20
|
-
* @param renderingData The textmode rendering data containing pipeline, grid, and font
|
|
21
|
-
* @param options Export options (excluding filename)
|
|
22
|
-
* @returns TXT content as string
|
|
23
|
-
*/
|
|
24
|
-
$generateTXT(renderingData: TextmodeRenderingData, options?: TXTExportOptions): string;
|
|
25
|
-
/**
|
|
26
|
-
* Exports TXT content to a downloadable file
|
|
27
|
-
* @param renderingData The textmode rendering data containing pipeline, grid, and font
|
|
28
|
-
* @param options Export options including filename
|
|
29
|
-
*/
|
|
30
|
-
$saveTXT(renderingData: TextmodeRenderingData, options?: TXTExportOptions): void;
|
|
31
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { FileHandler } from '../base/FileHandler.js';
|
|
2
|
-
/**
|
|
3
|
-
* Handles file operations for TXT export.
|
|
4
|
-
* This class manages the saving of TXT content to downloadable files.
|
|
5
|
-
*/
|
|
6
|
-
export declare class TXTFileHandler extends FileHandler {
|
|
7
|
-
/**
|
|
8
|
-
* Saves TXT content as a downloadable file
|
|
9
|
-
* @param content The TXT content to save
|
|
10
|
-
* @param filename The filename to use for the download
|
|
11
|
-
*/
|
|
12
|
-
$saveTXT(content: string, filename: string): void;
|
|
13
|
-
/**
|
|
14
|
-
* Ensures filename has proper extension and is valid
|
|
15
|
-
* @param filename The filename to validate and fix
|
|
16
|
-
* @returns Valid filename with .txt extension
|
|
17
|
-
*/
|
|
18
|
-
private _ensureValidFilename;
|
|
19
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { TXTExporter } from './TXTExporter';
|
|
2
|
-
export { TXTDataExtractor } from './TXTDataExtractor';
|
|
3
|
-
export { TXTContentGenerator } from './TXTContentGenerator';
|
|
4
|
-
export { TXTFileHandler } from './TXTFileHandler';
|
|
5
|
-
export type { TXTExportOptions, TXTGenerationOptions, FramebufferData } from './types';
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TXT-specific type definitions for the textmode.js library.
|
|
3
|
-
*/
|
|
4
|
-
import type { TextmodeFont, TextmodeGrid } from '../..';
|
|
5
|
-
/**
|
|
6
|
-
* Options for exporting the textmode content to TXT format.
|
|
7
|
-
*/
|
|
8
|
-
export type TXTExportOptions = {
|
|
9
|
-
/**
|
|
10
|
-
* The filename to save the TXT file as.
|
|
11
|
-
*
|
|
12
|
-
* If not provided, a default filename is used.
|
|
13
|
-
*/
|
|
14
|
-
filename?: string;
|
|
15
|
-
/**
|
|
16
|
-
* Whether to preserve trailing spaces on each line.
|
|
17
|
-
*
|
|
18
|
-
* When `false`, trailing spaces are trimmed from each line.
|
|
19
|
-
*
|
|
20
|
-
* Default is `false`.
|
|
21
|
-
*/
|
|
22
|
-
preserveTrailingSpaces?: boolean;
|
|
23
|
-
/**
|
|
24
|
-
* The line ending format to use *(`'lf'` for Unix/Linux, `'crlf'` for Windows)*.
|
|
25
|
-
*
|
|
26
|
-
* Default is `'lf'`.
|
|
27
|
-
*/
|
|
28
|
-
lineEnding?: 'lf' | 'crlf';
|
|
29
|
-
/**
|
|
30
|
-
* Character to use for empty cells *(when no character is rendered)*.
|
|
31
|
-
* Default is a space `' '`.
|
|
32
|
-
*/
|
|
33
|
-
emptyCharacter?: string;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Internal options used by TXT generation (with all defaults applied).
|
|
37
|
-
*/
|
|
38
|
-
export interface TXTGenerationOptions {
|
|
39
|
-
preserveTrailingSpaces: boolean;
|
|
40
|
-
lineEnding: 'lf' | 'crlf';
|
|
41
|
-
emptyCharacter: string;
|
|
42
|
-
filename: string;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Data required for textmode rendering export
|
|
46
|
-
*/
|
|
47
|
-
export interface TextmodeRenderingData {
|
|
48
|
-
pipeline: any;
|
|
49
|
-
grid: TextmodeGrid;
|
|
50
|
-
font: TextmodeFont;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Re-export shared types from SVG module that are also used by TXT exporter
|
|
54
|
-
*/
|
|
55
|
-
export type { FramebufferData } from '../svg/types';
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import type { Mixin } from './TextmodifierMixin';
|
|
2
|
-
import { type SVGExportOptions } from '../../export/svg';
|
|
3
|
-
import { type TXTExportOptions } from '../../export/txt';
|
|
4
|
-
import { type ImageExportOptions } from '../../export/image';
|
|
5
|
-
/**
|
|
6
|
-
* Interface for export capabilities that will be mixed into Textmodifier
|
|
7
|
-
*/
|
|
8
|
-
export interface ExportCapabilities {
|
|
9
|
-
/**
|
|
10
|
-
* Generate the current textmode rendering as a text string.
|
|
11
|
-
* @param options Options for text generation *(excluding filename)*
|
|
12
|
-
* @returns Textmode grid content as a string.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```javascript
|
|
16
|
-
* // Fetch a canvas element to apply textmode rendering to
|
|
17
|
-
* const canvas = document.querySelector('canvas#myCanvas');
|
|
18
|
-
*
|
|
19
|
-
* // Create a Textmodifier instance
|
|
20
|
-
* const textmodifier = textmode.create(canvas, {renderMode: 'manual'});
|
|
21
|
-
*
|
|
22
|
-
* // Get the current rendering as a text string
|
|
23
|
-
* const textString = textmodifier.toString({
|
|
24
|
-
* preserveTrailingSpaces: false,
|
|
25
|
-
* lineEnding: 'lf'
|
|
26
|
-
* });
|
|
27
|
-
*
|
|
28
|
-
* // Print to console or use otherwise
|
|
29
|
-
* console.log(textString);
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
toString(options?: TXTExportOptions): string;
|
|
33
|
-
/**
|
|
34
|
-
* Export the current textmode rendering to a TXT file.
|
|
35
|
-
* @param options Options for TXT export
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```javascript
|
|
39
|
-
* // Fetch a canvas element to apply textmode rendering to
|
|
40
|
-
* const canvas = document.querySelector('canvas#myCanvas');
|
|
41
|
-
*
|
|
42
|
-
* // Create a Textmodifier instance
|
|
43
|
-
* const textmodifier = textmode.create(canvas, {renderMode: 'manual'});
|
|
44
|
-
*
|
|
45
|
-
* // Export the current rendering to a TXT file
|
|
46
|
-
* textmodifier.saveStrings({
|
|
47
|
-
* filename: 'my_textmode_rendering',
|
|
48
|
-
* preserveTrailingSpaces: false
|
|
49
|
-
* });
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
saveStrings(options?: TXTExportOptions): void;
|
|
53
|
-
/**
|
|
54
|
-
* Generate the current textmode rendering as an SVG string.
|
|
55
|
-
* @param options Options for SVG generation *(excluding filename)*
|
|
56
|
-
* @returns SVG content as a string.
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* ```javascript
|
|
60
|
-
* // Fetch a canvas element to apply textmode rendering to
|
|
61
|
-
* const canvas = document.querySelector('canvas#myCanvas');
|
|
62
|
-
*
|
|
63
|
-
* // Create a Textmodifier instance
|
|
64
|
-
* const textmodifier = textmode.create(canvas, {renderMode: 'manual'});
|
|
65
|
-
*
|
|
66
|
-
* // Get the current rendering as an SVG string
|
|
67
|
-
* const svgString = textmodifier.toSVG({
|
|
68
|
-
* includeBackgroundRectangles: true,
|
|
69
|
-
* drawMode: 'fill'
|
|
70
|
-
* });
|
|
71
|
-
*
|
|
72
|
-
* // Print to console or use otherwise
|
|
73
|
-
* console.log(svgString);
|
|
74
|
-
* ```
|
|
75
|
-
*/
|
|
76
|
-
toSVG(options?: SVGExportOptions): string;
|
|
77
|
-
/**
|
|
78
|
-
* Export the current textmode rendering to an SVG file.
|
|
79
|
-
* @param options Options for SVG export
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* ```javascript
|
|
83
|
-
* // Fetch a canvas element to apply textmode rendering to
|
|
84
|
-
* const canvas = document.querySelector('canvas#myCanvas');
|
|
85
|
-
*
|
|
86
|
-
* // Create a Textmodifier instance
|
|
87
|
-
* const textmodifier = textmode.create(canvas, {renderMode: 'manual'});
|
|
88
|
-
*
|
|
89
|
-
* // Export the current rendering to an SVG file
|
|
90
|
-
* textmodifier.saveSVG({
|
|
91
|
-
* filename: 'my_textmode_rendering',
|
|
92
|
-
* });
|
|
93
|
-
* ```
|
|
94
|
-
*/
|
|
95
|
-
saveSVG(options?: SVGExportOptions): void;
|
|
96
|
-
/**
|
|
97
|
-
* Export the current textmode rendering to an image file.
|
|
98
|
-
* @param options Options for image export
|
|
99
|
-
*
|
|
100
|
-
* @example
|
|
101
|
-
* ```javascript
|
|
102
|
-
* // Fetch a canvas element to apply textmode rendering to
|
|
103
|
-
* const canvas = document.querySelector('canvas#myCanvas');
|
|
104
|
-
*
|
|
105
|
-
* // Create a Textmodifier instance
|
|
106
|
-
* const textmodifier = textmode.create(canvas, {renderMode: 'manual'});
|
|
107
|
-
*
|
|
108
|
-
* // Export the current rendering to a PNG file *(default)*
|
|
109
|
-
* textmodifier.saveCanvas();
|
|
110
|
-
*
|
|
111
|
-
* // Export with custom options
|
|
112
|
-
* textmodifier.saveCanvas({
|
|
113
|
-
* filename: 'my_textmode_rendering',
|
|
114
|
-
* format: 'jpg',
|
|
115
|
-
* quality: 0.8,
|
|
116
|
-
* scale: 2.0,
|
|
117
|
-
* backgroundColor: 'white'
|
|
118
|
-
* });
|
|
119
|
-
* ```
|
|
120
|
-
*/
|
|
121
|
-
saveCanvas(options?: ImageExportOptions): Promise<void>;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Mixin that adds export capabilities to a class
|
|
125
|
-
* @param Base The base class to extend
|
|
126
|
-
* @returns Extended class with export capabilities
|
|
127
|
-
*/
|
|
128
|
-
export declare const ExportMixin: Mixin<ExportCapabilities>;
|