@leafer-in/corner 2.0.7

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023-present, Chao (Leafer) Wan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # @leafer-in/corner
@@ -0,0 +1,264 @@
1
+ "use strict";
2
+
3
+ var draw = require("@leafer-ui/draw");
4
+
5
+ function getTangentDistance(r, x, y, lastX, lastY, nextX, nextY) {
6
+ const ux = lastX - x, uy = lastY - y;
7
+ const vx = nextX - x, vy = nextY - y;
8
+ const lenU = Math.sqrt(ux * ux + uy * uy);
9
+ const lenV = Math.sqrt(vx * vx + vy * vy);
10
+ if (lenU < .001 || lenV < .001) return 0;
11
+ const cosTheta = (ux * vx + uy * vy) / (lenU * lenV);
12
+ const safeCos = Math.max(-.99999, Math.min(.99999, cosTheta));
13
+ let d = r * Math.sqrt((1 - safeCos) / (1 + safeCos));
14
+ const maxD = Math.min(lenU / 2, lenV / 2);
15
+ return Math.min(d, maxD);
16
+ }
17
+
18
+ function getCorrectT(d, x, y, x1, y1, x2, y2, toX, toY) {
19
+ if (d <= 0) return 0;
20
+ const chordLen = Math.sqrt(Math.pow(toX - x, 2) + Math.pow(toY - y, 2));
21
+ if (d >= chordLen) return .5;
22
+ const vx0 = 3 * (x1 - x);
23
+ const vy0 = 3 * (y1 - y);
24
+ let v0mag = Math.sqrt(vx0 * vx0 + vy0 * vy0);
25
+ if (v0mag < 1e-6) v0mag = chordLen || 1;
26
+ let t = Math.min(.5, d / v0mag);
27
+ const tempP = {
28
+ x: 0,
29
+ y: 0
30
+ };
31
+ for (let i = 0; i < 5; i++) {
32
+ draw.BezierHelper.getPointAndSet(t, x, y, x1, y1, x2, y2, toX, toY, tempP);
33
+ const dx = tempP.x - x;
34
+ const dy = tempP.y - y;
35
+ const currentDist = Math.sqrt(dx * dx + dy * dy);
36
+ if (currentDist < 1e-6) {
37
+ t = t * 1.5;
38
+ continue;
39
+ }
40
+ const vxt = draw.BezierHelper.getDerivative(t, x, x1, x2, toX);
41
+ const vyt = draw.BezierHelper.getDerivative(t, y, y1, y2, toY);
42
+ const f_prime = (dx * vxt + dy * vyt) / currentDist;
43
+ if (Math.abs(f_prime) < 1e-6) break;
44
+ const deltaT = (currentDist - d) / f_prime;
45
+ const nextT = t - deltaT;
46
+ const safeNextT = Math.max(0, Math.min(.6, nextT));
47
+ if (Math.abs(safeNextT - t) < 1e-5) {
48
+ t = safeNextT;
49
+ break;
50
+ }
51
+ t = safeNextT;
52
+ }
53
+ return Math.max(0, Math.min(.5, t));
54
+ }
55
+
56
+ const {M: M, L: L, C: C, Z: Z} = draw.PathCommandMap;
57
+
58
+ const {getCenterX: getCenterX, getCenterY: getCenterY} = draw.PointHelper;
59
+
60
+ const {arcTo: arcTo} = draw.PathCommandDataHelper;
61
+
62
+ draw.PathCorner.smooth = function smooth(data, cornerRadius, _cornerSmoothing) {
63
+ const radius = data.radius;
64
+ if (isNeedConvert(data)) data = draw.PathConvert.toCanvasData(data, true);
65
+ let command, lastCommand, commandLen;
66
+ let i = 0, countCommand = 0, x = 0, y = 0, startX = 0, startY = 0, startR = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0, r, x1, y1, x2, y2, toX, toY;
67
+ if (draw.isArray(cornerRadius)) cornerRadius = cornerRadius[0] || 0;
68
+ const len = data.length, three = len === 9;
69
+ const smooth = [];
70
+ while (i < len) {
71
+ command = data[i];
72
+ r = radius ? draw.isUndefined(radius[countCommand]) ? cornerRadius : radius[countCommand] : cornerRadius;
73
+ switch (command) {
74
+ case M:
75
+ startX = lastX = data[i + 1];
76
+ startY = lastY = data[i + 2];
77
+ startR = r;
78
+ i += 3;
79
+ const end = findEndPoint(data, i);
80
+ switch (data[i]) {
81
+ case L:
82
+ secondX = data[i + 1];
83
+ secondY = data[i + 2];
84
+ if (three) smooth.push(M, startX, startY); else {
85
+ if (end) smooth.push(M, getCenterX(startX, secondX), getCenterY(startY, secondY)); else smooth.push(M, startX, startY);
86
+ }
87
+ break;
88
+
89
+ case C:
90
+ if (end) {
91
+ const {left: left, right: right} = setAfterC(data, i, r, end.x, end.y, startX, startY, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6]);
92
+ if (left && right) {
93
+ smooth.push(M, secondX = left[4], secondY = left[5]);
94
+ break;
95
+ }
96
+ }
97
+
98
+ default:
99
+ smooth.push(M, secondX = startX, secondY = startY);
100
+ }
101
+ break;
102
+
103
+ case L:
104
+ x = data[i + 1];
105
+ y = data[i + 2];
106
+ i += 3;
107
+ switch (data[i]) {
108
+ case L:
109
+ arcTo(smooth, x, y, data[i + 1], data[i + 2], r, lastX, lastY, three);
110
+ break;
111
+
112
+ case C:
113
+ const {left: left, right: right} = setAfterC(data, i, r, lastX, lastY, x, y, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6]);
114
+ if (left && right) arcTo(smooth, x, y, left[4], left[5], r, lastX, lastY, three); else smooth.push(L, x, y);
115
+ break;
116
+
117
+ case Z:
118
+ arcTo(smooth, x, y, startX, startY, r, lastX, lastY, three);
119
+ break;
120
+
121
+ default:
122
+ smooth.push(L, x, y);
123
+ }
124
+ lastX = x;
125
+ lastY = y;
126
+ break;
127
+
128
+ case C:
129
+ x1 = data[i + 1];
130
+ y1 = data[i + 2];
131
+ x2 = data[i + 3];
132
+ y2 = data[i + 4];
133
+ x = data[i + 5];
134
+ y = data[i + 6];
135
+ i += 7;
136
+ switch (data[i]) {
137
+ case L:
138
+ toX = data[i + 1], toY = data[i + 2];
139
+ setBeforeC(smooth, r, lastX, lastY, x1, y1, x2, y2, x, y, toX, toY, three);
140
+ break;
141
+
142
+ case C:
143
+ smooth.push(C, x1, y1, x2, y2, x, y);
144
+ break;
145
+
146
+ case Z:
147
+ toX = startX, toY = startY;
148
+ setBeforeC(smooth, r, lastX, lastY, x1, y1, x2, y2, x, y, toX, toY, three);
149
+ break;
150
+ }
151
+ lastX = x;
152
+ lastY = y;
153
+ break;
154
+
155
+ case Z:
156
+ if (lastCommand !== Z) {
157
+ arcTo(smooth, startX, startY, secondX, secondY, startR, lastX, lastY, three);
158
+ smooth.push(Z);
159
+ }
160
+ i += 1;
161
+ break;
162
+
163
+ default:
164
+ commandLen = draw.PathNumberCommandLengthMap[command];
165
+ for (let j = 0; j < commandLen; j++) smooth.push(data[i + j]);
166
+ i += commandLen;
167
+ }
168
+ lastCommand = command;
169
+ countCommand++;
170
+ }
171
+ return smooth;
172
+ };
173
+
174
+ function isNeedConvert(data) {
175
+ let command, i = 0;
176
+ const len = data.length;
177
+ while (i < len) {
178
+ command = data[i];
179
+ switch (command) {
180
+ case M:
181
+ i += 3;
182
+ break;
183
+
184
+ case L:
185
+ i += 3;
186
+ break;
187
+
188
+ case C:
189
+ i += 7;
190
+ break;
191
+
192
+ case Z:
193
+ i += 1;
194
+ break;
195
+
196
+ default:
197
+ return true;
198
+ }
199
+ }
200
+ return false;
201
+ }
202
+
203
+ function findEndPoint(data, i) {
204
+ let command, commandLen, x, y;
205
+ const len = data.length;
206
+ while (i < len) {
207
+ command = data[i];
208
+ switch (command) {
209
+ case M:
210
+ return undefined;
211
+
212
+ case L:
213
+ x = data[i + 1];
214
+ y = data[i + 2];
215
+ i += 3;
216
+ break;
217
+
218
+ case C:
219
+ x = data[i + 5];
220
+ y = data[i + 6];
221
+ i += 7;
222
+ break;
223
+
224
+ case Z:
225
+ return {
226
+ x: x,
227
+ y: y
228
+ };
229
+
230
+ default:
231
+ commandLen = draw.PathNumberCommandLengthMap[command];
232
+ i += commandLen;
233
+ }
234
+ }
235
+ return undefined;
236
+ }
237
+
238
+ function setAfterC(data, i, cornerRadius, lastX, lastY, fromX, fromY, x1, y1, x2, y2, toX, toY) {
239
+ const d = getTangentDistance(cornerRadius, fromX, fromY, lastX, lastY, x1, y1);
240
+ const t = getCorrectT(d, fromX, fromY, x1, y1, x2, y2, toX, toY);
241
+ const two = draw.BezierHelper.cut(t, fromX, fromY, x1, y1, x2, y2, toX, toY);
242
+ const {left: left, right: right} = two;
243
+ if (left && right) {
244
+ data[i + 1] = right[0];
245
+ data[i + 2] = right[1];
246
+ data[i + 3] = right[2];
247
+ data[i + 4] = right[3];
248
+ }
249
+ return two;
250
+ }
251
+
252
+ function setBeforeC(smooth, cornerRadius, fromX, fromY, x1, y1, x2, y2, toX, toY, nextX, nextY, three) {
253
+ const d = getTangentDistance(cornerRadius, toX, toY, x2, y2, nextX, nextY);
254
+ const t = getCorrectT(d, toX, toY, x2, y2, x1, y1, fromX, fromY);
255
+ const {left: left, right: right} = draw.BezierHelper.cut(1 - t, fromX, fromY, x1, y1, x2, y2, toX, toY);
256
+ if (left && right) {
257
+ smooth.push(C, left[0], left[1], left[2], left[3], left[4], left[5]);
258
+ arcTo(smooth, toX, toY, nextX, nextY, cornerRadius, left[4], left[5], three);
259
+ } else {
260
+ smooth.push(C, x1, y1, x2, y2, toX, toY);
261
+ }
262
+ }
263
+
264
+ draw.Plugin.add("corner");
@@ -0,0 +1,262 @@
1
+ import { BezierHelper, PathCommandMap, PointHelper, PathCommandDataHelper, PathCorner, PathConvert, isArray, isUndefined, PathNumberCommandLengthMap, Plugin } from "@leafer-ui/draw";
2
+
3
+ function getTangentDistance(r, x, y, lastX, lastY, nextX, nextY) {
4
+ const ux = lastX - x, uy = lastY - y;
5
+ const vx = nextX - x, vy = nextY - y;
6
+ const lenU = Math.sqrt(ux * ux + uy * uy);
7
+ const lenV = Math.sqrt(vx * vx + vy * vy);
8
+ if (lenU < .001 || lenV < .001) return 0;
9
+ const cosTheta = (ux * vx + uy * vy) / (lenU * lenV);
10
+ const safeCos = Math.max(-.99999, Math.min(.99999, cosTheta));
11
+ let d = r * Math.sqrt((1 - safeCos) / (1 + safeCos));
12
+ const maxD = Math.min(lenU / 2, lenV / 2);
13
+ return Math.min(d, maxD);
14
+ }
15
+
16
+ function getCorrectT(d, x, y, x1, y1, x2, y2, toX, toY) {
17
+ if (d <= 0) return 0;
18
+ const chordLen = Math.sqrt(Math.pow(toX - x, 2) + Math.pow(toY - y, 2));
19
+ if (d >= chordLen) return .5;
20
+ const vx0 = 3 * (x1 - x);
21
+ const vy0 = 3 * (y1 - y);
22
+ let v0mag = Math.sqrt(vx0 * vx0 + vy0 * vy0);
23
+ if (v0mag < 1e-6) v0mag = chordLen || 1;
24
+ let t = Math.min(.5, d / v0mag);
25
+ const tempP = {
26
+ x: 0,
27
+ y: 0
28
+ };
29
+ for (let i = 0; i < 5; i++) {
30
+ BezierHelper.getPointAndSet(t, x, y, x1, y1, x2, y2, toX, toY, tempP);
31
+ const dx = tempP.x - x;
32
+ const dy = tempP.y - y;
33
+ const currentDist = Math.sqrt(dx * dx + dy * dy);
34
+ if (currentDist < 1e-6) {
35
+ t = t * 1.5;
36
+ continue;
37
+ }
38
+ const vxt = BezierHelper.getDerivative(t, x, x1, x2, toX);
39
+ const vyt = BezierHelper.getDerivative(t, y, y1, y2, toY);
40
+ const f_prime = (dx * vxt + dy * vyt) / currentDist;
41
+ if (Math.abs(f_prime) < 1e-6) break;
42
+ const deltaT = (currentDist - d) / f_prime;
43
+ const nextT = t - deltaT;
44
+ const safeNextT = Math.max(0, Math.min(.6, nextT));
45
+ if (Math.abs(safeNextT - t) < 1e-5) {
46
+ t = safeNextT;
47
+ break;
48
+ }
49
+ t = safeNextT;
50
+ }
51
+ return Math.max(0, Math.min(.5, t));
52
+ }
53
+
54
+ const {M: M, L: L, C: C, Z: Z} = PathCommandMap;
55
+
56
+ const {getCenterX: getCenterX, getCenterY: getCenterY} = PointHelper;
57
+
58
+ const {arcTo: arcTo} = PathCommandDataHelper;
59
+
60
+ PathCorner.smooth = function smooth(data, cornerRadius, _cornerSmoothing) {
61
+ const radius = data.radius;
62
+ if (isNeedConvert(data)) data = PathConvert.toCanvasData(data, true);
63
+ let command, lastCommand, commandLen;
64
+ let i = 0, countCommand = 0, x = 0, y = 0, startX = 0, startY = 0, startR = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0, r, x1, y1, x2, y2, toX, toY;
65
+ if (isArray(cornerRadius)) cornerRadius = cornerRadius[0] || 0;
66
+ const len = data.length, three = len === 9;
67
+ const smooth = [];
68
+ while (i < len) {
69
+ command = data[i];
70
+ r = radius ? isUndefined(radius[countCommand]) ? cornerRadius : radius[countCommand] : cornerRadius;
71
+ switch (command) {
72
+ case M:
73
+ startX = lastX = data[i + 1];
74
+ startY = lastY = data[i + 2];
75
+ startR = r;
76
+ i += 3;
77
+ const end = findEndPoint(data, i);
78
+ switch (data[i]) {
79
+ case L:
80
+ secondX = data[i + 1];
81
+ secondY = data[i + 2];
82
+ if (three) smooth.push(M, startX, startY); else {
83
+ if (end) smooth.push(M, getCenterX(startX, secondX), getCenterY(startY, secondY)); else smooth.push(M, startX, startY);
84
+ }
85
+ break;
86
+
87
+ case C:
88
+ if (end) {
89
+ const {left: left, right: right} = setAfterC(data, i, r, end.x, end.y, startX, startY, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6]);
90
+ if (left && right) {
91
+ smooth.push(M, secondX = left[4], secondY = left[5]);
92
+ break;
93
+ }
94
+ }
95
+
96
+ default:
97
+ smooth.push(M, secondX = startX, secondY = startY);
98
+ }
99
+ break;
100
+
101
+ case L:
102
+ x = data[i + 1];
103
+ y = data[i + 2];
104
+ i += 3;
105
+ switch (data[i]) {
106
+ case L:
107
+ arcTo(smooth, x, y, data[i + 1], data[i + 2], r, lastX, lastY, three);
108
+ break;
109
+
110
+ case C:
111
+ const {left: left, right: right} = setAfterC(data, i, r, lastX, lastY, x, y, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6]);
112
+ if (left && right) arcTo(smooth, x, y, left[4], left[5], r, lastX, lastY, three); else smooth.push(L, x, y);
113
+ break;
114
+
115
+ case Z:
116
+ arcTo(smooth, x, y, startX, startY, r, lastX, lastY, three);
117
+ break;
118
+
119
+ default:
120
+ smooth.push(L, x, y);
121
+ }
122
+ lastX = x;
123
+ lastY = y;
124
+ break;
125
+
126
+ case C:
127
+ x1 = data[i + 1];
128
+ y1 = data[i + 2];
129
+ x2 = data[i + 3];
130
+ y2 = data[i + 4];
131
+ x = data[i + 5];
132
+ y = data[i + 6];
133
+ i += 7;
134
+ switch (data[i]) {
135
+ case L:
136
+ toX = data[i + 1], toY = data[i + 2];
137
+ setBeforeC(smooth, r, lastX, lastY, x1, y1, x2, y2, x, y, toX, toY, three);
138
+ break;
139
+
140
+ case C:
141
+ smooth.push(C, x1, y1, x2, y2, x, y);
142
+ break;
143
+
144
+ case Z:
145
+ toX = startX, toY = startY;
146
+ setBeforeC(smooth, r, lastX, lastY, x1, y1, x2, y2, x, y, toX, toY, three);
147
+ break;
148
+ }
149
+ lastX = x;
150
+ lastY = y;
151
+ break;
152
+
153
+ case Z:
154
+ if (lastCommand !== Z) {
155
+ arcTo(smooth, startX, startY, secondX, secondY, startR, lastX, lastY, three);
156
+ smooth.push(Z);
157
+ }
158
+ i += 1;
159
+ break;
160
+
161
+ default:
162
+ commandLen = PathNumberCommandLengthMap[command];
163
+ for (let j = 0; j < commandLen; j++) smooth.push(data[i + j]);
164
+ i += commandLen;
165
+ }
166
+ lastCommand = command;
167
+ countCommand++;
168
+ }
169
+ return smooth;
170
+ };
171
+
172
+ function isNeedConvert(data) {
173
+ let command, i = 0;
174
+ const len = data.length;
175
+ while (i < len) {
176
+ command = data[i];
177
+ switch (command) {
178
+ case M:
179
+ i += 3;
180
+ break;
181
+
182
+ case L:
183
+ i += 3;
184
+ break;
185
+
186
+ case C:
187
+ i += 7;
188
+ break;
189
+
190
+ case Z:
191
+ i += 1;
192
+ break;
193
+
194
+ default:
195
+ return true;
196
+ }
197
+ }
198
+ return false;
199
+ }
200
+
201
+ function findEndPoint(data, i) {
202
+ let command, commandLen, x, y;
203
+ const len = data.length;
204
+ while (i < len) {
205
+ command = data[i];
206
+ switch (command) {
207
+ case M:
208
+ return undefined;
209
+
210
+ case L:
211
+ x = data[i + 1];
212
+ y = data[i + 2];
213
+ i += 3;
214
+ break;
215
+
216
+ case C:
217
+ x = data[i + 5];
218
+ y = data[i + 6];
219
+ i += 7;
220
+ break;
221
+
222
+ case Z:
223
+ return {
224
+ x: x,
225
+ y: y
226
+ };
227
+
228
+ default:
229
+ commandLen = PathNumberCommandLengthMap[command];
230
+ i += commandLen;
231
+ }
232
+ }
233
+ return undefined;
234
+ }
235
+
236
+ function setAfterC(data, i, cornerRadius, lastX, lastY, fromX, fromY, x1, y1, x2, y2, toX, toY) {
237
+ const d = getTangentDistance(cornerRadius, fromX, fromY, lastX, lastY, x1, y1);
238
+ const t = getCorrectT(d, fromX, fromY, x1, y1, x2, y2, toX, toY);
239
+ const two = BezierHelper.cut(t, fromX, fromY, x1, y1, x2, y2, toX, toY);
240
+ const {left: left, right: right} = two;
241
+ if (left && right) {
242
+ data[i + 1] = right[0];
243
+ data[i + 2] = right[1];
244
+ data[i + 3] = right[2];
245
+ data[i + 4] = right[3];
246
+ }
247
+ return two;
248
+ }
249
+
250
+ function setBeforeC(smooth, cornerRadius, fromX, fromY, x1, y1, x2, y2, toX, toY, nextX, nextY, three) {
251
+ const d = getTangentDistance(cornerRadius, toX, toY, x2, y2, nextX, nextY);
252
+ const t = getCorrectT(d, toX, toY, x2, y2, x1, y1, fromX, fromY);
253
+ const {left: left, right: right} = BezierHelper.cut(1 - t, fromX, fromY, x1, y1, x2, y2, toX, toY);
254
+ if (left && right) {
255
+ smooth.push(C, left[0], left[1], left[2], left[3], left[4], left[5]);
256
+ arcTo(smooth, toX, toY, nextX, nextY, cornerRadius, left[4], left[5], three);
257
+ } else {
258
+ smooth.push(C, x1, y1, x2, y2, toX, toY);
259
+ }
260
+ }
261
+
262
+ Plugin.add("corner");
@@ -0,0 +1,2 @@
1
+ import{BezierHelper as t,PathCommandMap as e,PointHelper as a,PathCommandDataHelper as s,PathCorner as r,PathConvert as n,isArray as c,isUndefined as h,PathNumberCommandLengthMap as o,Plugin as i}from"@leafer-ui/draw";function u(t,e,a,s,r,n,c){const h=s-e,o=r-a,i=n-e,u=c-a,f=Math.sqrt(h*h+o*o),l=Math.sqrt(i*i+u*u);if(f<.001||l<.001)return 0;const b=(h*i+o*u)/(f*l),M=Math.max(-.99999,Math.min(.99999,b));let k=t*Math.sqrt((1-M)/(1+M));const p=Math.min(f/2,l/2);return Math.min(k,p)}function f(e,a,s,r,n,c,h,o,i){if(e<=0)return 0;const u=Math.sqrt(Math.pow(o-a,2)+Math.pow(i-s,2));if(e>=u)return.5;const f=3*(r-a),l=3*(n-s);let b=Math.sqrt(f*f+l*l);b<1e-6&&(b=u||1);let M=Math.min(.5,e/b);const k={x:0,y:0};for(let u=0;u<5;u++){t.getPointAndSet(M,a,s,r,n,c,h,o,i,k);const u=k.x-a,f=k.y-s,l=Math.sqrt(u*u+f*f);if(l<1e-6){M*=1.5;continue}const b=(u*t.getDerivative(M,a,r,c,o)+f*t.getDerivative(M,s,n,h,i))/l;if(Math.abs(b)<1e-6)break;const p=M-(l-e)/b,g=Math.max(0,Math.min(.6,p));if(Math.abs(g-M)<1e-5){M=g;break}M=g}return Math.max(0,Math.min(.5,M))}const{M:l,L:b,C:M,Z:k}=e,{getCenterX:p,getCenterY:g}=a,{arcTo:m}=s;function d(t,e){let a,s,r,n;const c=t.length;for(;e<c;)switch(a=t[e],a){case l:return;case b:r=t[e+1],n=t[e+2],e+=3;break;case M:r=t[e+5],n=t[e+6],e+=7;break;case k:return{x:r,y:n};default:s=o[a],e+=s}}function w(e,a,s,r,n,c,h,o,i,l,b,M,k){const p=f(u(s,c,h,r,n,o,i),c,h,o,i,l,b,M,k),g=t.cut(p,c,h,o,i,l,b,M,k),{left:m,right:d}=g;return m&&d&&(e[a+1]=d[0],e[a+2]=d[1],e[a+3]=d[2],e[a+4]=d[3]),g}function x(e,a,s,r,n,c,h,o,i,l,b,k,p){const g=f(u(a,i,l,h,o,b,k),i,l,h,o,n,c,s,r),{left:d,right:w}=t.cut(1-g,s,r,n,c,h,o,i,l);d&&w?(e.push(M,d[0],d[1],d[2],d[3],d[4],d[5]),m(e,i,l,b,k,a,d[4],d[5],p)):e.push(M,n,c,h,o,i,l)}r.smooth=function(t,e,a){const s=t.radius;let r,i,u;(function(t){let e,a=0;const s=t.length;for(;a<s;)switch(e=t[a],e){case l:case b:a+=3;break;case M:a+=7;break;case k:a+=1;break;default:return!0}return!1})(t)&&(t=n.toCanvasData(t,!0));let f,q,v,y,C,D,A,L=0,P=0,S=0,T=0,X=0,Y=0,Z=0,j=0,z=0,B=0,E=0;c(e)&&(e=e[0]||0);const F=t.length,G=9===F,H=[];for(;L<F;){switch(r=t[L],f=s?h(s[P])?e:s[P]:e,r){case l:X=B=t[L+1],Y=E=t[L+2],Z=f,L+=3;const e=d(t,L);switch(t[L]){case b:j=t[L+1],z=t[L+2],G?H.push(l,X,Y):e?H.push(l,p(X,j),g(Y,z)):H.push(l,X,Y);break;case M:if(e){const{left:a,right:s}=w(t,L,f,e.x,e.y,X,Y,t[L+1],t[L+2],t[L+3],t[L+4],t[L+5],t[L+6]);if(a&&s){H.push(l,j=a[4],z=a[5]);break}}default:H.push(l,j=X,z=Y)}break;case b:switch(S=t[L+1],T=t[L+2],L+=3,t[L]){case b:m(H,S,T,t[L+1],t[L+2],f,B,E,G);break;case M:const{left:e,right:a}=w(t,L,f,B,E,S,T,t[L+1],t[L+2],t[L+3],t[L+4],t[L+5],t[L+6]);e&&a?m(H,S,T,e[4],e[5],f,B,E,G):H.push(b,S,T);break;case k:m(H,S,T,X,Y,f,B,E,G);break;default:H.push(b,S,T)}B=S,E=T;break;case M:switch(q=t[L+1],v=t[L+2],y=t[L+3],C=t[L+4],S=t[L+5],T=t[L+6],L+=7,t[L]){case b:D=t[L+1],A=t[L+2],x(H,f,B,E,q,v,y,C,S,T,D,A,G);break;case M:H.push(M,q,v,y,C,S,T);break;case k:D=X,A=Y,x(H,f,B,E,q,v,y,C,S,T,D,A,G)}B=S,E=T;break;case k:i!==k&&(m(H,X,Y,j,z,Z,B,E,G),H.push(k)),L+=1;break;default:u=o[r];for(let e=0;e<u;e++)H.push(t[L+e]);L+=u}i=r,P++}return H},i.add("corner");
2
+ //# sourceMappingURL=corner.esm.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"corner.esm.min.js","sources":["../../../../../../src/in/packages/corner/src/helper.ts","../../../../../../src/in/packages/corner/src/PathCorner.ts","../../../../../../src/in/packages/corner/src/index.ts"],"sourcesContent":["import { BezierHelper } from '@leafer-ui/draw'\n\n\n// 获取圆角切线距离\nexport function getTangentDistance(r: number, x: number, y: number, lastX: number, lastY: number, nextX: number, nextY: number): number {\n // 1. 构造入射向量 U (P -> lastP) 和出射向量 V (P -> nextP)\n const ux = lastX - x, uy = lastY - y\n const vx = nextX - x, vy = nextY - y\n\n // 2. 计算向量长度(平方和开方)\n const lenU = Math.sqrt(ux * ux + uy * uy)\n const lenV = Math.sqrt(vx * vx + vy * vy)\n\n // 3. 边界防御:若线段长度几乎为0,则不产生圆角\n if (lenU < 0.001 || lenV < 0.001) return 0\n\n // 4. 计算向量夹角余弦值 cos(θ) = (U·V) / (|U|*|V|)\n const cosTheta = (ux * vx + uy * vy) / (lenU * lenV)\n\n // 5. 精度钳位:防止浮点误差导致 cos 越界 [-1, 1],避开分母为0的情况\n const safeCos = Math.max(-0.99999, Math.min(0.99999, cosTheta))\n\n // 6. 核心几何推导:d = r * sqrt((1 - cosθ) / (1 + cosθ))\n let d = r * Math.sqrt((1 - safeCos) / (1 + safeCos))\n\n // 7. 【关键性能与安全约束】:最大距离不得超过相邻边长的一半\n // 这样可以确保相邻顶点的圆角不会发生几何重叠或路径自交。\n const maxD = Math.min(lenU / 2, lenV / 2)\n return Math.min(d, maxD)\n}\n\n// 精准定位贝塞尔曲线参数 t\nexport function getCorrectT(d: number, x: number, y: number, x1: number, y1: number, x2: number, y2: number, toX: number, toY: number): number {\n if (d <= 0) return 0\n\n // 1. 预估总弦长(起点到终点的直线距离)\n const chordLen = Math.sqrt((toX - x) ** 2 + (toY - y) ** 2)\n\n // 2. 边界保护:若要求的距离超过弦长,为了路径安全,强制限制在曲线 50% 处\n if (d >= chordLen) return 0.5\n\n // 3. 初始猜测值估算:利用 t=0 处的瞬时速度矢量 v(0) = 3*(P1 - P0)\n const vx0 = 3 * (x1 - x)\n const vy0 = 3 * (y1 - y)\n let v0mag = Math.sqrt(vx0 * vx0 + vy0 * vy0)\n\n // 【优化点】:若起点与控制点重合(初速度为0),降级使用弦长线性比例,防止 NaN\n if (v0mag < 1e-6) v0mag = chordLen || 1\n\n let t = Math.min(0.5, d / v0mag)\n const tempP = { x: 0, y: 0 }\n\n // 4. 牛顿迭代 (Newton-Raphson) 循环\n for (let i = 0; i < 5; i++) {\n // 获取当前参数 t 对应的坐标点\n BezierHelper.getPointAndSet(t, x, y, x1, y1, x2, y2, toX, toY, tempP)\n\n const dx = tempP.x - x\n const dy = tempP.y - y\n const currentDist = Math.sqrt(dx * dx + dy * dy)\n\n // 数值稳定性检查:若当前点过于靠近起点,尝试向外探测\n if (currentDist < 1e-6) {\n t = t * 1.5\n continue\n }\n\n // 计算当前 t 处的导数向量 (x', y')\n const vxt = BezierHelper.getDerivative(t, x, x1, x2, toX)\n const vyt = BezierHelper.getDerivative(t, y, y1, y2, toY)\n\n // 计算目标函数的导数 f'(t) = (dx*x' + dy*y') / currentDist\n const f_prime = (dx * vxt + dy * vyt) / currentDist\n\n // 如果导数过小,说明进入平台期或计算异常,停止迭代\n if (Math.abs(f_prime) < 1e-6) break\n\n // 牛顿法公式:t_next = t - f(t) / f'(t)\n const deltaT = (currentDist - d) / f_prime\n const nextT = t - deltaT\n\n // 【收敛域保护】:强制限制在 [0, 0.6] 范围内寻找最优解,防止迭代跳出贝塞尔曲线有效区间\n const safeNextT = Math.max(0, Math.min(0.6, nextT))\n\n // 精度满足 1e-5 (像素级精度) 提前退出\n if (Math.abs(safeNextT - t) < 1e-5) {\n t = safeNextT\n break\n }\n t = safeNextT\n }\n\n // 最终返回结果,上限截断在 0.5 处,确保圆弧不会占据整条曲线导致形状崩坏\n return Math.max(0, Math.min(0.5, t))\n}","import { IPathCommandData, IPathCommandDataWithRadius, IPointData } from '@leafer-ui/interface'\nimport { PathCorner, PointHelper, PathCommandMap as Command, PathNumberCommandLengthMap, isArray, isUndefined, PathCommandDataHelper, BezierHelper, PathConvert } from '@leafer-ui/draw'\n\nimport { getCorrectT, getTangentDistance } from './helper'\n\n\nconst { M, L, C, Z } = Command\nconst { getCenterX, getCenterY } = PointHelper\nconst { arcTo } = PathCommandDataHelper\n\nPathCorner.smooth = function smooth(data: IPathCommandData, cornerRadius: number, _cornerSmoothing?: number): IPathCommandData {\n\n const radius = (data as any as IPathCommandDataWithRadius).radius // 独立圆角\n if (isNeedConvert(data)) data = PathConvert.toCanvasData(data, true)\n\n let command: number, lastCommand: number, commandLen\n let i = 0, countCommand = 0, x = 0, y = 0, startX = 0, startY = 0, startR = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0, r: number, x1: number, y1: number, x2: number, y2: number, toX: number, toY: number\n if (isArray(cornerRadius)) cornerRadius = cornerRadius[0] || 0\n\n const len = data.length, three = len === 9 // 3个点时可以加大圆角\n const smooth: IPathCommandData = []\n\n while (i < len) {\n command = data[i]\n r = radius ? (isUndefined(radius[countCommand]) ? cornerRadius : radius[countCommand]) : cornerRadius\n switch (command) {\n case M: //moveto(x, y)\n startX = lastX = data[i + 1]\n startY = lastY = data[i + 2]\n startR = r\n i += 3\n const end = findEndPoint(data, i)\n switch (data[i]) { // next command\n case L: // lineTo()\n secondX = data[i + 1]\n secondY = data[i + 2]\n if (three) smooth.push(M, startX, startY)\n else {\n if (end) smooth.push(M, getCenterX(startX, secondX), getCenterY(startY, secondY))\n else smooth.push(M, startX, startY)\n }\n break\n case C: // bezierCurveTo()\n if (end) {\n const { left, right } = setAfterC(data, i, r, end.x, end.y, startX, startY, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6])\n if (left && right) {\n smooth.push(M, secondX = left[4], secondY = left[5])\n break\n }\n }\n default:\n smooth.push(M, secondX = startX, secondY = startY)\n }\n break\n case L: //lineto(x, y)\n x = data[i + 1]\n y = data[i + 2]\n i += 3\n switch (data[i]) { // next command\n case L: // lineTo()\n arcTo(smooth, x, y, data[i + 1], data[i + 2], r, lastX, lastY, three) // use arcTo(x1, y1, x2, y2, radius)\n break\n case C: // bezierCurveTo()\n const { left, right } = setAfterC(data, i, r, lastX, lastY, x, y, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6])\n if (left && right) arcTo(smooth, x, y, left[4], left[5], r, lastX, lastY, three)\n else smooth.push(L, x, y)\n break\n case Z: // closePath()\n arcTo(smooth, x, y, startX, startY, r, lastX, lastY, three) // use arcTo(x1, y1, x2, y2, radius)\n break\n default:\n smooth.push(L, x, y)\n }\n lastX = x\n lastY = y\n break\n case C:\n x1 = data[i + 1]\n y1 = data[i + 2]\n x2 = data[i + 3]\n y2 = data[i + 4]\n x = data[i + 5]\n y = data[i + 6]\n i += 7\n switch (data[i]) { // next command\n case L: // lineTo()\n toX = data[i + 1], toY = data[i + 2]\n setBeforeC(smooth, r, lastX, lastY, x1, y1, x2, y2, x, y, toX, toY, three)\n break\n case C: //\n smooth.push(C, x1, y1, x2, y2, x, y)\n break\n case Z: // closePath()\n toX = startX, toY = startY\n setBeforeC(smooth, r, lastX, lastY, x1, y1, x2, y2, x, y, toX, toY, three)\n break\n }\n lastX = x\n lastY = y\n break\n case Z: //closepath()\n if (lastCommand !== Z) { // fix: 重复的 Z 导致的问题\n arcTo(smooth, startX, startY, secondX, secondY, startR, lastX, lastY, three) // use arcTo(x1, y1, x2, y2, radius)\n smooth.push(Z)\n }\n i += 1\n break\n default:\n commandLen = PathNumberCommandLengthMap[command]\n for (let j = 0; j < commandLen; j++) smooth.push(data[i + j])\n i += commandLen\n }\n lastCommand = command\n countCommand++\n }\n\n return smooth\n}\n\n\nfunction isNeedConvert(data: IPathCommandData): boolean {\n let command: number, i = 0\n const len = data.length\n while (i < len) {\n command = data[i]\n switch (command) {\n case M: //moveto(x, y)\n i += 3\n break\n case L: //lineto(x, y)\n i += 3\n break\n case C: // bezierCurveTo()\n i += 7\n break\n case Z: //closepath()\n i += 1\n break\n default:\n return true\n }\n }\n return false\n}\n\nfunction findEndPoint(data: IPathCommandData, i: number): IPointData {\n let command: number, commandLen: number, x: number, y: number\n const len = data.length\n while (i < len) {\n command = data[i]\n switch (command) {\n case M: //moveto(x, y)\n return undefined\n case L: //lineto(x, y)\n x = data[i + 1]\n y = data[i + 2]\n i += 3\n break\n case C: // bezierCurveTo()\n x = data[i + 5]\n y = data[i + 6]\n i += 7\n break\n case Z: //closepath()\n return { x, y }\n default:\n commandLen = PathNumberCommandLengthMap[command]\n i += commandLen\n }\n }\n return undefined\n}\n\n\nfunction setAfterC(data: IPathCommandData, i: number, cornerRadius: number, lastX: number, lastY: number, fromX: number, fromY: number, x1: number, y1: number, x2: number, y2: number, toX: number, toY: number) {\n const d = getTangentDistance(cornerRadius, fromX, fromY, lastX, lastY, x1, y1)\n const t = getCorrectT(d, fromX, fromY, x1, y1, x2, y2, toX, toY)\n const two = BezierHelper.cut(t, fromX, fromY, x1, y1, x2, y2, toX, toY)\n const { left, right } = two\n\n if (left && right) {\n data[i + 1] = right[0]; data[i + 2] = right[1]\n data[i + 3] = right[2]; data[i + 4] = right[3]\n }\n\n return two\n}\n\nfunction setBeforeC(smooth: IPathCommandData, cornerRadius: number, fromX: number, fromY: number, x1: number, y1: number, x2: number, y2: number, toX: number, toY: number, nextX: number, nextY: number, three: boolean) {\n const d = getTangentDistance(cornerRadius, toX, toY, x2, y2, nextX, nextY) // 反向\n const t = getCorrectT(d, toX, toY, x2, y2, x1, y1, fromX, fromY) // 反向\n const { left, right } = BezierHelper.cut(1 - t, fromX, fromY, x1, y1, x2, y2, toX, toY)\n\n if (left && right) {\n smooth.push(C, left[0], left[1], left[2], left[3], left[4], left[5])\n arcTo(smooth, toX, toY, nextX, nextY, cornerRadius, left[4], left[5], three)\n } else {\n smooth.push(C, x1, y1, x2, y2, toX, toY)\n }\n}","import { Plugin } from '@leafer-ui/draw'\nimport './PathCorner'\n\n\nPlugin.add('corner')"],"names":["getTangentDistance","r","x","y","lastX","lastY","nextX","nextY","ux","uy","vx","vy","lenU","Math","sqrt","lenV","cosTheta","safeCos","max","min","d","maxD","getCorrectT","x1","y1","x2","y2","toX","toY","chordLen","pow","vx0","vy0","v0mag","t","tempP","i","BezierHelper","getPointAndSet","dx","dy","currentDist","f_prime","getDerivative","abs","nextT","safeNextT","M","L","C","Z","Command","getCenterX","getCenterY","PointHelper","arcTo","PathCommandDataHelper","findEndPoint","data","command","commandLen","len","length","PathNumberCommandLengthMap","setAfterC","cornerRadius","fromX","fromY","two","cut","left","right","setBeforeC","smooth","three","push","PathCorner","_cornerSmoothing","radius","lastCommand","isNeedConvert","PathConvert","to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