@widgetic/canvas 0.5.46 → 0.5.47
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 +2 -1
- package/dist/canvas/DomCanvas.svelte +1 -2
- package/dist/canvas/host/CanvasHost.d.ts +0 -3
- package/dist/canvas/host/CanvasHost.js +102 -67
- package/dist/canvas/host/pauseCollector.d.ts +18 -0
- package/dist/canvas/host/pauseCollector.js +45 -0
- package/dist/canvas/ui/CanvasContextMenu.svelte +40 -3
- package/dist/canvas/ui/CanvasHint.svelte +10 -9
- package/dist/canvas/ui/SelectionPanel.svelte +14 -12
- package/dist/canvas/ui/SelectionPanel.svelte.d.ts +0 -2
- package/dist/canvas/ui/ShapesMenu.svelte +6 -4
- package/dist/canvas/ui/ToolButton.svelte +7 -6
- package/dist/canvas/ui/floatingCard.d.ts +28 -8
- package/dist/canvas/ui/floatingCard.js +28 -8
- package/dist/canvas/ui/selectionTraits.d.ts +8 -4
- package/dist/canvas/ui/selectionTraits.js +10 -18
- package/dist/canvas/view/SelectionOverlay.svelte +2 -2
- package/dist/canvas/view/geometry.d.ts +1 -1
- package/dist/canvas/view/geometry.js +1 -1
- package/dist/components/input-controls/ColorIC.svelte +1 -1
- package/dist/components/input-controls/FontSelectorIC.svelte +1 -1
- package/dist/engine/EngineCore.d.ts +33 -8
- package/dist/engine/EngineCore.js +66 -30
- package/dist/engine/core/brush.d.ts +24 -0
- package/dist/engine/core/brush.js +145 -13
- package/dist/engine/core/shapeTools.d.ts +23 -18
- package/dist/engine/core/shapeTools.js +45 -17
- package/dist/engine/core/style.d.ts +18 -2
- package/dist/engine/core/style.js +57 -25
- package/dist/engine/core/styleMemory.d.ts +88 -0
- package/dist/engine/core/styleMemory.js +189 -0
- package/dist/engine/input/gestures.d.ts +8 -3
- package/dist/engine/input/gestures.js +123 -48
- package/dist/engine/input/keyboard.js +7 -2
- package/dist/poster/boardPlacement.d.ts +4 -1
- package/dist/poster/boardPlacement.js +6 -3
- package/dist/settings/rememberedStyles.d.ts +22 -0
- package/dist/settings/rememberedStyles.js +47 -0
- package/dist/settings/workspaceToolSettings.d.ts +17 -0
- package/dist/settings/workspaceToolSettings.js +4 -1
- package/dist/tools/hostAdapter.js +0 -1
- package/package.json +4 -4
|
@@ -59,25 +59,145 @@ export function brushOutlineData(ink, strokeWidth) {
|
|
|
59
59
|
const center = points[0] ?? { x: 0, y: 0 };
|
|
60
60
|
return circlePathData(center, Math.max(0.5, size / 2));
|
|
61
61
|
}
|
|
62
|
-
/**
|
|
63
|
-
|
|
62
|
+
/**
|
|
63
|
+
* The points of a line that the outline needs: the ones that are a gap away from the one kept before them, the first and the last
|
|
64
|
+
* always. A line with more than `BRUSH_MAX_POINTS` of them is thinned further, with a wider gap.
|
|
65
|
+
*/
|
|
66
|
+
function thinKeptPoints(entries, size) {
|
|
64
67
|
let gap = Math.max(MINIMUM_POINT_GAP, size * POINT_GAP_OF_SIZE);
|
|
65
68
|
for (;;) {
|
|
66
|
-
const kept = [
|
|
67
|
-
for (let index = 1; index <
|
|
69
|
+
const kept = [entries[0]];
|
|
70
|
+
for (let index = 1; index < entries.length - 1; index += 1) {
|
|
68
71
|
const previous = kept[kept.length - 1].point;
|
|
69
|
-
if (Math.hypot(
|
|
70
|
-
kept.push(
|
|
71
|
-
}
|
|
72
|
+
if (Math.hypot(entries[index].point.x - previous.x, entries[index].point.y - previous.y) >= gap)
|
|
73
|
+
kept.push(entries[index]);
|
|
72
74
|
}
|
|
73
75
|
// The last point is where the hand ended, whatever came before it.
|
|
74
|
-
if (
|
|
75
|
-
kept.push(
|
|
76
|
+
if (entries.length > 1)
|
|
77
|
+
kept.push(entries[entries.length - 1]);
|
|
76
78
|
if (kept.length <= BRUSH_MAX_POINTS)
|
|
77
79
|
return kept;
|
|
78
80
|
gap *= 1.5;
|
|
79
81
|
}
|
|
80
82
|
}
|
|
83
|
+
/** The points of a smoothed line that the outline needs, with the pressure each was drawn with. */
|
|
84
|
+
function keptPoints(points, pressures, size) {
|
|
85
|
+
return thinKeptPoints(points.map((point, index) => ({ point, pressure: pressures[index] })), size);
|
|
86
|
+
}
|
|
87
|
+
// ──────────────────────────────────────────────────────────── a line that is partly held straight
|
|
88
|
+
/**
|
|
89
|
+
* The pressure a straight line (Shift) is drawn at when the device reports none (a mouse, a finger): the one a stroke drawn by
|
|
90
|
+
* hand settles at as soon as the hand moves at an ordinary pace. The straight line is then as thick as the lines drawn by hand
|
|
91
|
+
* beside it (a width of 3 is about 3 px on the screen, and not the 6.6 px of a pen pressing at its middle), and as thick at one
|
|
92
|
+
* end as at the other.
|
|
93
|
+
*/
|
|
94
|
+
export const STRAIGHT_LINE_PRESSURE = 0;
|
|
95
|
+
// Where a straight stretch meets the line the hand drew, the width eases from the hand's to the stretch's over this many brush
|
|
96
|
+
// widths (or over half of the stretch, when it is shorter): a hand that dwelled before Shift went down was thick there, and the
|
|
97
|
+
// stretch is even, so without the easing the line would step in width at the join.
|
|
98
|
+
const STRAIGHT_BLEND_IN_SIZES = 3;
|
|
99
|
+
// Two points of a joined line this close to each other are one: the end of a piece of the line is where the next one begins.
|
|
100
|
+
const JOIN_DISTANCE = 0.01;
|
|
101
|
+
/** The stretches that can be drawn: in order, one after another, each with a length and a pressure between 0 and 1. */
|
|
102
|
+
function usableStraightSpans(spans, samples) {
|
|
103
|
+
if (!spans || spans.length === 0)
|
|
104
|
+
return [];
|
|
105
|
+
// The indexes of a stretch count the samples as they were given, so a sample that is no point would throw them all off.
|
|
106
|
+
if (samples.some((sample) => !Number.isFinite(sample.x) || !Number.isFinite(sample.y)))
|
|
107
|
+
return [];
|
|
108
|
+
const usable = [];
|
|
109
|
+
let reach = 0;
|
|
110
|
+
for (const span of [...spans].sort((a, b) => a.from - b.from)) {
|
|
111
|
+
if (!Number.isInteger(span.from) || !Number.isInteger(span.to))
|
|
112
|
+
continue;
|
|
113
|
+
// A stretch that begins before the one before it ended, ends before it begins, or ends off the line is left out.
|
|
114
|
+
if (span.from < reach || span.to <= span.from || span.to >= samples.length)
|
|
115
|
+
continue;
|
|
116
|
+
// One with no length draws nothing (Shift pressed and let go on the same spot).
|
|
117
|
+
if (Math.hypot(samples[span.to].x - samples[span.from].x, samples[span.to].y - samples[span.from].y) < DOT_REACH)
|
|
118
|
+
continue;
|
|
119
|
+
const pressure = typeof span.pressure === 'number' && Number.isFinite(span.pressure) ? Math.min(1, Math.max(0, span.pressure)) : STRAIGHT_LINE_PRESSURE;
|
|
120
|
+
usable.push({ from: span.from, to: span.to, pressure });
|
|
121
|
+
reach = span.to;
|
|
122
|
+
}
|
|
123
|
+
return usable;
|
|
124
|
+
}
|
|
125
|
+
/** The samples of a straight stretch: its two ends, and the points where its width has settled to its own pressure. */
|
|
126
|
+
function straightStretchSamples(from, to, startPressure, pressure, endPressure, size) {
|
|
127
|
+
const length = Math.hypot(to.x - from.x, to.y - from.y);
|
|
128
|
+
const blend = Math.min(length / 2, size * STRAIGHT_BLEND_IN_SIZES);
|
|
129
|
+
const alongX = (to.x - from.x) / length;
|
|
130
|
+
const alongY = (to.y - from.y) / length;
|
|
131
|
+
const line = [
|
|
132
|
+
{ x: from.x, y: from.y, pressure: startPressure },
|
|
133
|
+
{ x: from.x + alongX * blend, y: from.y + alongY * blend, pressure }
|
|
134
|
+
];
|
|
135
|
+
// A stretch longer than twice the blend has a second point, where the width starts to ease towards the other end.
|
|
136
|
+
if (length - blend * 2 > JOIN_DISTANCE)
|
|
137
|
+
line.push({ x: to.x - alongX * blend, y: to.y - alongY * blend, pressure });
|
|
138
|
+
line.push({ x: to.x, y: to.y, pressure: endPressure });
|
|
139
|
+
return line;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* The line of a stroke that is partly drawn by hand and partly held straight. The hand's pieces are smoothed as ever, each ending
|
|
143
|
+
* exactly where a straight stretch begins and beginning again exactly where one ends; the stretches are exact straight lines in
|
|
144
|
+
* their own even pressure, easing to the width of the hand's piece beside them so that the join has no step. The outline
|
|
145
|
+
* (`brushOutlineData`) rounds the corner where a stretch leaves the hand's line at an angle.
|
|
146
|
+
*/
|
|
147
|
+
function keptOfMixedLine(samples, stretches, size, brushLine, finished) {
|
|
148
|
+
// A piece of the hand's line that never leaves a unit of where it began has no length to draw.
|
|
149
|
+
const hasReach = (piece) => piece.some((sample) => Math.hypot(sample.x - piece[0].x, sample.y - piece[0].y) >= DOT_REACH);
|
|
150
|
+
const pieces = [];
|
|
151
|
+
let cursor = 0;
|
|
152
|
+
for (const stretch of stretches) {
|
|
153
|
+
const handSamples = samples.slice(cursor, stretch.from + 1);
|
|
154
|
+
if (stretch.from > cursor && hasReach(handSamples))
|
|
155
|
+
pieces.push({ kind: 'hand', samples: handSamples });
|
|
156
|
+
pieces.push({ kind: 'straight', from: samples[stretch.from], to: samples[stretch.to], pressure: stretch.pressure });
|
|
157
|
+
cursor = stretch.to;
|
|
158
|
+
}
|
|
159
|
+
const handTail = samples.slice(cursor);
|
|
160
|
+
if (handTail.length > 1 && hasReach(handTail))
|
|
161
|
+
pieces.push({ kind: 'hand', samples: handTail });
|
|
162
|
+
// The hand's pieces first: a straight stretch takes the width at each of its ends from the hand's piece beside it. A piece that
|
|
163
|
+
// a stretch follows ends exactly where the stretch begins; the last piece trails the hand until the line is finished.
|
|
164
|
+
const handKept = new Map();
|
|
165
|
+
pieces.forEach((piece, index) => {
|
|
166
|
+
if (piece.kind !== 'hand')
|
|
167
|
+
return;
|
|
168
|
+
const options = { ...brushLine, last: index < pieces.length - 1 ? true : finished };
|
|
169
|
+
const points = strokePointsOf(piece.samples, options);
|
|
170
|
+
if (points.length === 0)
|
|
171
|
+
return;
|
|
172
|
+
const { pressures } = outlineWithPressures(points, options);
|
|
173
|
+
handKept.set(index, keptPoints(points, pressures, size));
|
|
174
|
+
});
|
|
175
|
+
const stretchOptions = { ...brushLine, streamline: 0, simulatePressure: false, last: true };
|
|
176
|
+
const parts = pieces.map((piece, index) => {
|
|
177
|
+
if (piece.kind === 'hand')
|
|
178
|
+
return handKept.get(index) ?? [];
|
|
179
|
+
const before = handKept.get(index - 1);
|
|
180
|
+
const after = handKept.get(index + 1);
|
|
181
|
+
const startPressure = before && before.length > 0 ? before[before.length - 1].pressure : piece.pressure;
|
|
182
|
+
const endPressure = after && after.length > 0 ? after[0].pressure : piece.pressure;
|
|
183
|
+
const points = strokePointsOf(straightStretchSamples(piece.from, piece.to, startPressure, piece.pressure, endPressure, size), stretchOptions);
|
|
184
|
+
if (points.length === 0)
|
|
185
|
+
return [];
|
|
186
|
+
const { pressures } = outlineWithPressures(points, stretchOptions);
|
|
187
|
+
return keptPoints(points, pressures, size);
|
|
188
|
+
});
|
|
189
|
+
const joined = [];
|
|
190
|
+
for (const part of parts) {
|
|
191
|
+
for (const entry of part) {
|
|
192
|
+
const previous = joined[joined.length - 1];
|
|
193
|
+
// The end of a piece is where the next one begins: one point, and the pressure the earlier piece gave it.
|
|
194
|
+
if (previous && Math.hypot(entry.point.x - previous.point.x, entry.point.y - previous.point.y) < JOIN_DISTANCE)
|
|
195
|
+
continue;
|
|
196
|
+
joined.push(entry);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return joined.length > BRUSH_MAX_POINTS ? thinKeptPoints(joined, size) : joined;
|
|
200
|
+
}
|
|
81
201
|
/**
|
|
82
202
|
* The stroke for the samples of a pointer, in world units: the box of its line, the line itself with its pressure, and the
|
|
83
203
|
* outline to draw. Null when there is nothing to draw.
|
|
@@ -90,9 +210,16 @@ export function buildBrushStroke(samples, options = {}) {
|
|
|
90
210
|
const steadyPressure = typeof options.steadyPressure === 'number' && Number.isFinite(options.steadyPressure) ? Math.min(1, Math.max(0, options.steadyPressure)) : null;
|
|
91
211
|
const brushLine = brushOptions(size, pressure, options.finished === true);
|
|
92
212
|
const lineOptions = steadyPressure === null ? brushLine : { ...brushLine, streamline: 0, simulatePressure: false };
|
|
93
|
-
|
|
213
|
+
// Stretches held straight: a line that is one of them from end to end is a straight line (its two ends, one pressure, as above);
|
|
214
|
+
// one that is only partly straight is drawn piece by piece. A line that is made straight as a whole leaves them out.
|
|
215
|
+
const stretches = steadyPressure === null ? usableStraightSpans(options.straightSpans, samples) : [];
|
|
216
|
+
const isStraightEndToEnd = stretches.length === 1 && stretches[0].from === 0 && stretches[0].to === samples.length - 1;
|
|
217
|
+
const straightPressure = isStraightEndToEnd ? stretches[0].pressure : steadyPressure;
|
|
218
|
+
const lineSamples = isStraightEndToEnd ? [samples[0], samples[samples.length - 1]] : samples;
|
|
219
|
+
const wholeLineOptions = isStraightEndToEnd ? { ...brushLine, streamline: 0, simulatePressure: false } : lineOptions;
|
|
220
|
+
const usable = lineSamples
|
|
94
221
|
.filter((sample) => Number.isFinite(sample.x) && Number.isFinite(sample.y))
|
|
95
|
-
.map((sample) => (
|
|
222
|
+
.map((sample) => (straightPressure === null ? sample : { x: sample.x, y: sample.y, pressure: straightPressure }));
|
|
96
223
|
if (usable.length === 0)
|
|
97
224
|
return null;
|
|
98
225
|
let kept;
|
|
@@ -103,10 +230,15 @@ export function buildBrushStroke(samples, options = {}) {
|
|
|
103
230
|
const point = { x: usable[0].x, y: usable[0].y, pressure: dotPressure, vectorX: 0, vectorY: 0, distance: 0, runningLength: 0 };
|
|
104
231
|
kept = [{ point, pressure: dotPressure }];
|
|
105
232
|
}
|
|
233
|
+
else if (stretches.length > 0 && !isStraightEndToEnd) {
|
|
234
|
+
kept = keptOfMixedLine(samples, stretches, size, brushLine, options.finished === true);
|
|
235
|
+
if (kept.length === 0)
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
106
238
|
else {
|
|
107
|
-
const smoothed = strokePointsOf(usable,
|
|
239
|
+
const smoothed = strokePointsOf(usable, wholeLineOptions);
|
|
108
240
|
// The pass that works the pressure out (from the speed, or read from the pen) so that it can be kept.
|
|
109
|
-
const { pressures } = outlineWithPressures(smoothed,
|
|
241
|
+
const { pressures } = outlineWithPressures(smoothed, wholeLineOptions);
|
|
110
242
|
kept = keptPoints(smoothed, pressures, size);
|
|
111
243
|
}
|
|
112
244
|
let minX = Infinity;
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* place. Nothing here touches the board; the pointer controller calls these on every move for the preview and
|
|
4
4
|
* once more on release for the shape that is kept.
|
|
5
5
|
*/
|
|
6
|
+
import type { RememberedStyles } from './styleMemory.js';
|
|
6
7
|
import type { EllipseObject, ObjectId, PathObject, Point, Rect, RectObject } from './types.js';
|
|
7
|
-
type WorkspaceShapePaint = Partial<Pick<RectObject, 'fill' | 'stroke' | 'strokeWidth' | 'strokeStyle' | 'opacity' | 'roundness'>>;
|
|
8
8
|
/** A drag shorter than this (in screen pixels) is a click: the shape is placed at its default size. */
|
|
9
9
|
export declare const MIN_DRAW_DISTANCE = 4;
|
|
10
10
|
/** The size of a library shape placed by a click. */
|
|
@@ -40,24 +40,25 @@ export interface ShapeDraftOptions {
|
|
|
40
40
|
wireframe: boolean;
|
|
41
41
|
createId?: (prefix: string) => ObjectId;
|
|
42
42
|
random?: () => number;
|
|
43
|
-
/**
|
|
44
|
-
|
|
43
|
+
/**
|
|
44
|
+
* What the person last chose for each kind of element (`EngineCore.rememberedStyles`): a new shape, line icon or arrow starts with it,
|
|
45
|
+
* laid over the look it would start with (the wireframe's white fill and grey outline, a random colour, the arrow's own line). Left
|
|
46
|
+
* out, the shape starts with that look alone.
|
|
47
|
+
*/
|
|
48
|
+
rememberedStyles?: RememberedStyles;
|
|
45
49
|
}
|
|
46
|
-
/**
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
/**
|
|
51
|
+
* The paint a new shape of the tools starts with, by the look the board is in. What the person chose for the shapes before is laid over
|
|
52
|
+
* it afterwards (`withRememberedStyle`), so it is the same in both looks: the wireframe look decides only how a shape starts.
|
|
53
|
+
*/
|
|
54
|
+
export declare function newShapePaint(wireframe: boolean, random?: () => number): {
|
|
55
|
+
fill: "#ffffff";
|
|
56
|
+
stroke: "#374151";
|
|
57
|
+
strokeWidth: 2;
|
|
54
58
|
} | {
|
|
55
|
-
roundness?: number | undefined;
|
|
56
|
-
opacity?: number | undefined;
|
|
57
59
|
fill: string;
|
|
58
|
-
stroke:
|
|
59
|
-
strokeWidth:
|
|
60
|
-
strokeStyle?: import("./types.js").StrokeStyle | undefined;
|
|
60
|
+
stroke: "#000000";
|
|
61
|
+
strokeWidth: 1;
|
|
61
62
|
};
|
|
62
63
|
/** The look of a library shape, and of an arrow. */
|
|
63
64
|
export declare const LIBRARY_SHAPE_PAINT: {
|
|
@@ -78,7 +79,11 @@ export declare function arrowEnd(options: Pick<ShapeDraftOptions, 'start' | 'end
|
|
|
78
79
|
export declare function snapPointAround(center: Point, point: Point, step: number): Point;
|
|
79
80
|
/** The shape a tool would place for a drag. */
|
|
80
81
|
export declare function buildDraggedShape(options: ShapeDraftOptions): RectObject | EllipseObject | PathObject;
|
|
81
|
-
/**
|
|
82
|
+
/**
|
|
83
|
+
* A library shape in a box, with the look and the line ends its kind has, and what the person last chose for its kind laid over that
|
|
84
|
+
* (`rememberedStyles`: the shapes' for a shape with an inside, the line icons' for a check, a cross, a plus and a minus). Null key or an
|
|
85
|
+
* unknown key gives a plain rectangle.
|
|
86
|
+
*/
|
|
82
87
|
export declare function buildLibraryShape(fields: {
|
|
83
88
|
id: ObjectId;
|
|
84
89
|
x: number;
|
|
@@ -86,5 +91,5 @@ export declare function buildLibraryShape(fields: {
|
|
|
86
91
|
width: number;
|
|
87
92
|
height: number;
|
|
88
93
|
key: string | null;
|
|
94
|
+
rememberedStyles?: RememberedStyles;
|
|
89
95
|
}): RectObject | PathObject;
|
|
90
|
-
export {};
|
|
@@ -9,6 +9,8 @@ import { buildArrow } from './arrow.js';
|
|
|
9
9
|
import { distanceBetween, rectFromPoints } from './geometry.js';
|
|
10
10
|
import { ARROW_SHAPE_KEY, TRIANGLE_SHAPE_KEY, libraryShapeKeepsAspect, libraryShapePathCommands, trianglePathCommands } from './shapePaths.js';
|
|
11
11
|
import { serializePathData } from './pathData.js';
|
|
12
|
+
import { MAX_STROKE_WIDTH, MIN_LINE_STROKE_WIDTH } from './style.js';
|
|
13
|
+
import { withRememberedStyle } from './styleMemory.js';
|
|
12
14
|
import { snapAngle } from './transform.js';
|
|
13
15
|
import { MIN_OBJECT_SIZE } from './types.js';
|
|
14
16
|
/** A drag shorter than this (in screen pixels) is a click: the shape is placed at its default size. */
|
|
@@ -42,16 +44,18 @@ function boxWithAspect(start, end, aspect) {
|
|
|
42
44
|
function centeredBox(center, width, height) {
|
|
43
45
|
return { x: center.x - width / 2, y: center.y - height / 2, width, height };
|
|
44
46
|
}
|
|
45
|
-
/**
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
/**
|
|
48
|
+
* The paint a new shape of the tools starts with, by the look the board is in. What the person chose for the shapes before is laid over
|
|
49
|
+
* it afterwards (`withRememberedStyle`), so it is the same in both looks: the wireframe look decides only how a shape starts.
|
|
50
|
+
*/
|
|
51
|
+
export function newShapePaint(wireframe, random = Math.random) {
|
|
52
|
+
return wireframe
|
|
48
53
|
? {
|
|
49
54
|
fill: SHAPE_STYLE_DEFAULTS.wireframeFill,
|
|
50
55
|
stroke: SHAPE_STYLE_DEFAULTS.wireframeStroke,
|
|
51
56
|
strokeWidth: SHAPE_STYLE_DEFAULTS.wireframeStrokeWidth
|
|
52
57
|
}
|
|
53
58
|
: { fill: randomShapeFill(random), stroke: SHAPE_STYLE_DEFAULTS.stroke, strokeWidth: SHAPE_STYLE_DEFAULTS.strokeWidth };
|
|
54
|
-
return { ...base, ...workspacePaint };
|
|
55
59
|
}
|
|
56
60
|
/** The look of a library shape, and of an arrow. */
|
|
57
61
|
export const LIBRARY_SHAPE_PAINT = { fill: '#ffffff', stroke: '#374151', strokeWidth: 3 };
|
|
@@ -95,61 +99,84 @@ export function snapPointAround(center, point, step) {
|
|
|
95
99
|
const angle = (snapAngle((Math.atan2(point.y - center.y, point.x - center.x) * 180) / Math.PI, step) * Math.PI) / 180;
|
|
96
100
|
return { x: center.x + length * Math.cos(angle), y: center.y + length * Math.sin(angle) };
|
|
97
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* The width an arrow starts with: the one the person last gave an arrow, or the Arrow tool's own. It is needed before the arrow exists,
|
|
104
|
+
* because the head of an arrow is drawn for the width of its line (a wider line has a bigger head), and the box that holds the arrow
|
|
105
|
+
* (which the drag's preview and the hit test use) is the box of that drawing.
|
|
106
|
+
*/
|
|
107
|
+
function arrowStrokeWidth(options) {
|
|
108
|
+
const remembered = options.rememberedStyles?.arrow.strokeWidth;
|
|
109
|
+
if (typeof remembered !== 'number' || !Number.isFinite(remembered))
|
|
110
|
+
return ARROW_PAINT.strokeWidth;
|
|
111
|
+
// An arrow is its line: never thinner than the thinnest, never wider than the Width control goes.
|
|
112
|
+
return Math.min(Math.max(remembered, MIN_LINE_STROKE_WIDTH), MAX_STROKE_WIDTH);
|
|
113
|
+
}
|
|
98
114
|
function arrowDragGeometry(options) {
|
|
99
|
-
return buildArrow(options.start, arrowEnd(options), 0,
|
|
115
|
+
return buildArrow(options.start, arrowEnd(options), 0, arrowStrokeWidth(options));
|
|
100
116
|
}
|
|
101
117
|
/** The shape a tool would place for a drag. */
|
|
102
118
|
export function buildDraggedShape(options) {
|
|
103
119
|
const createId = options.createId ?? createObjectId;
|
|
104
120
|
const id = createId('obj');
|
|
105
|
-
const { kind, wireframe } = options;
|
|
121
|
+
const { kind, wireframe, rememberedStyles } = options;
|
|
106
122
|
if (kind === 'arrow') {
|
|
107
123
|
const geometry = arrowDragGeometry(options);
|
|
108
|
-
|
|
124
|
+
const arrow = createPathObject({
|
|
109
125
|
id,
|
|
110
126
|
...geometry.box,
|
|
111
127
|
d: serializePathData(geometry.commands),
|
|
112
128
|
arrow: geometry.spec,
|
|
113
129
|
shape: ARROW_SHAPE_KEY,
|
|
114
130
|
...ARROW_PAINT,
|
|
131
|
+
// The width the head was drawn for (the Arrow tool's own, unless the person gave arrows another).
|
|
132
|
+
strokeWidth: arrowStrokeWidth(options),
|
|
115
133
|
lineCap: 'round',
|
|
116
134
|
lineJoin: 'round'
|
|
117
135
|
});
|
|
136
|
+
return withRememberedStyle(arrow, rememberedStyles?.arrow);
|
|
118
137
|
}
|
|
119
138
|
const box = shapeDragBox(options);
|
|
120
139
|
const width = Math.max(box.width, MIN_OBJECT_SIZE);
|
|
121
140
|
const height = Math.max(box.height, MIN_OBJECT_SIZE);
|
|
122
141
|
const frame = { id, x: box.x, y: box.y, width, height };
|
|
123
|
-
const paint = newShapePaint(wireframe, options.random
|
|
142
|
+
const paint = newShapePaint(wireframe, options.random);
|
|
143
|
+
// What the person last chose for the shapes is laid over the look the shape starts with, in the wireframe look and outside it.
|
|
144
|
+
const rememberedShape = rememberedStyles?.shape;
|
|
124
145
|
if (kind === 'rect')
|
|
125
|
-
return createRectObject({ ...frame, ...paint });
|
|
126
|
-
// The rounded square of the shapes menu: a rectangle that starts with soft corners (its Roundness control still moves them).
|
|
146
|
+
return withRememberedStyle(createRectObject({ ...frame, ...paint }), rememberedShape);
|
|
147
|
+
// The rounded square of the shapes menu: a rectangle that starts with soft corners (its Roundness control still moves them). The
|
|
148
|
+
// soft corners are what the entry is for, so the roundness the person last chose for a shape is not laid over them.
|
|
127
149
|
if (kind === 'rounded-rect') {
|
|
128
|
-
return createRectObject({ ...frame, ...paint, roundness: ROUNDED_RECT_ROUNDNESS });
|
|
150
|
+
return withRememberedStyle(createRectObject({ ...frame, ...paint, roundness: ROUNDED_RECT_ROUNDNESS }), rememberedShape, { leave: ['roundness'] });
|
|
129
151
|
}
|
|
130
152
|
if (kind === 'ellipse' || kind === 'circle') {
|
|
131
|
-
return createEllipseObject({ ...frame, ...paint, aspectLocked: kind === 'circle' });
|
|
153
|
+
return withRememberedStyle(createEllipseObject({ ...frame, ...paint, aspectLocked: kind === 'circle' }), rememberedShape);
|
|
132
154
|
}
|
|
133
155
|
if (kind === 'triangle') {
|
|
134
|
-
|
|
156
|
+
const triangle = createPathObject({
|
|
135
157
|
...frame,
|
|
136
158
|
...paint,
|
|
137
159
|
d: serializePathData(trianglePathCommands(width, height, 0)),
|
|
138
160
|
shape: TRIANGLE_SHAPE_KEY,
|
|
139
161
|
lineJoin: 'miter'
|
|
140
162
|
});
|
|
163
|
+
return withRememberedStyle(triangle, rememberedShape);
|
|
141
164
|
}
|
|
142
|
-
return buildLibraryShape({ ...frame, key: options.libraryKey ?? null });
|
|
165
|
+
return buildLibraryShape({ ...frame, key: options.libraryKey ?? null, rememberedStyles });
|
|
143
166
|
}
|
|
144
|
-
/**
|
|
167
|
+
/**
|
|
168
|
+
* A library shape in a box, with the look and the line ends its kind has, and what the person last chose for its kind laid over that
|
|
169
|
+
* (`rememberedStyles`: the shapes' for a shape with an inside, the line icons' for a check, a cross, a plus and a minus). Null key or an
|
|
170
|
+
* unknown key gives a plain rectangle.
|
|
171
|
+
*/
|
|
145
172
|
export function buildLibraryShape(fields) {
|
|
146
173
|
const shape = getShapeByKey(fields.key);
|
|
147
174
|
const frame = { id: fields.id, x: fields.x, y: fields.y, width: fields.width, height: fields.height };
|
|
148
175
|
const commands = fields.key && shape ? libraryShapePathCommands(fields.key, fields.width, fields.height, 0) : null;
|
|
149
176
|
if (!shape || !commands)
|
|
150
|
-
return createRectObject({ ...frame, ...newShapePaint(true) });
|
|
177
|
+
return withRememberedStyle(createRectObject({ ...frame, ...newShapePaint(true) }), fields.rememberedStyles?.shape);
|
|
151
178
|
const linesOnly = shape.cornerRadiusMode === 'strokeRound';
|
|
152
|
-
|
|
179
|
+
const libraryShape = createPathObject({
|
|
153
180
|
...frame,
|
|
154
181
|
...LIBRARY_SHAPE_PAINT,
|
|
155
182
|
// A line-only icon (a check, a cross) has no inside to fill.
|
|
@@ -160,4 +187,5 @@ export function buildLibraryShape(fields) {
|
|
|
160
187
|
lineCap: linesOnly ? 'butt' : 'round',
|
|
161
188
|
lineJoin: linesOnly ? 'miter' : 'round'
|
|
162
189
|
});
|
|
190
|
+
return withRememberedStyle(libraryShape, linesOnly ? fields.rememberedStyles?.lineIcon : fields.rememberedStyles?.shape);
|
|
163
191
|
}
|
|
@@ -29,8 +29,11 @@ export interface StylePatch {
|
|
|
29
29
|
}
|
|
30
30
|
/** Whether the Roundness control means something for the path (rounded corners or round line ends). */
|
|
31
31
|
export declare function pathSupportsRoundness(shapeKey: string | null): boolean;
|
|
32
|
-
/**
|
|
33
|
-
|
|
32
|
+
/**
|
|
33
|
+
* The widest a line may be made with the Width control, for every kind of shape, an arrow and a line drawn by hand (the pen's too: see
|
|
34
|
+
* `EngineCore.setPenStyle`). It was 200; a line thicker than 50 is not needed. A board saved with a thicker one opens as it was.
|
|
35
|
+
*/
|
|
36
|
+
export declare const MAX_STROKE_WIDTH = 50;
|
|
34
37
|
/** The thinnest line a shape that is only a line can be given (the brush's own least is the same): with none, nothing of it is left. */
|
|
35
38
|
export declare const MIN_LINE_STROKE_WIDTH = 1;
|
|
36
39
|
/**
|
|
@@ -46,5 +49,18 @@ export declare function paintsFillOnStroke(shape: ShapeObject): boolean;
|
|
|
46
49
|
* follow the pressure) the fill of that outline. The panel's Stroke colour and the shape snap read and write the line this way.
|
|
47
50
|
*/
|
|
48
51
|
export declare function lineColorOf(shape: ShapeObject): string;
|
|
52
|
+
/**
|
|
53
|
+
* A number of a patch brought into the range its key has (a width from 0 to 50, an opacity from 0 to 1, a size from 4 to 600 ...). A key
|
|
54
|
+
* with no range keeps the number as it is. The one place the ranges are applied, so a value kept for later and a value written to a shape
|
|
55
|
+
* can never disagree on what the key allows.
|
|
56
|
+
*/
|
|
57
|
+
export declare function clampedStyleNumber(key: keyof StylePatch, value: number): number;
|
|
58
|
+
/**
|
|
59
|
+
* The keys of a patch that a shape takes, at the values it takes them at: what `applyStylePatch` writes into the shape, whether or not
|
|
60
|
+
* the shape already has it. A number is brought into its range, a line is never made so thin that it is gone, and the Fill of a shape
|
|
61
|
+
* that is only a line (a check, a cross) is its Stroke. This is also what an edit of the selection says about the next element of its
|
|
62
|
+
* kind (see `styleMemory.ts`), so the memory and the shape always agree on what a value is.
|
|
63
|
+
*/
|
|
64
|
+
export declare function acceptedStylePatch(shape: ShapeObject, requested: StylePatch): StylePatch;
|
|
49
65
|
/** Applies the keys of a patch that mean something for the shape. Same object back when nothing changes. */
|
|
50
66
|
export declare function applyStylePatch(shape: ShapeObject, requested: StylePatch): ShapeObject;
|
|
@@ -53,8 +53,11 @@ export function pathSupportsRoundness(shapeKey) {
|
|
|
53
53
|
function roundnessIsLineEnds(shapeKey) {
|
|
54
54
|
return getShapeByKey(shapeKey)?.cornerRadiusMode === 'strokeRound';
|
|
55
55
|
}
|
|
56
|
-
/**
|
|
57
|
-
|
|
56
|
+
/**
|
|
57
|
+
* The widest a line may be made with the Width control, for every kind of shape, an arrow and a line drawn by hand (the pen's too: see
|
|
58
|
+
* `EngineCore.setPenStyle`). It was 200; a line thicker than 50 is not needed. A board saved with a thicker one opens as it was.
|
|
59
|
+
*/
|
|
60
|
+
export const MAX_STROKE_WIDTH = 50;
|
|
58
61
|
/** The thinnest line a shape that is only a line can be given (the brush's own least is the same): with none, nothing of it is left. */
|
|
59
62
|
export const MIN_LINE_STROKE_WIDTH = 1;
|
|
60
63
|
/**
|
|
@@ -94,49 +97,78 @@ export function lineColorOf(shape) {
|
|
|
94
97
|
return shape.type === 'rect' || shape.type === 'ellipse' || shape.type === 'path' ? shape.stroke : '';
|
|
95
98
|
}
|
|
96
99
|
/**
|
|
97
|
-
*
|
|
98
|
-
*
|
|
100
|
+
* The keys of a patch that a brush stroke takes, at the values it takes them at: the Stroke colour is the colour of the outline, the
|
|
101
|
+
* Width is the nominal width of the brush (from the brush's least to the widest), and the opacity is the whole stroke's. Everything else
|
|
102
|
+
* the patch carries means nothing to a stroke and is left out.
|
|
99
103
|
*/
|
|
104
|
+
function acceptedBrushStylePatch(patch) {
|
|
105
|
+
const accepted = {};
|
|
106
|
+
if (patch.opacity !== undefined)
|
|
107
|
+
accepted.opacity = clampNumber(patch.opacity, 0, 1);
|
|
108
|
+
if (patch.stroke !== undefined)
|
|
109
|
+
accepted.stroke = patch.stroke;
|
|
110
|
+
if (patch.strokeWidth !== undefined)
|
|
111
|
+
accepted.strokeWidth = clampNumber(patch.strokeWidth, MIN_BRUSH_WIDTH, MAX_STROKE_WIDTH);
|
|
112
|
+
return accepted;
|
|
113
|
+
}
|
|
114
|
+
/** A patch for a brush stroke: the Stroke colour is the colour of the outline, the Width draws the brush again at the new width. Same object back when nothing changes. */
|
|
100
115
|
function applyBrushStylePatch(shape, patch) {
|
|
116
|
+
const accepted = acceptedBrushStylePatch(patch);
|
|
101
117
|
let next = shape;
|
|
102
|
-
if (
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
next = { ...next, fill: patch.stroke };
|
|
109
|
-
if (patch.strokeWidth !== undefined) {
|
|
110
|
-
const strokeWidth = clampNumber(patch.strokeWidth, MIN_BRUSH_WIDTH, MAX_STROKE_WIDTH);
|
|
111
|
-
if (strokeWidth !== next.strokeWidth)
|
|
112
|
-
next = reshapeBrushStroke(next, { strokeWidth });
|
|
113
|
-
}
|
|
118
|
+
if (accepted.opacity !== undefined && accepted.opacity !== next.opacity)
|
|
119
|
+
next = { ...next, opacity: accepted.opacity };
|
|
120
|
+
if (accepted.stroke !== undefined && accepted.stroke !== next.fill)
|
|
121
|
+
next = { ...next, fill: accepted.stroke };
|
|
122
|
+
if (accepted.strokeWidth !== undefined && accepted.strokeWidth !== next.strokeWidth)
|
|
123
|
+
next = reshapeBrushStroke(next, { strokeWidth: accepted.strokeWidth });
|
|
114
124
|
return next;
|
|
115
125
|
}
|
|
116
|
-
/**
|
|
117
|
-
|
|
126
|
+
/**
|
|
127
|
+
* A number of a patch brought into the range its key has (a width from 0 to 50, an opacity from 0 to 1, a size from 4 to 600 ...). A key
|
|
128
|
+
* with no range keeps the number as it is. The one place the ranges are applied, so a value kept for later and a value written to a shape
|
|
129
|
+
* can never disagree on what the key allows.
|
|
130
|
+
*/
|
|
131
|
+
export function clampedStyleNumber(key, value) {
|
|
132
|
+
const range = RANGES[key];
|
|
133
|
+
return range ? clampNumber(value, range[0], range[1]) : value;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* The keys of a patch that a shape takes, at the values it takes them at: what `applyStylePatch` writes into the shape, whether or not
|
|
137
|
+
* the shape already has it. A number is brought into its range, a line is never made so thin that it is gone, and the Fill of a shape
|
|
138
|
+
* that is only a line (a check, a cross) is its Stroke. This is also what an edit of the selection says about the next element of its
|
|
139
|
+
* kind (see `styleMemory.ts`), so the memory and the shape always agree on what a value is.
|
|
140
|
+
*/
|
|
141
|
+
export function acceptedStylePatch(shape, requested) {
|
|
118
142
|
if (isBrushStroke(shape))
|
|
119
|
-
return
|
|
143
|
+
return acceptedBrushStylePatch(requested);
|
|
120
144
|
let patch = requested;
|
|
121
145
|
if (patch.fill !== undefined && paintsFillOnStroke(shape)) {
|
|
122
146
|
// The panel's Fill colour is the colour of the line for these icons.
|
|
123
147
|
const { fill, ...rest } = patch;
|
|
124
148
|
patch = { ...rest, stroke: fill };
|
|
125
149
|
}
|
|
126
|
-
const
|
|
127
|
-
const
|
|
128
|
-
for (const key of allowed) {
|
|
150
|
+
const accepted = {};
|
|
151
|
+
for (const key of keysFor(shape)) {
|
|
129
152
|
if (!(key in patch))
|
|
130
153
|
continue;
|
|
131
154
|
let value = patch[key];
|
|
132
155
|
if (value === undefined)
|
|
133
156
|
continue;
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
value = clampNumber(value, range[0], range[1]);
|
|
157
|
+
if (typeof value === 'number')
|
|
158
|
+
value = clampedStyleNumber(key, value);
|
|
137
159
|
// A line is never made so thin that it is gone (an arrow with no line would vanish with nothing left to take hold of).
|
|
138
160
|
if (key === 'strokeWidth' && typeof value === 'number')
|
|
139
161
|
value = Math.max(value, minimumStrokeWidthOf(shape));
|
|
162
|
+
accepted[key] = value;
|
|
163
|
+
}
|
|
164
|
+
return accepted;
|
|
165
|
+
}
|
|
166
|
+
/** Applies the keys of a patch that mean something for the shape. Same object back when nothing changes. */
|
|
167
|
+
export function applyStylePatch(shape, requested) {
|
|
168
|
+
if (isBrushStroke(shape))
|
|
169
|
+
return applyBrushStylePatch(shape, requested);
|
|
170
|
+
const changes = {};
|
|
171
|
+
for (const [key, value] of Object.entries(acceptedStylePatch(shape, requested))) {
|
|
140
172
|
if (shape[key] !== value)
|
|
141
173
|
changes[key] = value;
|
|
142
174
|
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the board remembers of how the person last styled each kind of element, so that the next element of that kind starts the way
|
|
3
|
+
* the last one was left ("after changing the fill and the colour of the stroke and the stroke width, those should be maintained across
|
|
4
|
+
* all the shapes until the user edits them again. The same should be true for the other elements as well", 19 Nov 2026).
|
|
5
|
+
*
|
|
6
|
+
* An element is of one of five kinds, and each kind remembers only what the person did to elements of that kind:
|
|
7
|
+
*
|
|
8
|
+
* - `shape`: a rectangle, an ellipse, a triangle and every shape of the library that has an inside (fill, stroke, width, opacity, roundness).
|
|
9
|
+
* - `lineIcon`: the four shapes of the library that are only a line (a check, a cross, a plus, a minus): the colour of the line, its width,
|
|
10
|
+
* its opacity and how round its ends are. They have no inside, so a fill chosen for a rectangle is no business of theirs, and a colour
|
|
11
|
+
* chosen for a check does not turn the next rectangle's outline.
|
|
12
|
+
* - `arrow`: the colour, the width and the opacity of the line (an arrow has no inside and no corners).
|
|
13
|
+
* - `text`: the font, the size, bold, italic, underline, the alignment, the colour of the letters and the opacity.
|
|
14
|
+
* - `pen`: a line drawn by hand. Its three settings are the pen of the Draw tool (`EngineState.penStyle`), so an edit of a drawn line is
|
|
15
|
+
* an edit of the pen, and the engine keeps the pen itself; this file only says that the edit is one.
|
|
16
|
+
*
|
|
17
|
+
* The memory is a set of patches in the panel's own keys (`StylePatch`). An edit of the selection is turned into one by `styleEditOf`,
|
|
18
|
+
* through `acceptedStylePatch`, so a value is remembered exactly as the shape took it (a width of 0 is 1 for an arrow, a width of 900 is
|
|
19
|
+
* 50), and a new element is given the memory by `withRememberedStyle`, through `applyStylePatch`, the one door every style goes through:
|
|
20
|
+
* the head of an arrow follows its width and the corners of a triangle are drawn again for their roundness, as when the panel is used.
|
|
21
|
+
*
|
|
22
|
+
* Everything here is a pure function of values. The engine holds the memory, records the edits of `setStyle` into it and tells the host,
|
|
23
|
+
* which keeps it for the workspace (`CanvasHost`, `workspaceToolSettings.ts`).
|
|
24
|
+
*/
|
|
25
|
+
import type { StylePatch } from './style.js';
|
|
26
|
+
import type { ShapeObject } from './types.js';
|
|
27
|
+
/** The kinds of element whose last style is remembered. */
|
|
28
|
+
export type StyleMemoryKind = 'shape' | 'lineIcon' | 'arrow' | 'text' | 'pen';
|
|
29
|
+
/** The kinds remembered as a patch of the panel's keys: the pen is not (it is the pen of the Draw tool, `EngineState.penStyle`). */
|
|
30
|
+
export type PatchedStyleKind = Exclude<StyleMemoryKind, 'pen'>;
|
|
31
|
+
export declare const PATCHED_STYLE_KINDS: readonly PatchedStyleKind[];
|
|
32
|
+
/**
|
|
33
|
+
* The keys of an edit that each kind remembers. What is not here is the element's own business and is never carried over: its place and
|
|
34
|
+
* size, its text, how it is rotated, what it is tied to. (A key that a kind does not take at all, such as a fill for an arrow, is not
|
|
35
|
+
* here either: `acceptedStylePatch` has already dropped it.)
|
|
36
|
+
*/
|
|
37
|
+
export declare const REMEMBERED_STYLE_KEYS: Readonly<Record<StyleMemoryKind, readonly (keyof StylePatch)[]>>;
|
|
38
|
+
/** The kind of element a shape is, or null for what has no style to remember (a picture, a widget card). */
|
|
39
|
+
export declare function styleMemoryKindOf(shape: ShapeObject): StyleMemoryKind | null;
|
|
40
|
+
/** What an edit of one element says about the next element of its kind. */
|
|
41
|
+
export interface StyleEdit {
|
|
42
|
+
kind: StyleMemoryKind;
|
|
43
|
+
style: StylePatch;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* What an edit says about the next element of the shape's kind: the keys of the patch that the shape takes and that its kind
|
|
47
|
+
* remembers, at the values the shape takes them at. Null when it says nothing (a picture, or a patch of keys the kind has no use for).
|
|
48
|
+
*
|
|
49
|
+
* The keys the shape already holds are in it too: a person who picks the colour a shape has already has said what the next one should
|
|
50
|
+
* be, and it may be another colour than the memory holds.
|
|
51
|
+
*/
|
|
52
|
+
export declare function styleEditOf(shape: ShapeObject, patch: StylePatch): StyleEdit | null;
|
|
53
|
+
/** The last style of each kind of element that is remembered as a patch (empty where the person has not styled one yet). */
|
|
54
|
+
export type RememberedStyles = {
|
|
55
|
+
readonly [kind in PatchedStyleKind]: Readonly<StylePatch>;
|
|
56
|
+
};
|
|
57
|
+
export declare const NO_REMEMBERED_STYLES: RememberedStyles;
|
|
58
|
+
/**
|
|
59
|
+
* The memory with some edits laid over it, and the kinds that came out different. Where the edits say nothing new the very same object
|
|
60
|
+
* comes back with no kind named, so a drag that goes on saying the same colour tells nobody anything. The pen is not part of the memory
|
|
61
|
+
* (the engine keeps it), so an edit of a drawn line is passed over here.
|
|
62
|
+
*/
|
|
63
|
+
export declare function rememberStyleEdits(styles: RememberedStyles, edits: readonly StyleEdit[]): {
|
|
64
|
+
styles: RememberedStyles;
|
|
65
|
+
changed: PatchedStyleKind[];
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* What the storage holds for a kind, as a memory can hold it: key by key, a value that is not one of the key is dropped (the rest stays),
|
|
69
|
+
* a number is brought into its range (a width that was kept when the widest was 200 comes down to 50), and a key the kind does not
|
|
70
|
+
* remember is left out. Anything that is not an object is no memory at all.
|
|
71
|
+
*/
|
|
72
|
+
export declare function sanitizeRememberedStyle(kind: PatchedStyleKind, stored: unknown): Readonly<StylePatch>;
|
|
73
|
+
/**
|
|
74
|
+
* What the storage holds for every kind, as a memory can hold it (`sanitizeRememberedStyle` for each). Nothing stored: nothing remembered.
|
|
75
|
+
* A kind the storage has no part for is nothing remembered for that kind.
|
|
76
|
+
*/
|
|
77
|
+
export declare function sanitizeRememberedStyles(stored: {
|
|
78
|
+
readonly [kind in PatchedStyleKind]?: unknown;
|
|
79
|
+
} | null): RememberedStyles;
|
|
80
|
+
/**
|
|
81
|
+
* A new element with what the person last chose for its kind laid over what it starts with. `leave` names keys of the memory that the
|
|
82
|
+
* element keeps as it starts (the rounded square keeps the soft corners it is chosen for). The element comes out as the panel would
|
|
83
|
+
* make it: the head of an arrow follows its width, the corners of a triangle are drawn again for their roundness. The very same object
|
|
84
|
+
* back when there is nothing to lay over.
|
|
85
|
+
*/
|
|
86
|
+
export declare function withRememberedStyle<Element extends ShapeObject>(element: Element, remembered: Readonly<StylePatch> | undefined, options?: {
|
|
87
|
+
leave?: readonly (keyof StylePatch)[];
|
|
88
|
+
}): Element;
|