blob: 5aa1192b2e1f4625c57e0db5e3e68eb4081443bf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
/**
* @typedef {import('./configuration.js').tConfiguration} tConfiguration
* @typedef {import('./image_type.js').ImageType} ImageType
* @typedef {import('./stage_type.js').StageType} StageType
* @typedef {import('wmap-parser').Map} ParsedMap
* @typedef {import('canvas').Canvas} Canvas
*/
/**
* Render a parsed Wardley map to a canvas element
* Works in both browser and Node.js environments
*
* @param {ParsedMap} map - Parsed map object from wmap-parser
* @param {HTMLCanvasElement|Canvas} canvas - Canvas element (browser) or Canvas instance (Node.js)
* @param {StageType} [stageType=StageType.ACTIVITIES] - The labels to use for each stage in the map.
* @param {tConfiguration} overrides - User configuration overrides
* @returns {Promise<void>}
*
* @example
* // Browser
* import { parse } from 'wmap-parser';
* import { renderToCanvas } from 'wmap-renderer-canvas';
*
* const map = parse(wmapSource);
* const canvas = document.getElementById('myCanvas');
* await renderToCanvas(map, canvas);
*
* @example
* // Node.js
* import { createCanvas } from 'canvas';
* import { parse } from 'wmap-parser';
* import { renderToCanvas } from 'wmap-renderer-canvas';
*
* const map = parse(wmapSource);
* const canvas = createCanvas(1384, 1084);
* await renderToCanvas(map, canvas);
*/
export function renderToCanvas(map: ParsedMap, canvas: HTMLCanvasElement | Canvas, stageType?: StageType, overrides?: tConfiguration): Promise<void>;
/**
* Render a parsed Wardley map to an image stream
* Only available in Node.js environments
*
* @param {ParsedMap} map - Parsed map object from wmap-parser
* @param {ImageType} imageType - Output image format ('png', 'jpeg', or 'pdf')
* @param {StageType} [stageType=StageType.ACTIVITIES] - The labels to use for each stage in the map.
* @param {tConfiguration} overrides - User configuration overrides
* @returns {Promise<Stream>} Stream of the rendered image
*
* @throws {Error} If not in Node.js environment
* @throws {Error} If canvas module is not available
* @throws {Error} If imageType is not supported
*
* @example
* import { parse } from 'wmap-parser';
* import { renderToImage } from 'wmap-renderer-canvas';
* import fs from 'fs';
*
* const map = parse(wmapSource);
* const stream = await renderToImage(map, 'png');
* const out = fs.createWriteStream('map.png');
* stream.pipe(out);
*/
export function renderToImage(map: ParsedMap, imageType?: ImageType, stageType?: StageType, overrides?: tConfiguration): Promise<Stream>;
export type ImageType = import("./image_type.js").ImageType;
export { ImageType } from "./image_type.js";
export type StageType = import("./stage_type.js").StageType;
export { StageType } from "./stage_type.js";
export type tConfiguration = import("./configuration.js").tConfiguration;
export type ParsedMap = import("wmap-parser").Map;
export type Canvas = import("canvas").Canvas;
import { StageType } from "./stage_type.js";
import { ImageType } from "./image_type.js";
|