mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Simplify vertical wire path
This commit is contained in:
parent
61f42f9efa
commit
8e8cac60b0
@ -596,74 +596,46 @@ RED.view = (function() {
|
||||
}
|
||||
}
|
||||
|
||||
function drawCross(x,y,i) {
|
||||
var res = " M "+(x-4)+" "+y+" h8 M "+x+" "+(y-4)+" v8 ";
|
||||
res += " M "+(x-8)+" "+(y-8)+" h2 ";
|
||||
if (i>0) res += " M "+(x+8)+" "+(y-8)+" h2 ";
|
||||
if (i>1) res += " M "+(x+8)+" "+(y+8)+" h2 ";
|
||||
if (i>2) res += " M "+(x-8)+" "+(y+8)+" h2 ";
|
||||
return res;
|
||||
}
|
||||
function drawCircle(x,y,w) {
|
||||
return " M "+x+" "+y+" m -"+w+" 0 "+
|
||||
"a "+w+","+w+" 0 1,0 "+(2*w)+",0 "+
|
||||
"a "+w+","+w+" 0 1,0 -"+(2*w)+",0 "
|
||||
}
|
||||
function drawLine(x1,y1,x2,y2) {
|
||||
return " M "+x1+","+y1+" L "+x2+","+y2+" "
|
||||
}
|
||||
|
||||
function generateLinkPathV(origX,origY, destX, destY, sc) {
|
||||
var dy = destY-origY;
|
||||
var dx = destX-origX;
|
||||
var delta = Math.sqrt(dy*dy+dx*dx);
|
||||
var scale = lineCurveScale;
|
||||
var fullScale = lineCurveScale*4;
|
||||
var scale = fullScale;
|
||||
var scaleX = 0;
|
||||
if (dy*sc > 0) {
|
||||
if (delta < node_height) {
|
||||
scale = 0.75-0.75*((node_height-delta)/node_height);
|
||||
// scale += 2*(Math.min(5*node_height,Math.abs(dx))/(5*node_height));
|
||||
// if (Math.abs(dy) < 3*node_height) {
|
||||
// scaleY = ((dy>0)?0.5:-0.5)*(((3*node_height)-Math.abs(dy))/(3*node_height))*(Math.min(node_height,Math.abs(dx))/(node_height)) ;
|
||||
// }
|
||||
}
|
||||
} else {
|
||||
scale = 0.4-0.2*(Math.max(0,(node_height-Math.min(Math.abs(dx),Math.abs(dy)))/node_height));
|
||||
}
|
||||
if (dy*sc > 0) {
|
||||
return "M "+origX+" "+origY+
|
||||
" C "+(origX+(node_width*scaleX))+" "+(origY+sc*scale*node_height)+" "+
|
||||
(destX-(node_width*scaleX))+" "+(destY-sc*scale*node_height)+" "+
|
||||
destX+" "+destY
|
||||
} else {
|
||||
if (dy*sc <= 0) {
|
||||
var r = 1-Math.max(0,((2*node_height) - Math.abs(dy*sc))/(2*node_height));
|
||||
scale = fullScale+(2*fullScale*r);
|
||||
|
||||
var midX = Math.floor(destX-dx/2);
|
||||
var midY = Math.floor(destY-dy/2);
|
||||
//
|
||||
if (dx === 0) {
|
||||
midX = destX + node_width;
|
||||
} else if (delta < (1.5*node_width)) {
|
||||
scale = fullScale-fullScale*(((1.5*node_width)-delta)/(1.5*node_width));
|
||||
}
|
||||
var cp_width = node_width/2;
|
||||
var x1 = (destX + midX)/2;
|
||||
var topX = dx>0? Math.min(x1 - dx/2 , origX+cp_width) : Math.max(x1 - dx/2 , origX-cp_width);
|
||||
var topY = origY + sc*node_height*scale;
|
||||
var bottomX = dx>0?Math.max(x1, destX-cp_width):Math.min(x1, destX+cp_width);
|
||||
var bottomY = destY - sc*node_height*scale;
|
||||
var y1 = (origY+topY)/2;
|
||||
var scx = dx>0?1:-1;
|
||||
var cp = [
|
||||
[origX,y1],
|
||||
[dx>0 ? Math.max(origX, topX-cp_width) : Math.min(origX, topX+cp_width), topY],
|
||||
[dx>0 ? Math.max(midX, topX-cp_width) : Math.min(midX, topX-cp_width), y1],
|
||||
[dx>0 ? Math.max(midX, bottomX-cp_width): Math.min(midX, bottomX+cp_width), bottomY],
|
||||
[destX,(destY+bottomY)/2]
|
||||
[origX, origY+sc*scale*node_height],
|
||||
[destX, destY-sc*scale*node_height]
|
||||
];
|
||||
if (cp[2][0] === topX+scx*cp_width) {
|
||||
if (Math.abs(dx) < cp_width*10) {
|
||||
cp[1][0] = topX-scx*cp_width/2;
|
||||
cp[3][0] = bottomX-scx*cp_width/2;
|
||||
}
|
||||
cp[2][1] = topY;
|
||||
}
|
||||
return "M "+origX+" "+origY+
|
||||
" C "+
|
||||
cp[0][0]+" "+cp[0][1]+" "+
|
||||
" C "+cp[0][0]+" "+cp[0][1]+" "+
|
||||
cp[1][0]+" "+cp[1][1]+" "+
|
||||
topX+" "+topY+
|
||||
" S "+
|
||||
cp[2][0]+" "+cp[2][1]+" "+
|
||||
midX+" "+midY+
|
||||
" S "+
|
||||
cp[3][0]+" "+cp[3][1]+" "+
|
||||
bottomX+" "+bottomY+
|
||||
" S "+
|
||||
cp[4][0]+" "+cp[4][1]+" "+
|
||||
destX+" "+destY
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function addNode(type,x,y) {
|
||||
|
Loading…
Reference in New Issue
Block a user