textmode.js 0.3.2-beta.2 → 0.4.0
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/README.md +5 -5
- package/dist/textmode.esm.js +841 -755
- package/dist/textmode.esm.min.js +854 -768
- package/dist/textmode.umd.js +6 -6
- package/dist/textmode.umd.min.js +7 -7
- package/dist/types/index.d.ts +1 -3
- package/dist/types/textmode/Textmodifier.d.ts +5 -43
- package/dist/types/textmode/font/TextmodeFont.d.ts +10 -1
- package/dist/types/textmode/font/typr/types.d.ts +0 -16
- package/dist/types/textmode/mixins/FontMixin.d.ts +2 -2
- package/dist/types/textmode/mixins/index.d.ts +0 -1
- package/dist/types/textmode/plugins/PluginManager.d.ts +76 -0
- package/package.json +3 -3
- package/dist/types/export/base/DataExtractor.d.ts +0 -34
- package/dist/types/export/base/FileHandler.d.ts +0 -46
- package/dist/types/export/base/index.d.ts +0 -2
- 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/index.d.ts +0 -3
- package/dist/types/export/svg/SVGContentGenerator.d.ts +0 -76
- package/dist/types/export/svg/SVGDataExtractor.d.ts +0 -33
- package/dist/types/export/svg/SVGExporter.d.ts +0 -31
- package/dist/types/export/svg/SVGFileHandler.d.ts +0 -25
- package/dist/types/export/svg/SVGPathGenerator.d.ts +0 -56
- package/dist/types/export/svg/index.d.ts +0 -6
- package/dist/types/export/svg/types.d.ts +0 -129
- 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,76 @@
|
|
|
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
|
+
/** The WebGL renderer used by the Textmodifier instance. */
|
|
10
|
+
renderer: GLRenderer;
|
|
11
|
+
/** The font used by the Textmodifier instance. */
|
|
12
|
+
font: TextmodeFont;
|
|
13
|
+
/** The grid used by the Textmodifier instance. */
|
|
14
|
+
grid: TextmodeGrid;
|
|
15
|
+
/** The canvas used by the Textmodifier instance. */
|
|
16
|
+
canvas: TextmodeCanvas;
|
|
17
|
+
/** The framebuffer the user draws to. */
|
|
18
|
+
drawFramebuffer: GLFramebuffer;
|
|
19
|
+
/** The framebuffer containing the ASCII representation. */
|
|
20
|
+
asciiFramebuffer: GLFramebuffer;
|
|
21
|
+
/** Immediately execute any pending draw commands. */
|
|
22
|
+
flushDrawCommands(): void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* An extended API provided to plugins when they are installed on a {@link Textmodifier} instance.
|
|
26
|
+
*/
|
|
27
|
+
export interface TextmodePluginAPI extends TextmodePluginContext {
|
|
28
|
+
/**
|
|
29
|
+
* Register a callback to be invoked before each draw cycle. Happens outside of the draw framebuffer being bound.
|
|
30
|
+
*/
|
|
31
|
+
registerPreDrawHook(callback: () => void): () => void;
|
|
32
|
+
/**
|
|
33
|
+
* Register a callback to be invoked after each draw cycle. Happens outside of the draw framebuffer being bound.
|
|
34
|
+
*/
|
|
35
|
+
registerPostDrawHook(callback: () => void): () => void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A plugin interface for extending the functionality of a {@link Textmodifier} instance.
|
|
39
|
+
*
|
|
40
|
+
* Users can create plugins by implementing this interface.
|
|
41
|
+
*/
|
|
42
|
+
export interface TextmodePlugin {
|
|
43
|
+
/** Unique name for the plugin. */
|
|
44
|
+
name: string;
|
|
45
|
+
/** Version string for the plugin. */
|
|
46
|
+
version?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Called when the plugin is installed on a {@link Textmodifier} instance.
|
|
49
|
+
* @param textmodifier The Textmodifier instance the plugin is being installed on.
|
|
50
|
+
* @param api An API object providing access to the Textmodifier's context and hook registration methods.
|
|
51
|
+
*/
|
|
52
|
+
install(textmodifier: Textmodifier, api: TextmodePluginAPI): void | Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Called when the plugin is uninstalled from a {@link Textmodifier} instance.
|
|
55
|
+
* @param textmodifier The Textmodifier instance the plugin is being uninstalled from.
|
|
56
|
+
* @param api An API object providing access to the Textmodifier's context and hook registration methods.
|
|
57
|
+
*/
|
|
58
|
+
uninstall?(textmodifier: Textmodifier, api: TextmodePluginAPI): void | Promise<void>;
|
|
59
|
+
}
|
|
60
|
+
export declare class TextmodePluginManager {
|
|
61
|
+
private readonly _textmodifier;
|
|
62
|
+
private readonly _plugins;
|
|
63
|
+
private readonly _installationOrder;
|
|
64
|
+
private readonly _preDrawHooks;
|
|
65
|
+
private readonly _postDrawHooks;
|
|
66
|
+
constructor(textmodifier: Textmodifier);
|
|
67
|
+
$installMany(plugins: TextmodePlugin[]): Promise<void>;
|
|
68
|
+
$unuse(pluginName: string): Promise<void>;
|
|
69
|
+
runPreDrawHooks(): void;
|
|
70
|
+
runPostDrawHooks(): void;
|
|
71
|
+
$disposeAll(): Promise<void>;
|
|
72
|
+
private _createAPI;
|
|
73
|
+
private _registerHook;
|
|
74
|
+
private _removePluginHooks;
|
|
75
|
+
private _runHooks;
|
|
76
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "textmode.js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
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,34 +0,0 @@
|
|
|
1
|
-
import type { GLFramebuffer } from '../../rendering';
|
|
2
|
-
import type { FramebufferData } from '../svg/types';
|
|
3
|
-
/**
|
|
4
|
-
* Base class for data extraction from textmode framebuffers.
|
|
5
|
-
* Provides common functionality shared between different export formats.
|
|
6
|
-
*/
|
|
7
|
-
export declare abstract class DataExtractor {
|
|
8
|
-
/**
|
|
9
|
-
* Extracts pixel data from all framebuffers needed for export
|
|
10
|
-
* @param framebuffer The conversion pipeline containing framebuffers
|
|
11
|
-
* @returns Object containing all pixel data arrays
|
|
12
|
-
*/
|
|
13
|
-
$extractFramebufferData(framebuffer: GLFramebuffer): FramebufferData;
|
|
14
|
-
/**
|
|
15
|
-
* Gets character index from character framebuffer pixels
|
|
16
|
-
* @param characterPixels Character framebuffer pixel data
|
|
17
|
-
* @param pixelIndex Index in the pixel array (already multiplied by 4 for RGBA)
|
|
18
|
-
* @param charactersLength Total number of available characters
|
|
19
|
-
* @returns Character index
|
|
20
|
-
*/
|
|
21
|
-
protected _getCharacterIndex(characterPixels: Uint8Array, pixelIndex: number): number;
|
|
22
|
-
/**
|
|
23
|
-
* Converts raw pixel data to RGBA color object
|
|
24
|
-
* @param pixels Pixel data array
|
|
25
|
-
* @param index Pixel index (already multiplied by 4 for RGBA)
|
|
26
|
-
* @returns RGBA color object with r, g, b, a properties
|
|
27
|
-
*/
|
|
28
|
-
protected _pixelsToRGBA(pixels: Uint8Array, index: number): {
|
|
29
|
-
r: number;
|
|
30
|
-
g: number;
|
|
31
|
-
b: number;
|
|
32
|
-
a: number;
|
|
33
|
-
};
|
|
34
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Base class for file handling operations.
|
|
3
|
-
* Provides common functionality for downloading files in the browser.
|
|
4
|
-
*/
|
|
5
|
-
export declare abstract class FileHandler {
|
|
6
|
-
/**
|
|
7
|
-
* Creates a downloadable blob from content
|
|
8
|
-
* @param content The content to include in the blob
|
|
9
|
-
* @param mimeType The MIME type for the blob
|
|
10
|
-
* @returns Blob object containing the content
|
|
11
|
-
*/
|
|
12
|
-
protected _createBlob(content: string, mimeType: string): Blob;
|
|
13
|
-
/**
|
|
14
|
-
* Downloads content as a file
|
|
15
|
-
* @param content The content to download
|
|
16
|
-
* @param filename The filename (with extension)
|
|
17
|
-
* @param mimeType The MIME type for the content
|
|
18
|
-
*/
|
|
19
|
-
protected _downloadFile(content: string, filename: string, mimeType: string): void;
|
|
20
|
-
/**
|
|
21
|
-
* Generates a timestamp string for filenames
|
|
22
|
-
* @returns Formatted timestamp string
|
|
23
|
-
*/
|
|
24
|
-
protected _generateTimestamp(): string;
|
|
25
|
-
/**
|
|
26
|
-
* Generates a date-time string for filenames (alternative format)
|
|
27
|
-
* @returns Formatted date and time string
|
|
28
|
-
*/
|
|
29
|
-
protected _generateDateTimeString(): {
|
|
30
|
-
date: string;
|
|
31
|
-
time: string;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Validates and sanitizes filename for safety and compatibility
|
|
35
|
-
* @param filename The filename to validate
|
|
36
|
-
* @returns Sanitized filename
|
|
37
|
-
*/
|
|
38
|
-
protected _sanitizeFilename(filename: string): string;
|
|
39
|
-
/**
|
|
40
|
-
* Generates a default filename with prefix and timestamp
|
|
41
|
-
* @param prefix The prefix for the filename
|
|
42
|
-
* @param extension The file extension (with dot)
|
|
43
|
-
* @returns Generated filename
|
|
44
|
-
*/
|
|
45
|
-
$generateDefaultFilename(): string;
|
|
46
|
-
}
|
|
@@ -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,76 +0,0 @@
|
|
|
1
|
-
import type { SVGCellData, SVGGenerationOptions } from './types';
|
|
2
|
-
import type { TextmodeFont, TextmodeGrid } from '../../index';
|
|
3
|
-
/**
|
|
4
|
-
* Generates SVG content and markup from processed cell data.
|
|
5
|
-
* This class handles the creation of SVG elements, groups, and styling.
|
|
6
|
-
*/
|
|
7
|
-
export declare class SVGContentGenerator {
|
|
8
|
-
private _pathGenerator;
|
|
9
|
-
constructor();
|
|
10
|
-
/**
|
|
11
|
-
* Generates the SVG header with metadata
|
|
12
|
-
* @param gridInfo Grid dimensions
|
|
13
|
-
* @returns SVG header string
|
|
14
|
-
*/
|
|
15
|
-
$generateSVGHeader(gridInfo: TextmodeGrid): string;
|
|
16
|
-
/**
|
|
17
|
-
* Generates the SVG footer
|
|
18
|
-
* @returns SVG footer string
|
|
19
|
-
*/
|
|
20
|
-
$generateSVGFooter(): string;
|
|
21
|
-
/**
|
|
22
|
-
* Generates background rectangle if needed
|
|
23
|
-
* @param gridInfo Grid information
|
|
24
|
-
* @param options SVG generation options
|
|
25
|
-
* @returns Background rectangle SVG string or empty string
|
|
26
|
-
*/
|
|
27
|
-
$generateBackground(gridInfo: TextmodeGrid, options: SVGGenerationOptions): string;
|
|
28
|
-
/**
|
|
29
|
-
* Generates SVG transform attribute string
|
|
30
|
-
* @param cellData Cell data with transform information
|
|
31
|
-
* @param gridInfo Grid information for center calculations
|
|
32
|
-
* @returns Transform attribute string or empty string
|
|
33
|
-
*/
|
|
34
|
-
private _generateTransformAttribute;
|
|
35
|
-
/**
|
|
36
|
-
* Generates background rectangle for a cell
|
|
37
|
-
* @param cellData Cell data
|
|
38
|
-
* @param gridInfo Grid information
|
|
39
|
-
* @param options SVG generation options
|
|
40
|
-
* @returns Background rectangle SVG string or empty string
|
|
41
|
-
*/
|
|
42
|
-
private _generateCellBackground;
|
|
43
|
-
/**
|
|
44
|
-
* Generates character path element for a cell
|
|
45
|
-
* @param cellData Cell data
|
|
46
|
-
* @param gridInfo Grid information
|
|
47
|
-
* @param fontInfo Font information
|
|
48
|
-
* @param options SVG generation options
|
|
49
|
-
* @returns Character path SVG string
|
|
50
|
-
*/
|
|
51
|
-
private _generateCharacterPath;
|
|
52
|
-
/**
|
|
53
|
-
* Generates complete SVG content for a single cell
|
|
54
|
-
* @param cellData Cell data
|
|
55
|
-
* @param gridInfo Grid information
|
|
56
|
-
* @param fontInfo Font information
|
|
57
|
-
* @param options SVG generation options
|
|
58
|
-
* @returns Complete cell SVG content
|
|
59
|
-
*/
|
|
60
|
-
$generateCellContent(cellData: SVGCellData, gridInfo: TextmodeGrid, fontInfo: TextmodeFont, options: SVGGenerationOptions): string;
|
|
61
|
-
/**
|
|
62
|
-
* Generates the complete SVG content from cell data
|
|
63
|
-
* @param cellDataArray Array of cell data
|
|
64
|
-
* @param grid Grid information
|
|
65
|
-
* @param fontInfo Font information
|
|
66
|
-
* @param options SVG generation options
|
|
67
|
-
* @returns Complete SVG string
|
|
68
|
-
*/
|
|
69
|
-
$generateSVGContent(cellDataArray: SVGCellData[], grid: TextmodeGrid, fontInfo: TextmodeFont, options: SVGGenerationOptions): string;
|
|
70
|
-
/**
|
|
71
|
-
* Optimizes SVG content by removing empty elements and unnecessary whitespace
|
|
72
|
-
* @param svgContent Raw SVG content
|
|
73
|
-
* @returns Optimized SVG content
|
|
74
|
-
*/
|
|
75
|
-
$optimizeSVGContent(svgContent: string): string;
|
|
76
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { FramebufferData, SVGCellData } from './types';
|
|
2
|
-
import { DataExtractor } from '../base';
|
|
3
|
-
import type { TextmodeGrid } from '../../index';
|
|
4
|
-
/**
|
|
5
|
-
* Extracts and processes data from framebuffers for SVG generation.
|
|
6
|
-
* This class handles the conversion of raw pixel data into structured data objects.
|
|
7
|
-
*/
|
|
8
|
-
export declare class SVGDataExtractor extends DataExtractor {
|
|
9
|
-
/**
|
|
10
|
-
* Extracts transform data from transform pixels
|
|
11
|
-
* @param transformPixels Transform framebuffer pixels
|
|
12
|
-
* @param rotationPixels Rotation framebuffer pixels
|
|
13
|
-
* @param pixelIndex Pixel index in the array
|
|
14
|
-
* @returns Transform data object
|
|
15
|
-
*/
|
|
16
|
-
private _extractTransformData;
|
|
17
|
-
/**
|
|
18
|
-
* Calculates cell position information
|
|
19
|
-
* @param x Grid X coordinate
|
|
20
|
-
* @param y Grid Y coordinate
|
|
21
|
-
* @param gridInfo Grid information
|
|
22
|
-
* @returns Position data object
|
|
23
|
-
*/
|
|
24
|
-
private _calculateCellPosition;
|
|
25
|
-
/**
|
|
26
|
-
* Processes all grid cells and extracts SVG cell data
|
|
27
|
-
* @param framebufferData Raw pixel data from framebuffers
|
|
28
|
-
* @param grid Grid information
|
|
29
|
-
* @param font Font information
|
|
30
|
-
* @returns Array of SVG cell data objects
|
|
31
|
-
*/
|
|
32
|
-
$extractSVGCellData(framebufferData: FramebufferData, grid: TextmodeGrid): SVGCellData[];
|
|
33
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { SVGExportOptions, TextmodeRenderingData } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Main SVG exporter for the textmode.js library.
|
|
4
|
-
* Orchestrates the SVG export process by coordinating data extraction,
|
|
5
|
-
* content generation, and file handling.
|
|
6
|
-
*/
|
|
7
|
-
export declare class SVGExporter {
|
|
8
|
-
private _dataExtractor;
|
|
9
|
-
private _contentGenerator;
|
|
10
|
-
private _fileHandler;
|
|
11
|
-
constructor();
|
|
12
|
-
/**
|
|
13
|
-
* Applies default values to SVG export options
|
|
14
|
-
* @param options User-provided options
|
|
15
|
-
* @returns Complete options with defaults applied
|
|
16
|
-
*/
|
|
17
|
-
private _applyDefaultOptions;
|
|
18
|
-
/**
|
|
19
|
-
* Generates SVG 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 SVG content as string
|
|
23
|
-
*/
|
|
24
|
-
$generateSVG(renderingData: TextmodeRenderingData, options?: SVGExportOptions): string;
|
|
25
|
-
/**
|
|
26
|
-
* Exports SVG 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
|
-
$saveSVG(renderingData: TextmodeRenderingData, options?: SVGExportOptions): void;
|
|
31
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { FileHandler } from '../base/FileHandler.js';
|
|
2
|
-
/**
|
|
3
|
-
* Handles SVG file operations including download and save functionality.
|
|
4
|
-
* This class manages the creation of downloadable SVG files and blob handling.
|
|
5
|
-
*/
|
|
6
|
-
export declare class SVGFileHandler extends FileHandler {
|
|
7
|
-
/**
|
|
8
|
-
* Creates a downloadable blob from SVG content
|
|
9
|
-
* @param svgContent The SVG content string
|
|
10
|
-
* @returns Blob object containing the SVG data
|
|
11
|
-
*/
|
|
12
|
-
$createSVGBlob(svgContent: string): Blob;
|
|
13
|
-
/**
|
|
14
|
-
* Downloads SVG content as a file
|
|
15
|
-
* @param svgContent The SVG content to download
|
|
16
|
-
* @param filename The filename (without extension)
|
|
17
|
-
*/
|
|
18
|
-
private _downloadSVG;
|
|
19
|
-
/**
|
|
20
|
-
* Saves SVG content with automatic filename generation if not provided
|
|
21
|
-
* @param svgContent The SVG content to save
|
|
22
|
-
* @param filename Optional filename (will generate if not provided)
|
|
23
|
-
*/
|
|
24
|
-
$saveSVG(svgContent: string, filename?: string): void;
|
|
25
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import type { TyprFont } from '../../textmode/font/typr/types.ts';
|
|
2
|
-
/**
|
|
3
|
-
* Handles SVG path generation for character glyphs.
|
|
4
|
-
* This class is responsible for converting font glyph data into SVG path strings.
|
|
5
|
-
*/
|
|
6
|
-
export declare class SVGPathGenerator {
|
|
7
|
-
/**
|
|
8
|
-
* Gets the glyph index for a given Unicode code point in a Typr.js font
|
|
9
|
-
* @param fontData The Typr.js font data
|
|
10
|
-
* @param codePoint The Unicode code point to look up
|
|
11
|
-
* @returns The glyph index, or 0 if not found
|
|
12
|
-
*/
|
|
13
|
-
private _getGlyphIndex;
|
|
14
|
-
/**
|
|
15
|
-
* Creates a path object for a glyph
|
|
16
|
-
* @param fontData Font data object
|
|
17
|
-
* @param glyphData Glyph data from font
|
|
18
|
-
* @param x X position
|
|
19
|
-
* @param y Y position
|
|
20
|
-
* @param fontSize Font size
|
|
21
|
-
* @returns Path object with bounding box and SVG methods
|
|
22
|
-
*/
|
|
23
|
-
private _createGlyphPath;
|
|
24
|
-
/**
|
|
25
|
-
* Converts glyph data to SVG path string
|
|
26
|
-
* @param glyphData Glyph data from font
|
|
27
|
-
* @param x X position
|
|
28
|
-
* @param y Y position
|
|
29
|
-
* @param scale Scale factor
|
|
30
|
-
* @returns SVG path data string
|
|
31
|
-
*/
|
|
32
|
-
private _glyphToSVGPath;
|
|
33
|
-
/**
|
|
34
|
-
* Generates an SVG path for a character glyph
|
|
35
|
-
* @param character The character to generate a path for
|
|
36
|
-
* @param fontData The font data object
|
|
37
|
-
* @param x X position
|
|
38
|
-
* @param y Y position
|
|
39
|
-
* @param fontSize Font size
|
|
40
|
-
* @returns Path object with SVG generation methods
|
|
41
|
-
*/
|
|
42
|
-
private _generateCharacterPath;
|
|
43
|
-
/**
|
|
44
|
-
* Generates SVG path data for a character with positioning calculations
|
|
45
|
-
* @param character The character to render
|
|
46
|
-
* @param fontData The font data
|
|
47
|
-
* @param cellX Cell X position
|
|
48
|
-
* @param cellY Cell Y position
|
|
49
|
-
* @param cellWidth Cell width
|
|
50
|
-
* @param cellHeight Cell height
|
|
51
|
-
* @param fontSize Font size
|
|
52
|
-
* @param advanceWidth Character advance width
|
|
53
|
-
* @returns SVG path data string or null if generation fails
|
|
54
|
-
*/
|
|
55
|
-
$generatePositionedCharacterPath(character: string, fontData: TyprFont, cellX: number, cellY: number, cellWidth: number, cellHeight: number, fontSize: number, advanceWidth: number): string | null;
|
|
56
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { SVGExporter } from './SVGExporter';
|
|
2
|
-
export { SVGDataExtractor } from './SVGDataExtractor';
|
|
3
|
-
export { SVGContentGenerator } from './SVGContentGenerator';
|
|
4
|
-
export { SVGPathGenerator } from './SVGPathGenerator';
|
|
5
|
-
export { SVGFileHandler } from './SVGFileHandler';
|
|
6
|
-
export type { SVGExportOptions, SVGGenerationOptions, SVGCellData, FramebufferData, RGBA, Position, CellPosition, CellTransform, GlyphPath } from './types';
|