plotboilerplate 1.27.1 → 1.28.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/index.esm.js +135 -36
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/plotboilerplate.browser.min.js +1 -1
- package/dist/plotboilerplate.browser.min.js.map +1 -1
- package/dist/plotboilerplate.js +96 -17
- package/dist/plotboilerplate.min.js +1 -1
- package/package.json +2 -1
- package/src/cjs/PlotBoilerplate.d.ts +11 -1
- package/src/cjs/PlotBoilerplate.js +23 -7
- package/src/cjs/PlotBoilerplate.js.map +1 -1
- package/src/cjs/VertexListeners.d.ts +2 -1
- package/src/cjs/VertexListeners.js +5 -1
- package/src/cjs/VertexListeners.js.map +1 -1
- package/src/cjs/draw.d.ts +18 -2
- package/src/cjs/draw.js +21 -2
- package/src/cjs/draw.js.map +1 -1
- package/src/cjs/drawgl.d.ts +18 -3
- package/src/cjs/drawgl.js +19 -2
- package/src/cjs/drawgl.js.map +1 -1
- package/src/cjs/drawutilssvg.d.ts +19 -1
- package/src/cjs/drawutilssvg.js +28 -5
- package/src/cjs/drawutilssvg.js.map +1 -1
- package/src/cjs/interfaces/DrawLib.d.ts +18 -1
- package/src/cjs/interfaces/DrawLib.js +2 -0
- package/src/cjs/interfaces/DrawLib.js.map +1 -1
- package/src/cjs/utils/Params.d.ts +3 -2
- package/src/cjs/utils/Params.js +11 -3
- package/src/cjs/utils/Params.js.map +1 -1
- package/src/cjs/utils/WebColors.d.ts +2 -1
- package/src/cjs/utils/WebColors.js +15 -2
- package/src/cjs/utils/WebColors.js.map +1 -1
- package/src/cjs/utils/algorithms/HobbyPath.js +13 -16
- package/src/cjs/utils/algorithms/HobbyPath.js.map +1 -1
- package/src/cjs/utils/helpers/BezierResizeHelper.d.ts +144 -0
- package/src/cjs/utils/helpers/BezierResizeHelper.js +319 -0
- package/src/cjs/utils/helpers/BezierResizeHelper.js.map +1 -0
- package/src/esm/PlotBoilerplate.d.ts +11 -1
- package/src/esm/PlotBoilerplate.js +23 -7
- package/src/esm/PlotBoilerplate.js.map +1 -1
- package/src/esm/VertexListeners.d.ts +2 -1
- package/src/esm/VertexListeners.js +5 -1
- package/src/esm/VertexListeners.js.map +1 -1
- package/src/esm/draw.d.ts +18 -2
- package/src/esm/draw.js +21 -2
- package/src/esm/draw.js.map +1 -1
- package/src/esm/drawgl.d.ts +18 -3
- package/src/esm/drawgl.js +19 -2
- package/src/esm/drawgl.js.map +1 -1
- package/src/esm/drawutilssvg.d.ts +19 -1
- package/src/esm/drawutilssvg.js +28 -5
- package/src/esm/drawutilssvg.js.map +1 -1
- package/src/esm/interfaces/DrawLib.d.ts +18 -1
- package/src/esm/interfaces/DrawLib.js +2 -0
- package/src/esm/interfaces/DrawLib.js.map +1 -1
- package/src/esm/utils/Params.d.ts +3 -2
- package/src/esm/utils/Params.js +11 -3
- package/src/esm/utils/Params.js.map +1 -1
- package/src/esm/utils/WebColors.d.ts +2 -1
- package/src/esm/utils/WebColors.js +15 -2
- package/src/esm/utils/WebColors.js.map +1 -1
- package/src/esm/utils/algorithms/HobbyPath.js +13 -16
- package/src/esm/utils/algorithms/HobbyPath.js.map +1 -1
- package/src/esm/utils/helpers/BezierResizeHelper.d.ts +144 -0
- package/src/esm/utils/helpers/BezierResizeHelper.js +314 -0
- package/src/esm/utils/helpers/BezierResizeHelper.js.map +1 -0
- package/src/ts/PlotBoilerplate.ts +37 -11
- package/src/ts/VertexListeners.ts +5 -1
- package/src/ts/draw.ts +32 -2
- package/src/ts/drawgl.ts +38 -3
- package/src/ts/drawutilssvg.ts +33 -6
- package/src/ts/interfaces/DrawLib.ts +19 -1
- package/src/ts/utils/Params.ts +11 -3
- package/src/ts/utils/WebColors.ts +15 -2
- package/src/ts/utils/algorithms/HobbyPath.ts +248 -272
- package/src/ts/utils/helpers/BezierResizeHelper.ts +390 -0
- package/src/cjs/utils/_gup.js_ +0 -13
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A helper to resize bezier paths in horizontal and vertical orientation.
|
|
3
|
+
*
|
|
4
|
+
* @requires PlotBoilerplate
|
|
5
|
+
* @requires BezierPath
|
|
6
|
+
* @requires Vertex
|
|
7
|
+
*
|
|
8
|
+
* @author Ikaros Kappler
|
|
9
|
+
* @date 2026-04-04 Copied from the ngdg project, made minor type adaptions.
|
|
10
|
+
* @version 1.2.0
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { BezierPath } from "../../BezierPath";
|
|
15
|
+
import PlotBoilerplate from "../../PlotBoilerplate";
|
|
16
|
+
import { Vertex } from "../../Vertex";
|
|
17
|
+
import { DrawLib, XYCoords } from "../../interfaces";
|
|
18
|
+
|
|
19
|
+
// A closure to hide helper functions.
|
|
20
|
+
export class BezierResizeHelper {
|
|
21
|
+
private pb: PlotBoilerplate;
|
|
22
|
+
|
|
23
|
+
public readonly bezierPath: BezierPath;
|
|
24
|
+
public readonly topResizeHandle: Vertex;
|
|
25
|
+
public readonly leftResizeHandle: Vertex;
|
|
26
|
+
public readonly bottomResizeHandle: Vertex;
|
|
27
|
+
public readonly rightResizeHandle: Vertex;
|
|
28
|
+
|
|
29
|
+
topHandleDragStartPosition: XYCoords;
|
|
30
|
+
leftHandleDragStartPosition: XYCoords;
|
|
31
|
+
bottomHandleDragStartPosition: XYCoords;
|
|
32
|
+
rightHandleDragStartPosition: XYCoords;
|
|
33
|
+
__listeners: Array<() => void>;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The constructor.
|
|
37
|
+
*
|
|
38
|
+
* @param {PlotBoilerplate} pb
|
|
39
|
+
* @param {BezierPath} bezierPath
|
|
40
|
+
* @param {function} updateCallback
|
|
41
|
+
*/
|
|
42
|
+
constructor(pb: PlotBoilerplate, bezierPath: BezierPath, updateCallback: () => void) {
|
|
43
|
+
this.pb = pb;
|
|
44
|
+
this.bezierPath = bezierPath;
|
|
45
|
+
|
|
46
|
+
// @public
|
|
47
|
+
this.topResizeHandle = new Vertex(0, 0);
|
|
48
|
+
this.leftResizeHandle = new Vertex(0, 0);
|
|
49
|
+
this.bottomResizeHandle = new Vertex(0, 0);
|
|
50
|
+
this.rightResizeHandle = new Vertex(0, 0);
|
|
51
|
+
|
|
52
|
+
// @private
|
|
53
|
+
this.topHandleDragStartPosition = null;
|
|
54
|
+
this.leftHandleDragStartPosition = null;
|
|
55
|
+
this.bottomHandleDragStartPosition = null;
|
|
56
|
+
this.rightHandleDragStartPosition = null;
|
|
57
|
+
|
|
58
|
+
this.__listeners = this.__installListeners(this, pb, bezierPath, updateCallback);
|
|
59
|
+
this.updateResizeHandles();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
draw(draw: DrawLib<any>, fill: DrawLib<any>) {
|
|
63
|
+
this.drawHandleLines(draw, fill, "grey");
|
|
64
|
+
this.drawTriangles(draw, fill, "rgba(0,192,192,1.0)");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Call this method from the outside to see active helper lines for those edges
|
|
69
|
+
* that are currently dragged.
|
|
70
|
+
*
|
|
71
|
+
* @param {DrawLib<any>} draw
|
|
72
|
+
* @param {DrawLib<any>} fill
|
|
73
|
+
* @param {string} lineColor
|
|
74
|
+
*/
|
|
75
|
+
drawHandleLines(draw: DrawLib<any>, fill: DrawLib<any>, lineColor: string) {
|
|
76
|
+
// console.log("drawResizeHandleLines", bezierResizer.verticalResizeHandleDragStartPosition);
|
|
77
|
+
var bounds = this.bezierPath.getBounds();
|
|
78
|
+
if (this.topHandleDragStartPosition) {
|
|
79
|
+
draw.line({ x: bounds.min.x, y: this.topResizeHandle.y }, { x: bounds.max.x, y: this.topResizeHandle.y }, lineColor, 1.0, {
|
|
80
|
+
dashOffset: 0.0,
|
|
81
|
+
dashArray: [5, 5]
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
if (this.leftHandleDragStartPosition) {
|
|
85
|
+
draw.line(
|
|
86
|
+
{ x: this.leftResizeHandle.x, y: bounds.min.y },
|
|
87
|
+
{ x: this.leftResizeHandle.x, y: bounds.max.y },
|
|
88
|
+
lineColor,
|
|
89
|
+
1.0,
|
|
90
|
+
{ dashOffset: 0.0, dashArray: [5, 5] }
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
if (this.bottomHandleDragStartPosition) {
|
|
94
|
+
draw.line(
|
|
95
|
+
{ x: bounds.min.x, y: this.bottomResizeHandle.y },
|
|
96
|
+
{ x: bounds.max.x, y: this.bottomResizeHandle.y },
|
|
97
|
+
lineColor,
|
|
98
|
+
1.0,
|
|
99
|
+
{
|
|
100
|
+
dashOffset: 0.0,
|
|
101
|
+
dashArray: [5, 5]
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
if (this.rightHandleDragStartPosition) {
|
|
106
|
+
draw.line(
|
|
107
|
+
{ x: this.rightResizeHandle.x, y: bounds.min.y },
|
|
108
|
+
{ x: this.rightResizeHandle.x, y: bounds.max.y },
|
|
109
|
+
lineColor,
|
|
110
|
+
1.0,
|
|
111
|
+
{ dashOffset: 0.0, dashArray: [5, 5] }
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
public drawTriangles(draw: DrawLib<any>, _fill: DrawLib<any>, color: string) {
|
|
117
|
+
// this.__drawUpTriangle(draw, this.topResizeHandle, color);
|
|
118
|
+
// this.__drawDownTriangle(draw, this.bottomResizeHandle, color);
|
|
119
|
+
// this.__drawLeftTriangle(draw, this.leftResizeHandle, color);
|
|
120
|
+
// this.__drawRightTriangle(draw, this.rightResizeHandle, color);
|
|
121
|
+
this.drawTopTriangle(draw, _fill, color);
|
|
122
|
+
this.drawLeftTriangle(draw, _fill, color);
|
|
123
|
+
this.drawBottomTriangle(draw, _fill, color);
|
|
124
|
+
this.drawRightTriangle(draw, _fill, color);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Draws an up-trinangle at the top handle position.
|
|
129
|
+
*
|
|
130
|
+
* @param draw
|
|
131
|
+
* @param position
|
|
132
|
+
* @param color
|
|
133
|
+
*/
|
|
134
|
+
drawTopTriangle(draw: DrawLib<any>, _fill: DrawLib<any>, color: string) {
|
|
135
|
+
this.__drawUpTriangle(draw, _fill, this.topResizeHandle, color);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Draws an up-trinangle at the top handle position.
|
|
140
|
+
*
|
|
141
|
+
* @param draw
|
|
142
|
+
* @param position
|
|
143
|
+
* @param color
|
|
144
|
+
*/
|
|
145
|
+
drawLeftTriangle(draw: DrawLib<any>, _fill: DrawLib<any>, color: string) {
|
|
146
|
+
this.__drawLeftTriangle(draw, _fill, this.leftResizeHandle, color);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Draws an up-trinangle at the top handle position.
|
|
151
|
+
*
|
|
152
|
+
* @param draw
|
|
153
|
+
* @param position
|
|
154
|
+
* @param color
|
|
155
|
+
*/
|
|
156
|
+
drawBottomTriangle(draw: DrawLib<any>, _fill: DrawLib<any>, color: string) {
|
|
157
|
+
this.__drawDownTriangle(draw, _fill, this.bottomResizeHandle, color);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Draws an right-trinangle at the top handle position.
|
|
162
|
+
*
|
|
163
|
+
* @param draw
|
|
164
|
+
* @param position
|
|
165
|
+
* @param color
|
|
166
|
+
*/
|
|
167
|
+
drawRightTriangle(draw: DrawLib<any>, _fill: DrawLib<any>, color: string) {
|
|
168
|
+
this.__drawRightTriangle(draw, _fill, this.rightResizeHandle, color);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Draws an up-trinangle at the top handle position.
|
|
173
|
+
*
|
|
174
|
+
* @param draw
|
|
175
|
+
* @param position
|
|
176
|
+
* @param color
|
|
177
|
+
*/
|
|
178
|
+
private __drawUpTriangle(draw: DrawLib<any>, _fill: DrawLib<any>, position: XYCoords, color: string) {
|
|
179
|
+
const arrowSize = 6.0;
|
|
180
|
+
const arrowSizeH = arrowSize / this.pb.config.scaleX;
|
|
181
|
+
const arrowSizeV = arrowSize / this.pb.config.scaleY;
|
|
182
|
+
const verts: XYCoords[] = [
|
|
183
|
+
{ x: position.x - arrowSizeH, y: position.y + arrowSizeV * 0.5 }, // left corner
|
|
184
|
+
{ x: position.x, y: position.y - arrowSizeV }, // up corner
|
|
185
|
+
{ x: position.x + arrowSizeH, y: position.y + arrowSizeV * 0.5 } // right corner
|
|
186
|
+
];
|
|
187
|
+
draw.polyline(verts, false, color, 1.0);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Draws an left-trinangle at the left handle position.
|
|
192
|
+
*
|
|
193
|
+
* @param draw
|
|
194
|
+
* @param position
|
|
195
|
+
* @param color
|
|
196
|
+
*/
|
|
197
|
+
private __drawLeftTriangle(draw: DrawLib<any>, _fill: DrawLib<any>, position: XYCoords, color: string) {
|
|
198
|
+
const arrowSize = 6.0;
|
|
199
|
+
const arrowSizeH = arrowSize / this.pb.config.scaleX;
|
|
200
|
+
const arrowSizeV = arrowSize / this.pb.config.scaleY;
|
|
201
|
+
const verts: XYCoords[] = [
|
|
202
|
+
{ x: position.x - arrowSizeH, y: position.y }, // left corner
|
|
203
|
+
{ x: position.x + arrowSizeH * 0.5, y: position.y - arrowSizeV }, // up corner
|
|
204
|
+
{ x: position.x + arrowSizeH * 0.5, y: position.y + arrowSizeV } // down corner
|
|
205
|
+
];
|
|
206
|
+
draw.polyline(verts, false, color, 1.0);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Draws a down-trinangle at the top handle position.
|
|
211
|
+
*
|
|
212
|
+
* @param draw
|
|
213
|
+
* @param position
|
|
214
|
+
* @param color
|
|
215
|
+
*/
|
|
216
|
+
private __drawDownTriangle(draw: DrawLib<any>, _fill: DrawLib<any>, position: XYCoords, color: string) {
|
|
217
|
+
const arrowSize = 6.0;
|
|
218
|
+
const arrowSizeH = arrowSize / this.pb.config.scaleX;
|
|
219
|
+
const arrowSizeV = arrowSize / this.pb.config.scaleY;
|
|
220
|
+
const verts: XYCoords[] = [
|
|
221
|
+
{ x: position.x + arrowSizeH, y: position.y - arrowSizeV * 0.5 }, // right corner
|
|
222
|
+
{ x: position.x, y: position.y + arrowSizeV }, // down corner
|
|
223
|
+
{ x: position.x - arrowSizeH, y: position.y - arrowSizeV * 0.5 } // left corner
|
|
224
|
+
];
|
|
225
|
+
draw.polyline(verts, false, color, 1.0);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Draws an left-trinangle at the left handle position.
|
|
230
|
+
*
|
|
231
|
+
* @param draw
|
|
232
|
+
* @param position
|
|
233
|
+
* @param color
|
|
234
|
+
*/
|
|
235
|
+
private __drawRightTriangle(draw: DrawLib<any>, _fill: DrawLib<any>, position: XYCoords, color: string) {
|
|
236
|
+
const arrowSize = 6.0;
|
|
237
|
+
const arrowSizeH = arrowSize / this.pb.config.scaleX;
|
|
238
|
+
const arrowSizeV = arrowSize / this.pb.config.scaleY;
|
|
239
|
+
const verts: XYCoords[] = [
|
|
240
|
+
{ x: position.x + arrowSizeH, y: position.y }, // left corner
|
|
241
|
+
{ x: position.x - arrowSizeH * 0.5, y: position.y - arrowSizeV }, // up corner
|
|
242
|
+
{ x: position.x - arrowSizeH * 0.5, y: position.y + arrowSizeV } // down corner
|
|
243
|
+
];
|
|
244
|
+
draw.polyline(verts, false, color, 1.0);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Destroys this helper by removing all previously installed vertex listeners.
|
|
249
|
+
*/
|
|
250
|
+
destroy() {
|
|
251
|
+
this.topResizeHandle.listeners.removeDragStartListener(this.__listeners[0]);
|
|
252
|
+
this.topResizeHandle.listeners.removeDragEndListener(this.__listeners[1]);
|
|
253
|
+
this.leftResizeHandle.listeners.removeDragStartListener(this.__listeners[2]);
|
|
254
|
+
this.leftResizeHandle.listeners.removeDragEndListener(this.__listeners[3]);
|
|
255
|
+
this.bottomResizeHandle.listeners.removeDragStartListener(this.__listeners[4]);
|
|
256
|
+
this.bottomResizeHandle.listeners.removeDragEndListener(this.__listeners[5]);
|
|
257
|
+
this.rightResizeHandle.listeners.removeDragStartListener(this.__listeners[6]);
|
|
258
|
+
this.rightResizeHandle.listeners.removeDragEndListener(this.__listeners[7]);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Install all required drag-start and drag-end listeners.
|
|
263
|
+
*/
|
|
264
|
+
private __installListeners(_self: BezierResizeHelper, pb: PlotBoilerplate, bezierPath: BezierPath, updateCallback: () => void) {
|
|
265
|
+
var listeners = [];
|
|
266
|
+
listeners.push(
|
|
267
|
+
_self.topResizeHandle.listeners.addDragStartListener(function (e) {
|
|
268
|
+
var relPos = pb.transformMousePosition(e.params.draggedFrom.x, e.params.draggedFrom.y);
|
|
269
|
+
_self.topHandleDragStartPosition = relPos;
|
|
270
|
+
})
|
|
271
|
+
);
|
|
272
|
+
listeners.push(
|
|
273
|
+
_self.topResizeHandle.listeners.addDragEndListener(function (e) {
|
|
274
|
+
var relTargetPos = pb.transformMousePosition(e.params.pos.x, e.params.pos.y);
|
|
275
|
+
var targetHeightDifference = _self.topHandleDragStartPosition.y - relTargetPos.y;
|
|
276
|
+
_self.__changePathHeightTop(bezierPath, targetHeightDifference);
|
|
277
|
+
_self.updateResizeHandles();
|
|
278
|
+
_self.topHandleDragStartPosition = null;
|
|
279
|
+
updateCallback();
|
|
280
|
+
})
|
|
281
|
+
);
|
|
282
|
+
|
|
283
|
+
listeners.push(
|
|
284
|
+
_self.leftResizeHandle.listeners.addDragStartListener(function (e) {
|
|
285
|
+
var relPos = pb.transformMousePosition(e.params.draggedFrom.x, e.params.draggedFrom.y);
|
|
286
|
+
_self.leftHandleDragStartPosition = relPos;
|
|
287
|
+
})
|
|
288
|
+
);
|
|
289
|
+
listeners.push(
|
|
290
|
+
_self.leftResizeHandle.listeners.addDragEndListener(function (e) {
|
|
291
|
+
var relTargetPos = pb.transformMousePosition(e.params.pos.x, e.params.pos.y);
|
|
292
|
+
var targetWidthDifference = _self.leftHandleDragStartPosition.x - relTargetPos.x;
|
|
293
|
+
_self.__changePathWidthLeft(bezierPath, targetWidthDifference);
|
|
294
|
+
_self.updateResizeHandles();
|
|
295
|
+
_self.leftHandleDragStartPosition = null;
|
|
296
|
+
updateCallback();
|
|
297
|
+
})
|
|
298
|
+
);
|
|
299
|
+
|
|
300
|
+
listeners.push(
|
|
301
|
+
_self.bottomResizeHandle.listeners.addDragStartListener(function (e) {
|
|
302
|
+
var relPos = pb.transformMousePosition(e.params.draggedFrom.x, e.params.draggedFrom.y);
|
|
303
|
+
_self.bottomHandleDragStartPosition = relPos;
|
|
304
|
+
})
|
|
305
|
+
);
|
|
306
|
+
listeners.push(
|
|
307
|
+
_self.bottomResizeHandle.listeners.addDragEndListener(function (e) {
|
|
308
|
+
var relTargetPos = pb.transformMousePosition(e.params.pos.x, e.params.pos.y);
|
|
309
|
+
var targetHeightDifference = relTargetPos.y - _self.bottomHandleDragStartPosition.y;
|
|
310
|
+
_self.__changePathHeightBottom(bezierPath, targetHeightDifference);
|
|
311
|
+
_self.updateResizeHandles();
|
|
312
|
+
_self.bottomHandleDragStartPosition = null;
|
|
313
|
+
updateCallback();
|
|
314
|
+
})
|
|
315
|
+
);
|
|
316
|
+
|
|
317
|
+
listeners.push(
|
|
318
|
+
_self.rightResizeHandle.listeners.addDragStartListener(function (e) {
|
|
319
|
+
var relPos = pb.transformMousePosition(e.params.draggedFrom.x, e.params.draggedFrom.y);
|
|
320
|
+
_self.rightHandleDragStartPosition = relPos;
|
|
321
|
+
})
|
|
322
|
+
);
|
|
323
|
+
listeners.push(
|
|
324
|
+
_self.rightResizeHandle.listeners.addDragEndListener(function (e) {
|
|
325
|
+
var relTargetPos = pb.transformMousePosition(e.params.pos.x, e.params.pos.y);
|
|
326
|
+
var targetWidthDifference = relTargetPos.x - _self.rightHandleDragStartPosition.x;
|
|
327
|
+
_self.__changePathWidthRight(bezierPath, targetWidthDifference);
|
|
328
|
+
_self.updateResizeHandles();
|
|
329
|
+
_self.rightHandleDragStartPosition = null;
|
|
330
|
+
updateCallback();
|
|
331
|
+
})
|
|
332
|
+
);
|
|
333
|
+
return listeners;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* @param {BezierPath} bezierPath - The path to update.
|
|
338
|
+
* @param {number} heightAmount - The height difference to apply. Can be positive or negative or zero.
|
|
339
|
+
*/
|
|
340
|
+
private __changePathHeightTop(bezierPath: BezierPath, heightAmount: number) {
|
|
341
|
+
const bounds = bezierPath.getBounds();
|
|
342
|
+
const scaleAnchor = bounds.max;
|
|
343
|
+
const verticalScaleFactor = (bounds.height + heightAmount) / bounds.height;
|
|
344
|
+
bezierPath.scaleXY({ x: 1.0, y: verticalScaleFactor }, scaleAnchor);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* @param {BezierPath} bezierPath - The path to update.
|
|
349
|
+
* @param {number} widthAmount - The width difference to apply. Can be positive or negative or zero.
|
|
350
|
+
*/
|
|
351
|
+
private __changePathWidthLeft(bezierPath: BezierPath, widthAmount: number) {
|
|
352
|
+
const bounds = bezierPath.getBounds();
|
|
353
|
+
const scaleAnchor = bounds.max;
|
|
354
|
+
const horizontalScaleFactor = (bounds.width + widthAmount) / bounds.width;
|
|
355
|
+
bezierPath.scaleXY({ x: horizontalScaleFactor, y: 1.0 }, scaleAnchor);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* @param {BezierPath} bezierPath - The path to update.
|
|
360
|
+
* @param {number} heightAmount - The height difference to apply. Can be positive or negative or zero.
|
|
361
|
+
*/
|
|
362
|
+
private __changePathHeightBottom(bezierPath: BezierPath, heightAmount: number) {
|
|
363
|
+
const bounds = bezierPath.getBounds();
|
|
364
|
+
const scaleAnchor = bounds.min;
|
|
365
|
+
const verticalScaleFactor = (bounds.height + heightAmount) / bounds.height;
|
|
366
|
+
bezierPath.scaleXY({ x: 1.0, y: verticalScaleFactor }, scaleAnchor);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* @param {BezierPath} bezierPath - The path to update.
|
|
371
|
+
* @param {number} widthAmount - The width difference to apply. Can be positive or negative or zero.
|
|
372
|
+
*/
|
|
373
|
+
private __changePathWidthRight(bezierPath: BezierPath, widthAmount: number) {
|
|
374
|
+
const bounds = bezierPath.getBounds();
|
|
375
|
+
const scaleAnchor = bounds.min;
|
|
376
|
+
const horizontalScaleFactor = (bounds.width + widthAmount) / bounds.width;
|
|
377
|
+
bezierPath.scaleXY({ x: horizontalScaleFactor, y: 1.0 }, scaleAnchor);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Set the handles to the new position after the path was resized.
|
|
382
|
+
*/
|
|
383
|
+
public updateResizeHandles() {
|
|
384
|
+
const bounds = this.bezierPath.getBounds();
|
|
385
|
+
this.leftResizeHandle.set(bounds.min.x, bounds.min.y + bounds.height / 2.0);
|
|
386
|
+
this.topResizeHandle.set(bounds.min.x + bounds.width / 2.0, bounds.min.y);
|
|
387
|
+
this.rightResizeHandle.set(bounds.max.x, bounds.min.y + bounds.height / 2.0);
|
|
388
|
+
this.bottomResizeHandle.set(bounds.min.x + bounds.width / 2.0, bounds.max.y);
|
|
389
|
+
}
|
|
390
|
+
} // END class
|
package/src/cjs/utils/_gup.js_
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// Get the URI GET params as an assoc.
|
|
2
|
-
//
|
|
3
|
-
// A nicer version with regex
|
|
4
|
-
// Found at
|
|
5
|
-
// https://stackoverflow.com/questions/979975/how-to-get-the-value-from-the-get-parameters?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
|
|
6
|
-
function gup() {
|
|
7
|
-
var vars = {};
|
|
8
|
-
var parts = globalThis.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi,
|
|
9
|
-
function(m,key,value) {
|
|
10
|
-
vars[key] = value;
|
|
11
|
-
});
|
|
12
|
-
return vars;
|
|
13
|
-
}
|