mirror of
https://github.com/konvajs/konva.git
synced 2025-06-28 15:23:44 +08:00
Fix wrong size calculations for Konva.Line
with tension. fix #1030
This commit is contained in:
parent
7b69e5b2f6
commit
d5d6af43fa
@ -3,6 +3,7 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
* Fix wrong size calculations for `Konva.Line` with tension
|
||||
* Fix `shape.intersects()` behavior when a node is dragged
|
||||
|
||||
## 7.2.1
|
||||
|
@ -986,6 +986,9 @@ export const Util = {
|
||||
p[n + 3],
|
||||
tension
|
||||
);
|
||||
if (isNaN(cp[0])) {
|
||||
continue;
|
||||
}
|
||||
allPoints.push(cp[0]);
|
||||
allPoints.push(cp[1]);
|
||||
allPoints.push(p[n]);
|
||||
|
@ -315,6 +315,257 @@ suite('Line', function () {
|
||||
assert.equal(Math.round(client.height), 147, 'check height');
|
||||
});
|
||||
|
||||
test.only('getClientRect with tension 2', function () {
|
||||
var stage = addStage();
|
||||
stage.draggable(true);
|
||||
var layer = new Konva.Layer();
|
||||
|
||||
var line = new Konva.Line({
|
||||
x: 0,
|
||||
y: 0,
|
||||
points: [
|
||||
494.39880507841673,
|
||||
795.3696788648244,
|
||||
494.49880507841675,
|
||||
795.4696788648245,
|
||||
494.39880507841673,
|
||||
796.8633308439133,
|
||||
489.9178491411501,
|
||||
798.3569828230022,
|
||||
480.95593726661684,
|
||||
802.8379387602688,
|
||||
467.513069454817,
|
||||
810.3061986557132,
|
||||
451.0828976848394,
|
||||
820.7617625093353,
|
||||
433.15907393577294,
|
||||
832.7109783420462,
|
||||
415.2352501867065,
|
||||
846.1538461538461,
|
||||
398.8050784167289,
|
||||
859.596713965646,
|
||||
383.8685586258402,
|
||||
871.545929798357,
|
||||
374.90664675130694,
|
||||
880.5078416728902,
|
||||
371.9193427931292,
|
||||
883.4951456310679,
|
||||
371.9193427931292,
|
||||
883.4951456310679,
|
||||
371.9193427931292,
|
||||
883.4951456310679,
|
||||
376.40029873039583,
|
||||
882.0014936519791,
|
||||
395.8177744585511,
|
||||
876.0268857356235,
|
||||
443.6146377893951,
|
||||
856.6094100074682,
|
||||
507.84167289021656,
|
||||
838.6855862584017,
|
||||
551.1575802837939,
|
||||
825.2427184466019,
|
||||
624.3465272591486,
|
||||
807.3188946975355,
|
||||
696.0418222554144,
|
||||
789.395070948469,
|
||||
758.7752053771471,
|
||||
777.445855115758,
|
||||
802.0911127707244,
|
||||
772.9648991784914,
|
||||
820.0149365197909,
|
||||
771.4712471994025,
|
||||
821.5085884988797,
|
||||
771.4712471994025,
|
||||
820.0149365197909,
|
||||
775.9522031366691,
|
||||
799.1038088125466,
|
||||
790.8887229275579,
|
||||
743.8386855862584,
|
||||
825.2427184466019,
|
||||
652.7259148618372,
|
||||
871.545929798357,
|
||||
542.1956684092606,
|
||||
926.8110530246452,
|
||||
455.563853622106,
|
||||
977.5952203136669,
|
||||
412.24794622852875,
|
||||
1010.455563853622,
|
||||
397.31142643764,
|
||||
1026.8857356235997,
|
||||
397.31142643764,
|
||||
1032.8603435399552,
|
||||
400.29873039581776,
|
||||
1038.8349514563106,
|
||||
415.2352501867065,
|
||||
1043.3159073935774,
|
||||
463.0321135175504,
|
||||
1043.3159073935774,
|
||||
563.1067961165048,
|
||||
1040.3286034353996,
|
||||
696.0418222554144,
|
||||
1032.8603435399552,
|
||||
787.1545929798357,
|
||||
1026.8857356235997,
|
||||
921.5832710978342,
|
||||
1017.9238237490664,
|
||||
1018.6706497386109,
|
||||
1013.4428678117998,
|
||||
1069.4548170276325,
|
||||
1013.4428678117998,
|
||||
1076.923076923077,
|
||||
1013.4428678117998,
|
||||
1075.4294249439881,
|
||||
1014.9365197908887,
|
||||
1051.530993278566,
|
||||
1026.8857356235997,
|
||||
979.8356982823002,
|
||||
1053.7714712471993,
|
||||
888.722927557879,
|
||||
1079.1635548917102,
|
||||
761.7625093353248,
|
||||
1116.504854368932,
|
||||
672.1433905899925,
|
||||
1150.858849887976,
|
||||
628.8274831964152,
|
||||
1171.7699775952203,
|
||||
615.3846153846154,
|
||||
1180.7318894697535,
|
||||
615.3846153846154,
|
||||
1182.2255414488425,
|
||||
618.3719193427931,
|
||||
1183.7191934279313,
|
||||
633.3084391336819,
|
||||
1182.2255414488425,
|
||||
687.0799103808812,
|
||||
1171.7699775952203,
|
||||
775.2053771471248,
|
||||
1150.858849887976,
|
||||
902.1657953696788,
|
||||
1116.504854368932,
|
||||
990.2912621359224,
|
||||
1091.1127707244211,
|
||||
1082.8976848394325,
|
||||
1062.7333831217327,
|
||||
1133.681852128454,
|
||||
1046.303211351755,
|
||||
1144.1374159820762,
|
||||
1041.8222554144884,
|
||||
1144.1374159820762,
|
||||
1041.8222554144884,
|
||||
1141.1501120238984,
|
||||
1041.8222554144884,
|
||||
1117.2516803584765,
|
||||
1043.3159073935774,
|
||||
1082.8976848394325,
|
||||
1046.303211351755,
|
||||
1008.2150858849888,
|
||||
1062.7333831217327,
|
||||
917.1023151605675,
|
||||
1092.6064227035101,
|
||||
861.8371919342793,
|
||||
1117.9985063480208,
|
||||
814.0403286034353,
|
||||
1152.352501867065,
|
||||
794.62285287528,
|
||||
1176.250933532487,
|
||||
790.1418969380135,
|
||||
1189.6938013442868,
|
||||
793.1292008961912,
|
||||
1198.65571321882,
|
||||
802.0911127707244,
|
||||
1206.1239731142643,
|
||||
831.9641523525019,
|
||||
1216.5795369678865,
|
||||
903.6594473487677,
|
||||
1225.5414488424196,
|
||||
1014.1896938013442,
|
||||
1228.5287528005974,
|
||||
1148.6183719193427,
|
||||
1228.5287528005974,
|
||||
1272.591486183719,
|
||||
1225.5414488424196,
|
||||
1314.4137415982075,
|
||||
1225.5414488424196,
|
||||
1326.3629574309186,
|
||||
1225.5414488424196,
|
||||
1326.3629574309186,
|
||||
1225.5414488424196,
|
||||
1314.4137415982075,
|
||||
1228.5287528005974,
|
||||
1272.591486183719,
|
||||
1237.4906646751306,
|
||||
1197.9088872292755,
|
||||
1247.9462285287527,
|
||||
1105.3024645257656,
|
||||
1270.3510082150858,
|
||||
1048.5436893203882,
|
||||
1286.7811799850635,
|
||||
1024.6452576549664,
|
||||
1295.7430918595967,
|
||||
1006.7214339058999,
|
||||
1306.1986557132188,
|
||||
1000.7468259895444,
|
||||
1313.6669156086632,
|
||||
1000.7468259895444,
|
||||
1315.160567587752,
|
||||
1003.7341299477222,
|
||||
1316.6542195668408,
|
||||
1015.6833457804331,
|
||||
1319.6415235250186,
|
||||
1050.0373412994772,
|
||||
1321.1351755041076,
|
||||
1103.8088125466766,
|
||||
1321.1351755041076,
|
||||
1169.529499626587,
|
||||
1316.6542195668408,
|
||||
1220.3136669156086,
|
||||
1310.6796116504854,
|
||||
1248.6930545182972,
|
||||
1307.6923076923076,
|
||||
1253.1740104555638,
|
||||
1307.6923076923076,
|
||||
1253.1740104555638,
|
||||
1307.6923076923076,
|
||||
1253.1740104555638,
|
||||
1307.6923076923076,
|
||||
1248.6930545182972,
|
||||
1309.1859596713964,
|
||||
1229.275578790142,
|
||||
1312.1732636295742,
|
||||
1199.4025392083645,
|
||||
1319.6415235250186,
|
||||
1172.5168035847648,
|
||||
1330.0970873786407,
|
||||
1154.5929798356983,
|
||||
1342.0463032113516,
|
||||
1144.1374159820762,
|
||||
1353.9955190440626,
|
||||
1139.6564600448096,
|
||||
1361.463778939507,
|
||||
1138.1628080657206,
|
||||
1364.4510828976847,
|
||||
1138.1628080657206,
|
||||
1365.9447348767737,
|
||||
1138.1628080657206,
|
||||
1365.9447348767737,
|
||||
],
|
||||
tension: 0.5,
|
||||
stroke: '#0f0',
|
||||
});
|
||||
layer.add(line);
|
||||
|
||||
var client = line.getClientRect();
|
||||
var rect = new Konva.Rect(Konva.Util._assign({ stroke: 'red' }, client));
|
||||
layer.add(rect);
|
||||
|
||||
stage.add(layer);
|
||||
|
||||
assert.equal(Math.round(client.x), 371, 'check x');
|
||||
assert.equal(Math.round(client.y), 770, 'check y');
|
||||
assert.equal(Math.round(client.width), 956, 'check width');
|
||||
assert.equal(Math.round(client.height), 597, 'check height');
|
||||
});
|
||||
|
||||
test('getClientRect with low number of points', function () {
|
||||
var stage = addStage();
|
||||
var layer = new Konva.Layer();
|
||||
|
Loading…
Reference in New Issue
Block a user