@formicoidea/labre-framework-wardley 0.23.0 → 0.23.1
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/consts.d.ts +72 -0
- package/{src/consts.ts → dist/consts.js} +63 -72
- package/dist/descriptor.d.ts +7 -0
- package/{src/descriptor.ts → dist/descriptor.js} +1 -1
- package/dist/effects.d.ts +10 -0
- package/dist/effects.js +7 -0
- package/dist/element-renderer.d.ts +15 -0
- package/dist/element-renderer.js +160 -0
- package/dist/element-view.d.ts +21 -0
- package/dist/element-view.js +122 -0
- package/dist/gradient.d.ts +18 -0
- package/dist/gradient.js +112 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/label-layout.d.ts +21 -0
- package/dist/label-layout.js +73 -0
- package/dist/legend.d.ts +12 -0
- package/dist/legend.js +333 -0
- package/dist/node/consts.d.ts +107 -0
- package/{src/node/consts.ts → dist/node/consts.js} +12 -20
- package/dist/node/label-editor.d.ts +28 -0
- package/dist/node/label-editor.js +216 -0
- package/dist/node/node-renderer.d.ts +17 -0
- package/dist/node/node-renderer.js +106 -0
- package/{src/node/node-view.ts → dist/node/node-view.d.ts} +3 -3
- package/dist/node/node-view.js +10 -0
- package/dist/templates/index.d.ts +3 -0
- package/dist/templates/index.js +172 -0
- package/dist/templates/maps.d.ts +3 -0
- package/dist/templates/maps.js +247 -0
- package/dist/toolbar/config.d.ts +75 -0
- package/dist/toolbar/config.js +206 -0
- package/dist/toolbar/icons.d.ts +31 -0
- package/{src/toolbar/icons.ts → dist/toolbar/icons.js} +51 -66
- package/dist/toolbar/node-config.d.ts +2 -0
- package/{src/toolbar/node-config.ts → dist/toolbar/node-config.js} +7 -14
- package/dist/toolbar/senior-tool.d.ts +2 -0
- package/{src/toolbar/senior-tool.ts → dist/toolbar/senior-tool.js} +5 -5
- package/dist/toolbar/wardley-menu.d.ts +53 -0
- package/dist/toolbar/wardley-menu.js +408 -0
- package/dist/toolbar/wardley-senior-button.d.ts +18 -0
- package/dist/toolbar/wardley-senior-button.js +146 -0
- package/dist/toolbar/wardley-tool-button.d.ts +10 -0
- package/dist/toolbar/wardley-tool-button.js +123 -0
- package/dist/view.d.ts +7 -0
- package/dist/view.js +36 -0
- package/package.json +15 -6
- package/src/effects.ts +0 -17
- package/src/element-renderer.ts +0 -242
- package/src/element-view.ts +0 -143
- package/src/gradient.ts +0 -137
- package/src/index.ts +0 -1
- package/src/label-layout.ts +0 -126
- package/src/legend.ts +0 -438
- package/src/node/node-renderer.ts +0 -142
- package/src/templates/index.ts +0 -236
- package/src/templates/maps.ts +0 -283
- package/src/toolbar/config.ts +0 -280
- package/src/toolbar/wardley-menu.ts +0 -552
- package/src/toolbar/wardley-senior-button.ts +0 -154
- package/src/view.ts +0 -39
package/dist/gradient.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Curve-driven gradient backgrounds (Slice C). Each analytic background is a
|
|
3
|
+
* smooth mathematical curve (piecewise asymmetric Gaussian bells); the gradient
|
|
4
|
+
* opacity at each evolution position X follows that curve, normalised between
|
|
5
|
+
* its own min and max — i.e. the gradient is strongest where the curve peaks and
|
|
6
|
+
* fades to nothing at its minimum. Validated against the reference images at
|
|
7
|
+
* `../wardley-mockups/gradient-backgrounds.html`.
|
|
8
|
+
*/
|
|
9
|
+
const bell = (x, mu, s) => Math.exp(-0.5 * ((x - mu) / s) ** 2);
|
|
10
|
+
const asym = (x, mu, sL, sR) => Math.exp(-0.5 * ((x - mu) / (x < mu ? sL : sR)) ** 2);
|
|
11
|
+
// Opportunity — differential value (green): early peak + long decay.
|
|
12
|
+
const fDiff = (x) => asym(x, 0.175, 0.24, 0.36);
|
|
13
|
+
const DIFF_DOM = [0, 0.86];
|
|
14
|
+
// Opportunity — operational value (red): bump centred on commodity.
|
|
15
|
+
const fOper = (x) => asym(x, 0.85, 0.1, 0.075);
|
|
16
|
+
const OPER_DOM = [0.62, 1];
|
|
17
|
+
// Benefit / investment (signed): big positive bell − small negative bell.
|
|
18
|
+
const fBen = (x) => asym(x, 0.49, 0.17, 0.24) - 0.42 * bell(x, 0.1, 0.075);
|
|
19
|
+
// Evolution-gradient — Simon Wardley's classic evolution presentation: a
|
|
20
|
+
// symmetric grey "U", strong at both evolution extremes (uncharted /
|
|
21
|
+
// industrialised), fading to white through the build middle.
|
|
22
|
+
const fGrey = (x) => {
|
|
23
|
+
const left = Math.max(0, (0.26 - x) / 0.26);
|
|
24
|
+
const right = Math.max(0, (x - 0.64) / 0.36);
|
|
25
|
+
return Math.max(left, right);
|
|
26
|
+
};
|
|
27
|
+
function rangeOf(fn, x0, x1) {
|
|
28
|
+
let lo = Infinity;
|
|
29
|
+
let hi = -Infinity;
|
|
30
|
+
for (let i = 0; i <= 240; i++) {
|
|
31
|
+
const v = fn(x0 + ((x1 - x0) * i) / 240);
|
|
32
|
+
if (v < lo)
|
|
33
|
+
lo = v;
|
|
34
|
+
if (v > hi)
|
|
35
|
+
hi = v;
|
|
36
|
+
}
|
|
37
|
+
return { lo, hi };
|
|
38
|
+
}
|
|
39
|
+
const RG = rangeOf(fDiff, DIFF_DOM[0], DIFF_DOM[1]);
|
|
40
|
+
const RR = rangeOf(fOper, OPER_DOM[0], OPER_DOM[1]);
|
|
41
|
+
const RB = rangeOf(fBen, 0, 1);
|
|
42
|
+
const clamp01 = (v) => Math.max(0, Math.min(1, v));
|
|
43
|
+
const norm = (v, lo, hi) => (hi > lo ? (v - lo) / (hi - lo) : 0);
|
|
44
|
+
export const GRADIENT_GREEN = '#1f9e4d';
|
|
45
|
+
export const GRADIENT_RED = '#d6455d';
|
|
46
|
+
const GRADIENT_GREY = '#7c8389';
|
|
47
|
+
/** Validated peak opacity for the green/red variants. */
|
|
48
|
+
const GRADIENT_MAX_OPACITY = 0.45;
|
|
49
|
+
/** Peak opacity for the grey evolution-gradient variant. */
|
|
50
|
+
const GREY_MAX_OPACITY = 0.38;
|
|
51
|
+
/** Benefit/investment zero-line height (fraction of plot height from bottom). */
|
|
52
|
+
export const BENEFIT_ZERO_FRAC = 0.3;
|
|
53
|
+
function rgba(hex, alpha) {
|
|
54
|
+
const r = parseInt(hex.slice(1, 3), 16);
|
|
55
|
+
const g = parseInt(hex.slice(3, 5), 16);
|
|
56
|
+
const b = parseInt(hex.slice(5, 7), 16);
|
|
57
|
+
return `rgba(${r},${g},${b},${alpha})`;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Add stops to a horizontal gradient (offset 0..1 spanning the plot width) for
|
|
61
|
+
* a function-driven opacity profile within [x0, x1] (zero outside).
|
|
62
|
+
*/
|
|
63
|
+
function addStops(grad, hex, opacityFn, x0, x1, maxOp = GRADIENT_MAX_OPACITY) {
|
|
64
|
+
const eps = 0.001;
|
|
65
|
+
if (x0 > eps)
|
|
66
|
+
grad.addColorStop(Math.max(0, x0 - eps), rgba(hex, 0));
|
|
67
|
+
const N = 48;
|
|
68
|
+
for (let i = 0; i <= N; i++) {
|
|
69
|
+
const x = x0 + ((x1 - x0) * i) / N;
|
|
70
|
+
grad.addColorStop(clamp01(x), rgba(hex, clamp01(opacityFn(x)) * maxOp));
|
|
71
|
+
}
|
|
72
|
+
if (x1 < 1 - eps)
|
|
73
|
+
grad.addColorStop(Math.min(1, x1 + eps), rgba(hex, 0));
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Paint the curve-driven gradient over the plot rectangle [px0,px1]×[py0,py1]
|
|
77
|
+
* in element-local coordinates. `classic` paints nothing.
|
|
78
|
+
*/
|
|
79
|
+
export function paintGradientBackground(ctx, variant, px0, px1, py0, py1) {
|
|
80
|
+
const w = px1 - px0;
|
|
81
|
+
const h = py1 - py0;
|
|
82
|
+
if (variant === 'evolution-gradient') {
|
|
83
|
+
const grey = ctx.createLinearGradient(px0, 0, px1, 0);
|
|
84
|
+
addStops(grey, GRADIENT_GREY, fGrey, 0, 1, GREY_MAX_OPACITY);
|
|
85
|
+
ctx.fillStyle = grey;
|
|
86
|
+
ctx.fillRect(px0, py0, w, h);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (variant === 'opportunity') {
|
|
90
|
+
const green = ctx.createLinearGradient(px0, 0, px1, 0);
|
|
91
|
+
addStops(green, GRADIENT_GREEN, x => norm(fDiff(x), RG.lo, RG.hi), DIFF_DOM[0], DIFF_DOM[1]);
|
|
92
|
+
ctx.fillStyle = green;
|
|
93
|
+
ctx.fillRect(px0, py0, w, h);
|
|
94
|
+
const red = ctx.createLinearGradient(px0, 0, px1, 0);
|
|
95
|
+
addStops(red, GRADIENT_RED, x => norm(fOper(x), RR.lo, RR.hi), OPER_DOM[0], OPER_DOM[1]);
|
|
96
|
+
ctx.fillStyle = red;
|
|
97
|
+
ctx.fillRect(px0, py0, w, h);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
// benefit: green where the curve is positive, red where negative.
|
|
101
|
+
const maxPos = RB.hi;
|
|
102
|
+
const maxNeg = -RB.lo;
|
|
103
|
+
const green = ctx.createLinearGradient(px0, 0, px1, 0);
|
|
104
|
+
addStops(green, GRADIENT_GREEN, x => Math.max(0, fBen(x)) / maxPos, 0, 1);
|
|
105
|
+
ctx.fillStyle = green;
|
|
106
|
+
ctx.fillRect(px0, py0, w, h);
|
|
107
|
+
const red = ctx.createLinearGradient(px0, 0, px1, 0);
|
|
108
|
+
addStops(red, GRADIENT_RED, x => Math.max(0, -fBen(x)) / maxNeg, 0, 1);
|
|
109
|
+
ctx.fillStyle = red;
|
|
110
|
+
ctx.fillRect(px0, py0, w, h);
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=gradient.js.map
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { WardleyBackgroundElementModel } from '@formicoidea/labre-core/model';
|
|
2
|
+
/** The editable label fields of a Wardley background. */
|
|
3
|
+
export type WardleyLabelField = 'xAxisTitle' | 'yAxisTitle' | 'evolutionStart' | 'evolutionEnd' | 'visibilityHigh' | 'visibilityLow' | 'phase0' | 'phase1' | 'phase2' | 'phase3';
|
|
4
|
+
/** A label's hit box in element-local coordinates (axis-aligned, padded). */
|
|
5
|
+
export interface WardleyLabelHit {
|
|
6
|
+
field: WardleyLabelField;
|
|
7
|
+
minX: number;
|
|
8
|
+
minY: number;
|
|
9
|
+
maxX: number;
|
|
10
|
+
maxY: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Compute the clickable boxes of every *visible* Wardley label, in the
|
|
14
|
+
* element's local space. Positions are derived from the SAME constants the
|
|
15
|
+
* renderer uses (`MARGIN` / `OFFSETS` / `FONTS`), so the hit boxes track the
|
|
16
|
+
* drawn text. Boxes are padded so double-clicking is forgiving.
|
|
17
|
+
*/
|
|
18
|
+
export declare function getWardleyLabelHits(model: WardleyBackgroundElementModel, w: number, h: number): WardleyLabelHit[];
|
|
19
|
+
/** First label whose (padded) box contains the local point, or null. */
|
|
20
|
+
export declare function hitTestWardleyLabel(hits: WardleyLabelHit[], lx: number, ly: number): WardleyLabelHit | null;
|
|
21
|
+
//# sourceMappingURL=label-layout.d.ts.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { FONTS, MARGIN, OFFSETS } from './consts';
|
|
2
|
+
/** Rough per-character advance — only used to size generous hit boxes. */
|
|
3
|
+
const approxTextWidth = (text, fontSize) => Math.max(fontSize, text.length * fontSize * 0.6);
|
|
4
|
+
/**
|
|
5
|
+
* Compute the clickable boxes of every *visible* Wardley label, in the
|
|
6
|
+
* element's local space. Positions are derived from the SAME constants the
|
|
7
|
+
* renderer uses (`MARGIN` / `OFFSETS` / `FONTS`), so the hit boxes track the
|
|
8
|
+
* drawn text. Boxes are padded so double-clicking is forgiving.
|
|
9
|
+
*/
|
|
10
|
+
export function getWardleyLabelHits(model, w, h) {
|
|
11
|
+
const px0 = MARGIN.left;
|
|
12
|
+
const px1 = w - MARGIN.right;
|
|
13
|
+
const py0 = MARGIN.top;
|
|
14
|
+
const py1 = h - MARGIN.bottom;
|
|
15
|
+
const ex = (r) => px0 + r * (px1 - px0);
|
|
16
|
+
const pad = 6;
|
|
17
|
+
const hits = [];
|
|
18
|
+
// Horizontal label anchored on its text baseline.
|
|
19
|
+
const addH = (field, text, fontSize, ax, baseline, align) => {
|
|
20
|
+
const tw = approxTextWidth(text, fontSize);
|
|
21
|
+
const minX = align === 'right' ? ax - tw : ax;
|
|
22
|
+
const maxX = align === 'right' ? ax : ax + tw;
|
|
23
|
+
hits.push({
|
|
24
|
+
field,
|
|
25
|
+
minX: minX - pad,
|
|
26
|
+
maxX: maxX + pad,
|
|
27
|
+
minY: baseline - fontSize - pad,
|
|
28
|
+
maxY: baseline + fontSize * 0.3 + pad,
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
// Vertical label (drawn rotated -90°), centered on (ax, ay).
|
|
32
|
+
const addV = (field, text, fontSize, ax, ay) => {
|
|
33
|
+
const tw = approxTextWidth(text, fontSize);
|
|
34
|
+
hits.push({
|
|
35
|
+
field,
|
|
36
|
+
minX: ax - fontSize - pad,
|
|
37
|
+
maxX: ax + fontSize * 0.4 + pad,
|
|
38
|
+
minY: ay - tw / 2 - pad,
|
|
39
|
+
maxY: ay + tw / 2 + pad,
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
if (model.showColumnLabels) {
|
|
43
|
+
addH('phase0', model.phase0, FONTS.phase, ex(0) + OFFSETS.phasePad, py1 + OFFSETS.phaseBaseline, 'left');
|
|
44
|
+
addH('phase1', model.phase1, FONTS.phase, ex(0.175) + OFFSETS.phasePad, py1 + OFFSETS.phaseBaseline, 'left');
|
|
45
|
+
addH('phase2', model.phase2, FONTS.phase, ex(0.4) + OFFSETS.phasePad, py1 + OFFSETS.phaseBaseline, 'left');
|
|
46
|
+
addH('phase3', model.phase3, FONTS.phase, ex(0.7) + OFFSETS.phasePad, py1 + OFFSETS.phaseBaseline, 'left');
|
|
47
|
+
}
|
|
48
|
+
if (model.showXAxis) {
|
|
49
|
+
addH('xAxisTitle', model.xAxisTitle, FONTS.axis, px1 - OFFSETS.evolutionPadRight, py1 + OFFSETS.phaseBaseline, 'right');
|
|
50
|
+
}
|
|
51
|
+
if (model.showCornerLabels) {
|
|
52
|
+
addH('evolutionStart', model.evolutionStart, FONTS.direction, px0 + OFFSETS.directionPadLeft, py0 + OFFSETS.directionTop, 'left');
|
|
53
|
+
addH('evolutionEnd', model.evolutionEnd, FONTS.direction, px1 - OFFSETS.directionPadRight, py0 + OFFSETS.directionTop, 'right');
|
|
54
|
+
}
|
|
55
|
+
if (model.showYAxis) {
|
|
56
|
+
addV('yAxisTitle', model.yAxisTitle, FONTS.axis, px0 - OFFSETS.yHug, (py0 + py1) / 2);
|
|
57
|
+
}
|
|
58
|
+
if (model.showVisibilityLabels) {
|
|
59
|
+
addV('visibilityHigh', model.visibilityHigh, FONTS.visibility, px0 - OFFSETS.yHug, py0 + OFFSETS.visibleTop);
|
|
60
|
+
addV('visibilityLow', model.visibilityLow, FONTS.visibility, px0 - OFFSETS.yHug, py1 - OFFSETS.invisibleBottom);
|
|
61
|
+
}
|
|
62
|
+
return hits;
|
|
63
|
+
}
|
|
64
|
+
/** First label whose (padded) box contains the local point, or null. */
|
|
65
|
+
export function hitTestWardleyLabel(hits, lx, ly) {
|
|
66
|
+
for (const hit of hits) {
|
|
67
|
+
if (lx >= hit.minX && lx <= hit.maxX && ly >= hit.minY && ly <= hit.maxY) {
|
|
68
|
+
return hit;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=label-layout.js.map
|
package/dist/legend.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type WardleyBackgroundElementModel } from '@formicoidea/labre-core/model';
|
|
2
|
+
import type { BlockStdScope } from '@formicoidea/labre-core/std';
|
|
3
|
+
/**
|
|
4
|
+
* Build a "Legend" group from real, editable elements (white rect frame +
|
|
5
|
+
* "Legend" text + one row of [real component glyph + description text] per
|
|
6
|
+
* Wardley component TYPE present inside the background's perimeter + a
|
|
7
|
+
* gradient-meaning block when the background is a gradient variant). A snapshot
|
|
8
|
+
* is created on each call; everything is grouped so it can be moved / resized /
|
|
9
|
+
* edited and is dropped bottom-left of the background.
|
|
10
|
+
*/
|
|
11
|
+
export declare function createWardleyLegend(std: BlockStdScope, bg: WardleyBackgroundElementModel): void;
|
|
12
|
+
//# sourceMappingURL=legend.d.ts.map
|
package/dist/legend.js
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import { createGroupCommand } from '@formicoidea/labre-core/gfx/group';
|
|
2
|
+
import { ConnectorElementModel, ConnectorMode, FontFamily, PointStyle, ShapeElementModel, ShapeStyle, StrokeStyle, WardleyNodeElementModel, } from '@formicoidea/labre-core/model';
|
|
3
|
+
import { Bound } from '@formicoidea/labre-core/global/gfx';
|
|
4
|
+
import { GfxControllerIdentifier } from '@formicoidea/labre-core/std/gfx';
|
|
5
|
+
import { GRADIENT_GREEN, GRADIENT_RED } from './gradient';
|
|
6
|
+
import { INERTIA_COLOR, LINK_GREY, LINK_STROKE_WIDTH, MARKET_DOT_STROKE_WIDTH, MARKET_LINK_COLOR, MARKET_LINK_WIDTH, METHOD_FILL, NODE_FILL, NODE_STROKE, NODE_STROKE_WIDTH, PIPELINE_FILL, WARDLEY_RED, } from './node/consts';
|
|
7
|
+
const LEGEND_ORDER = [
|
|
8
|
+
'component',
|
|
9
|
+
'anchor',
|
|
10
|
+
'market',
|
|
11
|
+
'ecosystem',
|
|
12
|
+
'method',
|
|
13
|
+
'pipeline',
|
|
14
|
+
'link',
|
|
15
|
+
'arrow',
|
|
16
|
+
'inertia',
|
|
17
|
+
];
|
|
18
|
+
/** Default (editable) descriptions for each legend row. */
|
|
19
|
+
const LEGEND_DESC = {
|
|
20
|
+
component: 'Need / capability (activity, practice, data…)',
|
|
21
|
+
anchor: 'Stakeholder (customer, user…)',
|
|
22
|
+
market: 'Market (set of actors)',
|
|
23
|
+
ecosystem: 'Ecosystem',
|
|
24
|
+
method: 'Component + method (color = phase)',
|
|
25
|
+
pipeline: 'Pipeline (possible choices for a capability)',
|
|
26
|
+
link: 'Need relation (parent → child)',
|
|
27
|
+
arrow: 'Evolution / movement (red = future)',
|
|
28
|
+
inertia: 'Inertia to change',
|
|
29
|
+
};
|
|
30
|
+
/** Gradient-meaning block, keyed by variant (caption + 2-colour swatch). */
|
|
31
|
+
const LEGEND_GRADIENT = {
|
|
32
|
+
opportunity: {
|
|
33
|
+
caption: 'Opportunity gradient: differential value (green) vs operational value (red).',
|
|
34
|
+
swatch: [GRADIENT_GREEN, GRADIENT_RED],
|
|
35
|
+
},
|
|
36
|
+
benefit: {
|
|
37
|
+
caption: 'Gradient: investment (red) then benefit (green).',
|
|
38
|
+
swatch: [GRADIENT_RED, GRADIENT_GREEN],
|
|
39
|
+
},
|
|
40
|
+
'evolution-gradient': {
|
|
41
|
+
caption: "Gradient representing the growth of Wardley's evolution function.",
|
|
42
|
+
swatch: ['#9aa0a6', '#cfd2d6'],
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Build a "Legend" group from real, editable elements (white rect frame +
|
|
47
|
+
* "Legend" text + one row of [real component glyph + description text] per
|
|
48
|
+
* Wardley component TYPE present inside the background's perimeter + a
|
|
49
|
+
* gradient-meaning block when the background is a gradient variant). A snapshot
|
|
50
|
+
* is created on each call; everything is grouped so it can be moved / resized /
|
|
51
|
+
* edited and is dropped bottom-left of the background.
|
|
52
|
+
*/
|
|
53
|
+
export function createWardleyLegend(std, bg) {
|
|
54
|
+
const gfx = std.get(GfxControllerIdentifier);
|
|
55
|
+
const surface = gfx.surface;
|
|
56
|
+
if (!surface)
|
|
57
|
+
return;
|
|
58
|
+
const [bx, by, , bh] = bg.deserializedXYWH;
|
|
59
|
+
// 1. Detect which component types are present inside the perimeter.
|
|
60
|
+
const present = new Set();
|
|
61
|
+
for (const el of gfx.getElementsByBound(Bound.deserialize(bg.xywh), {
|
|
62
|
+
type: 'canvas',
|
|
63
|
+
})) {
|
|
64
|
+
// Note: WardleyNodeElementModel extends ShapeElementModel, so the order of
|
|
65
|
+
// these instanceof checks matters.
|
|
66
|
+
if (el instanceof WardleyNodeElementModel) {
|
|
67
|
+
if (el.kind !== 'handle')
|
|
68
|
+
present.add(el.kind);
|
|
69
|
+
}
|
|
70
|
+
else if (el instanceof ConnectorElementModel) {
|
|
71
|
+
if (el.strokeStyle === StrokeStyle.Dash || el.stroke === WARDLEY_RED) {
|
|
72
|
+
present.add('arrow');
|
|
73
|
+
}
|
|
74
|
+
else if (el.stroke === LINK_GREY) {
|
|
75
|
+
present.add('link');
|
|
76
|
+
}
|
|
77
|
+
// market triangle connectors (NODE_STROKE) are ignored.
|
|
78
|
+
}
|
|
79
|
+
else if (el instanceof ShapeElementModel) {
|
|
80
|
+
if (el.fillColor === INERTIA_COLOR)
|
|
81
|
+
present.add('inertia');
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const rows = LEGEND_ORDER.filter(t => present.has(t));
|
|
85
|
+
// 2. Layout (model units). The text column is wide enough for one-line
|
|
86
|
+
// descriptions; the gradient row is taller as its caption may wrap.
|
|
87
|
+
const PAD = 16;
|
|
88
|
+
const TITLE_H = 28;
|
|
89
|
+
const ROW_H = 30;
|
|
90
|
+
const GLYPH_W = 46;
|
|
91
|
+
const GAP = 12;
|
|
92
|
+
const TEXT_FS = 15;
|
|
93
|
+
const TITLE_FS = 18;
|
|
94
|
+
const TEXT_W = 360;
|
|
95
|
+
const GRAD_ROW_H = 40;
|
|
96
|
+
const W = PAD * 2 + GLYPH_W + GAP + TEXT_W;
|
|
97
|
+
const variant = bg.variant;
|
|
98
|
+
const grad = variant !== 'classic' ? LEGEND_GRADIENT[variant] : null;
|
|
99
|
+
const gradH = grad ? 12 + GRAD_ROW_H : 0;
|
|
100
|
+
const H = PAD * 2 + TITLE_H + rows.length * ROW_H + gradH;
|
|
101
|
+
const x0 = bx + 50;
|
|
102
|
+
const y0 = by + bh - 56 - H;
|
|
103
|
+
const text = (t, x, y, w, h, fontSize, align = 'left') => surface.addElement({
|
|
104
|
+
type: 'text',
|
|
105
|
+
text: t,
|
|
106
|
+
fontFamily: FontFamily.Inter,
|
|
107
|
+
fontSize,
|
|
108
|
+
color: NODE_STROKE,
|
|
109
|
+
textAlign: align,
|
|
110
|
+
xywh: new Bound(x, y, w, h).serialize(),
|
|
111
|
+
});
|
|
112
|
+
// ── glyph builders (real, editable elements), centred on (cx, cy) ─────
|
|
113
|
+
const ellipse = (kind, d, fill, sw, cx, cy) => surface.addElement({
|
|
114
|
+
type: 'wardleyNode',
|
|
115
|
+
kind,
|
|
116
|
+
shapeType: 'ellipse',
|
|
117
|
+
filled: true,
|
|
118
|
+
fillColor: fill,
|
|
119
|
+
strokeColor: NODE_STROKE,
|
|
120
|
+
strokeWidth: sw,
|
|
121
|
+
shapeStyle: ShapeStyle.General,
|
|
122
|
+
roughness: 0,
|
|
123
|
+
xywh: new Bound(cx - d / 2, cy - d / 2, d, d).serialize(),
|
|
124
|
+
});
|
|
125
|
+
const glyph = (type, cx, cy) => {
|
|
126
|
+
switch (type) {
|
|
127
|
+
case 'component':
|
|
128
|
+
return [ellipse('component', 16, NODE_FILL, NODE_STROKE_WIDTH, cx, cy)];
|
|
129
|
+
case 'anchor':
|
|
130
|
+
return [ellipse('anchor', 16, NODE_FILL, NODE_STROKE_WIDTH, cx, cy)];
|
|
131
|
+
case 'ecosystem':
|
|
132
|
+
return [ellipse('ecosystem', 20, NODE_FILL, NODE_STROKE_WIDTH, cx, cy)];
|
|
133
|
+
case 'method':
|
|
134
|
+
return [ellipse('method', 18, METHOD_FILL, NODE_STROKE_WIDTH, cx, cy)];
|
|
135
|
+
case 'inertia':
|
|
136
|
+
return [
|
|
137
|
+
surface.addElement({
|
|
138
|
+
type: 'shape',
|
|
139
|
+
shapeType: 'rect',
|
|
140
|
+
filled: true,
|
|
141
|
+
fillColor: INERTIA_COLOR,
|
|
142
|
+
strokeColor: INERTIA_COLOR,
|
|
143
|
+
strokeWidth: 0,
|
|
144
|
+
shapeStyle: ShapeStyle.General,
|
|
145
|
+
roughness: 0,
|
|
146
|
+
radius: 0,
|
|
147
|
+
xywh: new Bound(cx - 2.5, cy - 11, 5, 22).serialize(),
|
|
148
|
+
}),
|
|
149
|
+
];
|
|
150
|
+
case 'pipeline': {
|
|
151
|
+
const bw2 = 34;
|
|
152
|
+
const bh2 = 12;
|
|
153
|
+
const hd = 10;
|
|
154
|
+
const top = cy - bh2 / 2;
|
|
155
|
+
return [
|
|
156
|
+
surface.addElement({
|
|
157
|
+
type: 'wardleyNode',
|
|
158
|
+
kind: 'pipeline',
|
|
159
|
+
shapeType: 'rect',
|
|
160
|
+
filled: true,
|
|
161
|
+
fillColor: PIPELINE_FILL,
|
|
162
|
+
strokeColor: NODE_STROKE,
|
|
163
|
+
strokeWidth: NODE_STROKE_WIDTH,
|
|
164
|
+
shapeStyle: ShapeStyle.General,
|
|
165
|
+
roughness: 0,
|
|
166
|
+
radius: 0,
|
|
167
|
+
xywh: new Bound(cx - bw2 / 2, top, bw2, bh2).serialize(),
|
|
168
|
+
}),
|
|
169
|
+
surface.addElement({
|
|
170
|
+
type: 'wardleyNode',
|
|
171
|
+
kind: 'handle',
|
|
172
|
+
shapeType: 'rect',
|
|
173
|
+
filled: true,
|
|
174
|
+
fillColor: NODE_FILL,
|
|
175
|
+
strokeColor: NODE_STROKE,
|
|
176
|
+
strokeWidth: NODE_STROKE_WIDTH,
|
|
177
|
+
shapeStyle: ShapeStyle.General,
|
|
178
|
+
roughness: 0,
|
|
179
|
+
radius: 0,
|
|
180
|
+
xywh: new Bound(cx - hd / 2, top - hd / 2, hd, hd).serialize(),
|
|
181
|
+
}),
|
|
182
|
+
];
|
|
183
|
+
}
|
|
184
|
+
case 'market': {
|
|
185
|
+
const R = 11;
|
|
186
|
+
const dr = 3;
|
|
187
|
+
const rho = 6;
|
|
188
|
+
const sin60 = Math.sqrt(3) / 2;
|
|
189
|
+
const circle = surface.addElement({
|
|
190
|
+
type: 'wardleyNode',
|
|
191
|
+
kind: 'market',
|
|
192
|
+
shapeType: 'ellipse',
|
|
193
|
+
filled: true,
|
|
194
|
+
fillColor: NODE_FILL,
|
|
195
|
+
strokeColor: NODE_STROKE,
|
|
196
|
+
strokeWidth: NODE_STROKE_WIDTH,
|
|
197
|
+
shapeStyle: ShapeStyle.General,
|
|
198
|
+
roughness: 0,
|
|
199
|
+
xywh: new Bound(cx - R, cy - R, R * 2, R * 2).serialize(),
|
|
200
|
+
});
|
|
201
|
+
const verts = [
|
|
202
|
+
[0, -rho],
|
|
203
|
+
[rho * sin60, rho / 2],
|
|
204
|
+
[-rho * sin60, rho / 2],
|
|
205
|
+
];
|
|
206
|
+
const dots = verts.map(([vx, vy]) => surface.addElement({
|
|
207
|
+
type: 'wardleyNode',
|
|
208
|
+
kind: 'component',
|
|
209
|
+
shapeType: 'ellipse',
|
|
210
|
+
filled: true,
|
|
211
|
+
fillColor: NODE_FILL,
|
|
212
|
+
strokeColor: NODE_STROKE,
|
|
213
|
+
strokeWidth: MARKET_DOT_STROKE_WIDTH,
|
|
214
|
+
shapeStyle: ShapeStyle.General,
|
|
215
|
+
roughness: 0,
|
|
216
|
+
xywh: new Bound(cx + vx - dr, cy + vy - dr, dr * 2, dr * 2).serialize(),
|
|
217
|
+
}));
|
|
218
|
+
const conns = [
|
|
219
|
+
[dots[0], dots[1]],
|
|
220
|
+
[dots[1], dots[2]],
|
|
221
|
+
[dots[2], dots[0]],
|
|
222
|
+
].map(([a, b]) => surface.addElement({
|
|
223
|
+
type: 'connector',
|
|
224
|
+
mode: ConnectorMode.Straight,
|
|
225
|
+
source: { id: a },
|
|
226
|
+
target: { id: b },
|
|
227
|
+
stroke: MARKET_LINK_COLOR,
|
|
228
|
+
strokeStyle: StrokeStyle.Solid,
|
|
229
|
+
strokeWidth: MARKET_LINK_WIDTH,
|
|
230
|
+
frontEndpointStyle: PointStyle.None,
|
|
231
|
+
rearEndpointStyle: PointStyle.None,
|
|
232
|
+
}));
|
|
233
|
+
return [circle, ...dots, ...conns];
|
|
234
|
+
}
|
|
235
|
+
case 'link':
|
|
236
|
+
return [
|
|
237
|
+
surface.addElement({
|
|
238
|
+
type: 'connector',
|
|
239
|
+
mode: ConnectorMode.Straight,
|
|
240
|
+
source: { position: [cx - 18, cy + 6] },
|
|
241
|
+
target: { position: [cx + 18, cy - 6] },
|
|
242
|
+
stroke: LINK_GREY,
|
|
243
|
+
strokeStyle: StrokeStyle.Solid,
|
|
244
|
+
strokeWidth: LINK_STROKE_WIDTH,
|
|
245
|
+
frontEndpointStyle: PointStyle.None,
|
|
246
|
+
rearEndpointStyle: PointStyle.None,
|
|
247
|
+
}),
|
|
248
|
+
];
|
|
249
|
+
case 'arrow':
|
|
250
|
+
return [
|
|
251
|
+
surface.addElement({
|
|
252
|
+
type: 'connector',
|
|
253
|
+
mode: ConnectorMode.Straight,
|
|
254
|
+
source: { position: [cx - 18, cy] },
|
|
255
|
+
target: { position: [cx + 16, cy] },
|
|
256
|
+
stroke: WARDLEY_RED,
|
|
257
|
+
strokeStyle: StrokeStyle.Dash,
|
|
258
|
+
strokeWidth: LINK_STROKE_WIDTH,
|
|
259
|
+
frontEndpointStyle: PointStyle.None,
|
|
260
|
+
rearEndpointStyle: PointStyle.Triangle,
|
|
261
|
+
}),
|
|
262
|
+
];
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
// 3. Create the elements.
|
|
266
|
+
std.store.captureSync();
|
|
267
|
+
const ids = [];
|
|
268
|
+
// White frame.
|
|
269
|
+
ids.push(surface.addElement({
|
|
270
|
+
type: 'shape',
|
|
271
|
+
shapeType: 'rect',
|
|
272
|
+
filled: true,
|
|
273
|
+
fillColor: '#ffffff',
|
|
274
|
+
strokeColor: '#cfd2d6',
|
|
275
|
+
strokeWidth: 1,
|
|
276
|
+
shapeStyle: ShapeStyle.General,
|
|
277
|
+
roughness: 0,
|
|
278
|
+
radius: 6,
|
|
279
|
+
xywh: new Bound(x0, y0, W, H).serialize(),
|
|
280
|
+
}));
|
|
281
|
+
// Title.
|
|
282
|
+
ids.push(text('Legend', x0 + PAD, y0 + PAD, W - PAD * 2, TITLE_FS + 6, TITLE_FS));
|
|
283
|
+
// Rows.
|
|
284
|
+
let ry = y0 + PAD + TITLE_H;
|
|
285
|
+
for (const t of rows) {
|
|
286
|
+
const cyRow = ry + ROW_H / 2;
|
|
287
|
+
ids.push(...glyph(t, x0 + PAD + GLYPH_W / 2, cyRow));
|
|
288
|
+
ids.push(text(LEGEND_DESC[t], x0 + PAD + GLYPH_W + GAP, cyRow - (TEXT_FS + 8) / 2, TEXT_W, TEXT_FS + 8, TEXT_FS));
|
|
289
|
+
ry += ROW_H;
|
|
290
|
+
}
|
|
291
|
+
// Gradient meaning block: a separator, then [2-colour swatch | caption].
|
|
292
|
+
if (grad) {
|
|
293
|
+
const sepY = ry + 4;
|
|
294
|
+
ids.push(surface.addElement({
|
|
295
|
+
type: 'shape',
|
|
296
|
+
shapeType: 'rect',
|
|
297
|
+
filled: true,
|
|
298
|
+
fillColor: '#cfd2d6',
|
|
299
|
+
strokeColor: '#cfd2d6',
|
|
300
|
+
strokeWidth: 0,
|
|
301
|
+
shapeStyle: ShapeStyle.General,
|
|
302
|
+
roughness: 0,
|
|
303
|
+
radius: 0,
|
|
304
|
+
xywh: new Bound(x0 + PAD, sepY, W - PAD * 2, 1).serialize(),
|
|
305
|
+
}));
|
|
306
|
+
const cyRow = sepY + 8 + GRAD_ROW_H / 2;
|
|
307
|
+
const sw = 14;
|
|
308
|
+
const sgap = 2;
|
|
309
|
+
const sx = x0 + PAD + GLYPH_W / 2 - (sw * 2 + sgap) / 2;
|
|
310
|
+
grad.swatch.forEach((col, i) => {
|
|
311
|
+
ids.push(surface.addElement({
|
|
312
|
+
type: 'shape',
|
|
313
|
+
shapeType: 'rect',
|
|
314
|
+
filled: true,
|
|
315
|
+
fillColor: col,
|
|
316
|
+
strokeColor: '#cfd2d6',
|
|
317
|
+
strokeWidth: 0.5,
|
|
318
|
+
shapeStyle: ShapeStyle.General,
|
|
319
|
+
roughness: 0,
|
|
320
|
+
radius: 1,
|
|
321
|
+
xywh: new Bound(sx + i * (sw + sgap), cyRow - sw / 2, sw, sw).serialize(),
|
|
322
|
+
}));
|
|
323
|
+
});
|
|
324
|
+
ids.push(text(grad.caption, x0 + PAD + GLYPH_W + GAP, cyRow - GRAD_ROW_H / 2, TEXT_W, GRAD_ROW_H, TEXT_FS));
|
|
325
|
+
}
|
|
326
|
+
// 4. Group everything and select it.
|
|
327
|
+
const [, result] = std.command.exec(createGroupCommand, { elements: ids });
|
|
328
|
+
gfx.selection.set({
|
|
329
|
+
elements: [result.groupId || ids[0]],
|
|
330
|
+
editing: false,
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
//# sourceMappingURL=legend.js.map
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Visual constants for Wardley nodes (component + anchor) and the connector /
|
|
3
|
+
* inertia presets created from the Wardley menu.
|
|
4
|
+
*
|
|
5
|
+
* The node is a NATIVE ellipse (ShapeElementModel-derived) so its stroke
|
|
6
|
+
* width / colors are editable via the shape toolbar; these are just the
|
|
7
|
+
* pre-formatted defaults at creation. The person glyph (anchor) is expressed as
|
|
8
|
+
* ratios of the circle radius R so it stays proportional at any size.
|
|
9
|
+
*/
|
|
10
|
+
/** Default node diameter (= the map label font size, 18). White fill, thin border. */
|
|
11
|
+
export declare const NODE_SIZE = 18;
|
|
12
|
+
export declare const NODE_FILL = "#ffffff";
|
|
13
|
+
export declare const NODE_STROKE = "#1f2328";
|
|
14
|
+
/** Thin border, matching the link / silhouette line weight. */
|
|
15
|
+
export declare const NODE_STROKE_WIDTH = 1;
|
|
16
|
+
/**
|
|
17
|
+
* Person glyph (`kind: 'anchor'`) ratios of R, mirroring the validated icon
|
|
18
|
+
* ANCH-B (circle r6 → head r1.8 at cy-2.6 ; shoulders cubic touching the
|
|
19
|
+
* border at ±(4.6, 3.9) with controls at ±(3.8, 0.1)).
|
|
20
|
+
*/
|
|
21
|
+
export declare const ANCHOR: {
|
|
22
|
+
headR: number;
|
|
23
|
+
headCY: number;
|
|
24
|
+
shoulderEndX: number;
|
|
25
|
+
shoulderEndY: number;
|
|
26
|
+
shoulderCtrlX: number;
|
|
27
|
+
shoulderCtrlY: number;
|
|
28
|
+
};
|
|
29
|
+
/** Native text label, same family as the axis labels, size 18. */
|
|
30
|
+
export declare const LABEL_FONT_SIZE = 18;
|
|
31
|
+
export declare const LABEL_GAP = 8;
|
|
32
|
+
export declare const LABEL_DEFAULT: {
|
|
33
|
+
component: string;
|
|
34
|
+
anchor: string;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Pipeline defaults. The body is a wide, thin native rect (≈ 1.4× the node
|
|
38
|
+
* diameter tall) with a white slightly-transparent fill and a node-weight
|
|
39
|
+
* border. The handle is a node-sized square straddling the top edge — the only
|
|
40
|
+
* connection point (center anchor). Both reuse the WardleyNode (rect) so they
|
|
41
|
+
* stay native and editable; the body is made non-connectable in the model.
|
|
42
|
+
*/
|
|
43
|
+
export declare const PIPELINE_HEIGHT: number;
|
|
44
|
+
export declare const PIPELINE_WIDTH = 120;
|
|
45
|
+
/** White ~60% opacity — fill only; the 1px border stays opaque. */
|
|
46
|
+
export declare const PIPELINE_FILL = "#ffffff99";
|
|
47
|
+
/** Handle square = node diameter. */
|
|
48
|
+
export declare const HANDLE_SIZE = 18;
|
|
49
|
+
export declare const PIPELINE_LABEL = "Pipeline";
|
|
50
|
+
/**
|
|
51
|
+
* Connector line width. Connectors are constrained to the LineWidth enum
|
|
52
|
+
* {2,4,6,8,10,12}, so the thinnest available (2) is used — as close as possible
|
|
53
|
+
* to the 1px node border.
|
|
54
|
+
*/
|
|
55
|
+
export declare const LINK_STROKE_WIDTH = 2;
|
|
56
|
+
/** Wardley red ("future"/evolution) — matches the validated arrow icon. */
|
|
57
|
+
export declare const WARDLEY_RED = "#d6455d";
|
|
58
|
+
/** Dependency link grey. */
|
|
59
|
+
export declare const LINK_GREY = "#666666";
|
|
60
|
+
/** Inertia bar color + size. */
|
|
61
|
+
export declare const INERTIA_COLOR = "#1f2328";
|
|
62
|
+
export declare const INERTIA_SIZE: {
|
|
63
|
+
w: number;
|
|
64
|
+
h: number;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Market node (composite): a large thin-bordered circle containing 3 small
|
|
68
|
+
* thick-bordered component nodes wired into a triangle by native connectors.
|
|
69
|
+
*/
|
|
70
|
+
export declare const MARKET_SIZE = 30;
|
|
71
|
+
export declare const MARKET_DOT_SIZE = 8;
|
|
72
|
+
/** Radius of the circle on which the 3 inner node centers sit. */
|
|
73
|
+
export declare const MARKET_DOT_RING = 8;
|
|
74
|
+
/** Inner nodes have a thicker border than the outer circle. */
|
|
75
|
+
export declare const MARKET_DOT_STROKE_WIDTH = 2;
|
|
76
|
+
/** Triangle connectors: thin + dark, no arrows. */
|
|
77
|
+
export declare const MARKET_LINK_WIDTH = 1;
|
|
78
|
+
export declare const MARKET_LINK_COLOR = "#1f2328";
|
|
79
|
+
export declare const MARKET_LABEL = "Market";
|
|
80
|
+
/**
|
|
81
|
+
* Ecosystem node: a single connectable circle drawn as a GLYPH — a double border
|
|
82
|
+
* at the rim (outer circle + a 2nd inscribed circle with a thin blank band
|
|
83
|
+
* between them) and diagonal hatching confined to the inner donut (from the 2nd
|
|
84
|
+
* border down to a hollow central circle; the hatch never reaches the outer
|
|
85
|
+
* border). Ratios are of R so the glyph scales with the circle.
|
|
86
|
+
*/
|
|
87
|
+
export declare const ECOSYSTEM_SIZE = 40;
|
|
88
|
+
export declare const ECOSYSTEM: {
|
|
89
|
+
secondBorderRatio: number;
|
|
90
|
+
centerRatio: number;
|
|
91
|
+
hatchOuterRatio: number;
|
|
92
|
+
hatchSpacingRatio: number;
|
|
93
|
+
};
|
|
94
|
+
export declare const ECOSYSTEM_LABEL = "Ecosystem";
|
|
95
|
+
/**
|
|
96
|
+
* Method node: a component inscribed in a slightly larger outer circle whose
|
|
97
|
+
* FILL color encodes the chosen method (editable via the toolbar). Glyph = the
|
|
98
|
+
* outer circle (colored fill + border, the base ellipse) + a white component
|
|
99
|
+
* circle drawn at its center. Default fill is a neutral grey.
|
|
100
|
+
*/
|
|
101
|
+
export declare const METHOD_SIZE = 35;
|
|
102
|
+
export declare const METHOD_FILL = "#d9d9d9";
|
|
103
|
+
export declare const METHOD: {
|
|
104
|
+
centerRatio: number;
|
|
105
|
+
};
|
|
106
|
+
export declare const METHOD_LABEL = "Component";
|
|
107
|
+
//# sourceMappingURL=consts.d.ts.map
|