Changeset 0c6b92a for imaps-frontend/node_modules/konva/lib/shapes/Path.js
Legend:
- Unmodified
- Added
- Removed
-
imaps-frontend/node_modules/konva/lib/shapes/Path.js
rd565449 r0c6b92a 21 21 } 22 22 _sceneFunc(context) { 23 varca = this.dataArray;23 const ca = this.dataArray; 24 24 context.beginPath(); 25 varisClosed = false;26 for ( varn = 0; n < ca.length; n++) {27 varc = ca[n].command;28 varp = ca[n].points;25 let isClosed = false; 26 for (let n = 0; n < ca.length; n++) { 27 const c = ca[n].command; 28 const p = ca[n].points; 29 29 switch (c) { 30 30 case 'L': … … 67 67 } 68 68 getSelfRect() { 69 varpoints = [];69 let points = []; 70 70 this.dataArray.forEach(function (data) { 71 71 if (data.command === 'A') { 72 varstart = data.points[4];73 vardTheta = data.points[5];74 varend = data.points[4] + dTheta;75 varinc = Math.PI / 180.0;72 const start = data.points[4]; 73 const dTheta = data.points[5]; 74 const end = data.points[4] + dTheta; 75 let inc = Math.PI / 180.0; 76 76 if (Math.abs(start - end) < inc) { 77 77 inc = Math.abs(start - end); … … 100 100 } 101 101 }); 102 varminX = points[0];103 varmaxX = points[0];104 varminY = points[1];105 varmaxY = points[1];106 varx, y;107 for ( vari = 0; i < points.length / 2; i++) {102 let minX = points[0]; 103 let maxX = points[0]; 104 let minY = points[1]; 105 let maxY = points[1]; 106 let x, y; 107 for (let i = 0; i < points.length / 2; i++) { 108 108 x = points[i * 2]; 109 109 y = points[i * 2 + 1]; … … 135 135 static getPathLength(dataArray) { 136 136 let pathLength = 0; 137 for ( vari = 0; i < dataArray.length; ++i) {137 for (let i = 0; i < dataArray.length; ++i) { 138 138 pathLength += dataArray[i].pathLength; 139 139 } … … 141 141 } 142 142 static getPointAtLengthOfDataArray(length, dataArray) { 143 var point, i = 0, ii = dataArray.length;143 let points, i = 0, ii = dataArray.length; 144 144 if (!ii) { 145 145 return null; … … 150 150 } 151 151 if (i === ii) { 152 point = dataArray[i - 1].points.slice(-2);152 points = dataArray[i - 1].points.slice(-2); 153 153 return { 154 x: point [0],155 y: point [1],154 x: points[0], 155 y: points[1], 156 156 }; 157 157 } 158 158 if (length < 0.01) { 159 point = dataArray[i].points.slice(0, 2);159 points = dataArray[i].points.slice(0, 2); 160 160 return { 161 x: point [0],162 y: point [1],161 x: points[0], 162 y: points[1], 163 163 }; 164 164 } 165 varcp = dataArray[i];166 varp = cp.points;165 const cp = dataArray[i]; 166 const p = cp.points; 167 167 switch (cp.command) { 168 168 case 'L': … … 221 221 return (1 - t) * (1 - t) * (1 - t); 222 222 } 223 varx = P4x * CB1(pct) + P3x * CB2(pct) + P2x * CB3(pct) + P1x * CB4(pct);224 vary = P4y * CB1(pct) + P3y * CB2(pct) + P2y * CB3(pct) + P1y * CB4(pct);223 const x = P4x * CB1(pct) + P3x * CB2(pct) + P2x * CB3(pct) + P1x * CB4(pct); 224 const y = P4y * CB1(pct) + P3y * CB2(pct) + P2y * CB3(pct) + P1y * CB4(pct); 225 225 return { 226 226 x: x, … … 238 238 return (1 - t) * (1 - t); 239 239 } 240 varx = P3x * QB1(pct) + P2x * QB2(pct) + P1x * QB3(pct);241 vary = P3y * QB1(pct) + P2y * QB2(pct) + P1y * QB3(pct);240 const x = P3x * QB1(pct) + P2x * QB2(pct) + P1x * QB3(pct); 241 const y = P3y * QB1(pct) + P2y * QB2(pct) + P1y * QB3(pct); 242 242 return { 243 243 x: x, … … 246 246 } 247 247 static getPointOnEllipticalArc(cx, cy, rx, ry, theta, psi) { 248 varcosPsi = Math.cos(psi), sinPsi = Math.sin(psi);249 varpt = {248 const cosPsi = Math.cos(psi), sinPsi = Math.sin(psi); 249 const pt = { 250 250 x: rx * Math.cos(theta), 251 251 y: ry * Math.sin(theta), … … 260 260 return []; 261 261 } 262 varcs = data;263 varcc = [262 let cs = data; 263 const cc = [ 264 264 'm', 265 265 'M', … … 287 287 cs = cs.replace(new RegExp(cc[n], 'g'), '|' + cc[n]); 288 288 } 289 vararr = cs.split('|');290 varca = [];291 varcoords = [];292 varcpx = 0;293 varcpy = 0;294 varre = /([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;295 varmatch;289 const arr = cs.split('|'); 290 const ca = []; 291 const coords = []; 292 let cpx = 0; 293 let cpy = 0; 294 const re = /([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi; 295 let match; 296 296 for (n = 1; n < arr.length; n++) { 297 varstr = arr[n];298 varc = str.charAt(0);297 let str = arr[n]; 298 let c = str.charAt(0); 299 299 str = str.slice(1); 300 300 coords.length = 0; … … 302 302 coords.push(match[0]); 303 303 } 304 varp = [];305 for ( varj = 0, jlen = coords.length; j < jlen; j++) {304 const p = []; 305 for (let j = 0, jlen = coords.length; j < jlen; j++) { 306 306 if (coords[j] === '00') { 307 307 p.push(0, 0); 308 308 continue; 309 309 } 310 varparsed = parseFloat(coords[j]);310 const parsed = parseFloat(coords[j]); 311 311 if (!isNaN(parsed)) { 312 312 p.push(parsed); … … 320 320 break; 321 321 } 322 varcmd = '';323 varpoints = [];324 varstartX = cpx, startY = cpy;322 let cmd = ''; 323 let points = []; 324 const startX = cpx, startY = cpy; 325 325 var prevCmd, ctlPtx, ctlPty; 326 326 var rx, ry, psi, fa, fs, x1, y1; … … 344 344 cmd = 'M'; 345 345 if (ca.length > 2 && ca[ca.length - 1].command === 'z') { 346 for ( varidx = ca.length - 2; idx >= 0; idx--) {346 for (let idx = ca.length - 2; idx >= 0; idx--) { 347 347 if (ca[idx].command === 'M') { 348 348 cpx = ca[idx].points[0] + dx; … … 511 511 } 512 512 static calcLength(x, y, cmd, points) { 513 varlen, p1, p2, t;514 varpath = Path;513 let len, p1, p2, t; 514 const path = Path; 515 515 switch (cmd) { 516 516 case 'L': … … 551 551 } 552 552 static convertEndpointToCenterParameterization(x1, y1, x2, y2, fa, fs, rx, ry, psiDeg) { 553 varpsi = psiDeg * (Math.PI / 180.0);554 varxp = (Math.cos(psi) * (x1 - x2)) / 2.0 + (Math.sin(psi) * (y1 - y2)) / 2.0;555 varyp = (-1 * Math.sin(psi) * (x1 - x2)) / 2.0 +553 const psi = psiDeg * (Math.PI / 180.0); 554 const xp = (Math.cos(psi) * (x1 - x2)) / 2.0 + (Math.sin(psi) * (y1 - y2)) / 2.0; 555 const yp = (-1 * Math.sin(psi) * (x1 - x2)) / 2.0 + 556 556 (Math.cos(psi) * (y1 - y2)) / 2.0; 557 varlambda = (xp * xp) / (rx * rx) + (yp * yp) / (ry * ry);557 const lambda = (xp * xp) / (rx * rx) + (yp * yp) / (ry * ry); 558 558 if (lambda > 1) { 559 559 rx *= Math.sqrt(lambda); 560 560 ry *= Math.sqrt(lambda); 561 561 } 562 varf = Math.sqrt((rx * rx * (ry * ry) - rx * rx * (yp * yp) - ry * ry * (xp * xp)) /562 let f = Math.sqrt((rx * rx * (ry * ry) - rx * rx * (yp * yp) - ry * ry * (xp * xp)) / 563 563 (rx * rx * (yp * yp) + ry * ry * (xp * xp))); 564 564 if (fa === fs) { … … 568 568 f = 0; 569 569 } 570 varcxp = (f * rx * yp) / ry;571 varcyp = (f * -ry * xp) / rx;572 varcx = (x1 + x2) / 2.0 + Math.cos(psi) * cxp - Math.sin(psi) * cyp;573 varcy = (y1 + y2) / 2.0 + Math.sin(psi) * cxp + Math.cos(psi) * cyp;574 varvMag = function (v) {570 const cxp = (f * rx * yp) / ry; 571 const cyp = (f * -ry * xp) / rx; 572 const cx = (x1 + x2) / 2.0 + Math.cos(psi) * cxp - Math.sin(psi) * cyp; 573 const cy = (y1 + y2) / 2.0 + Math.sin(psi) * cxp + Math.cos(psi) * cyp; 574 const vMag = function (v) { 575 575 return Math.sqrt(v[0] * v[0] + v[1] * v[1]); 576 576 }; 577 varvRatio = function (u, v) {577 const vRatio = function (u, v) { 578 578 return (u[0] * v[0] + u[1] * v[1]) / (vMag(u) * vMag(v)); 579 579 }; 580 varvAngle = function (u, v) {580 const vAngle = function (u, v) { 581 581 return (u[0] * v[1] < u[1] * v[0] ? -1 : 1) * Math.acos(vRatio(u, v)); 582 582 }; 583 vartheta = vAngle([1, 0], [(xp - cxp) / rx, (yp - cyp) / ry]);584 varu = [(xp - cxp) / rx, (yp - cyp) / ry];585 varv = [(-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry];586 vardTheta = vAngle(u, v);583 const theta = vAngle([1, 0], [(xp - cxp) / rx, (yp - cyp) / ry]); 584 const u = [(xp - cxp) / rx, (yp - cyp) / ry]; 585 const v = [(-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry]; 586 let dTheta = vAngle(u, v); 587 587 if (vRatio(u, v) <= -1) { 588 588 dTheta = Math.PI;
Note:
See TracChangeset
for help on using the changeset viewer.