|
|
|
@ -5,12 +5,12 @@ function createEnd() {
|
|
|
|
|
var X = stage.width() - stage.width() / 100 * 5;
|
|
|
|
|
var Y = stage.height() / 2;
|
|
|
|
|
|
|
|
|
|
var endShape = new Konva.RegularPolygon({
|
|
|
|
|
x: X,
|
|
|
|
|
y: Y,
|
|
|
|
|
sides: 6,
|
|
|
|
|
radius: 30,
|
|
|
|
|
var endShape = new Konva.Rect({
|
|
|
|
|
x: X - 25,
|
|
|
|
|
y: Y - 25,
|
|
|
|
|
fill: colorEnd,
|
|
|
|
|
width: 50,
|
|
|
|
|
height: 50,
|
|
|
|
|
stroke: 'black',
|
|
|
|
|
strokeWidth: 4,
|
|
|
|
|
id: "end",
|
|
|
|
@ -27,6 +27,19 @@ function createEnd() {
|
|
|
|
|
layer.add(endShape);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function createCircle(x, y) {
|
|
|
|
|
var circle = new Konva.Circle({
|
|
|
|
|
x: x,
|
|
|
|
|
y: y,
|
|
|
|
|
radius: 10,
|
|
|
|
|
fill: 'black',
|
|
|
|
|
stroke: 'black',
|
|
|
|
|
strokeWidth: 4,
|
|
|
|
|
});
|
|
|
|
|
layer.add(circle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function createSwitch(id, x, y) {
|
|
|
|
|
var switche = {
|
|
|
|
|
id: id,
|
|
|
|
@ -53,13 +66,25 @@ function createSwitch(id, x, y) {
|
|
|
|
|
layer.add(rect1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function createLine(points, id) {
|
|
|
|
|
function createLine(points, id, end) {
|
|
|
|
|
let startX = points[0],
|
|
|
|
|
startY = points[1],
|
|
|
|
|
endX = points[2],
|
|
|
|
|
endY = points[3];
|
|
|
|
|
let distance20 = (endX - startX) / 100 * pourcentageBreak;
|
|
|
|
|
let newPoints = [startX, startY, startX + distance20, startY, endX - distance20, endY, endX, endY];
|
|
|
|
|
var newPoints;
|
|
|
|
|
if (end != undefined && end != null && end === true) {
|
|
|
|
|
let distance20 = (endX - startX) / 100 * 5;
|
|
|
|
|
let distance80 = (endX - startX) / 100 * 90;
|
|
|
|
|
newPoints = [startX, startY, startX + distance80, startY, endX - distance20, endY, endX, endY];
|
|
|
|
|
} else if (end != undefined && end != null && end === false) {
|
|
|
|
|
let distance20 = (endX - startX) / 100 * 10;
|
|
|
|
|
let distance80 = (endX - startX) / 100 * 80;
|
|
|
|
|
newPoints = [startX, startY, startX + distance80, startY, endX - distance20, endY, endX, endY];
|
|
|
|
|
} else {
|
|
|
|
|
let distance20 = (endX - startX) / 100 * pourcentageBreak;
|
|
|
|
|
newPoints = [startX, startY, startX + distance20, startY, endX - distance20, endY, endX, endY];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let line = new Konva.Line({
|
|
|
|
|
points: newPoints,
|
|
|
|
|
stroke: colorLineInnactive,
|
|
|
|
@ -95,7 +120,7 @@ function createLink(entre, sortie) {
|
|
|
|
|
} else {
|
|
|
|
|
var logiqueMidY = sortie.y + (imageHeight / 3);
|
|
|
|
|
}
|
|
|
|
|
createLine([switchMidX, switchMidY, logiqueMidX, logiqueMidY], "line" + lineId);
|
|
|
|
|
createLine([switchMidX, switchMidY, logiqueMidX, logiqueMidY], "line" + lineId, false);
|
|
|
|
|
setLine(sortie, "id1", "line" + lineId);
|
|
|
|
|
|
|
|
|
|
let truc = entre.x;
|
|
|
|
@ -103,7 +128,7 @@ function createLink(entre, sortie) {
|
|
|
|
|
break;
|
|
|
|
|
case "id2":
|
|
|
|
|
|
|
|
|
|
createLine([entre.getX() + entre.getWidth(), entre.getY() + entre.getHeight() / 2, sortie.x, sortie.y + (imageHeight / 3) * 2], "line" + lineId);
|
|
|
|
|
createLine([entre.getX() + entre.getWidth(), entre.getY() + entre.getHeight() / 2, sortie.x, sortie.y + (imageHeight / 3) * 2], "line" + lineId, false);
|
|
|
|
|
setLine(sortie, "id2", "line" + lineId);
|
|
|
|
|
getSwitchById(entre.id()).id3.push("line" + lineId);
|
|
|
|
|
|
|
|
|
@ -138,7 +163,10 @@ function createLink(entre, sortie) {
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
endLines.push(lineId);
|
|
|
|
|
createLine([entre.x + imageWidth, entre.y + imageHeight / 2, sortie.x, sortie.y], "line" + lineId);
|
|
|
|
|
if (end.position === 1) createLine([entre.x + imageWidth, entre.y + imageHeight / 2, sortie.x, (end.y + (50 / (end.position + 1) * (end.let-end.position)))], "line" + lineId, true);
|
|
|
|
|
|
|
|
|
|
else createLine([entre.x + imageWidth, entre.y + imageHeight / 2, sortie.x, (end.y + (50 / (end.position + 1) * (end.let+1 - end.position)))], "line" + lineId, true);
|
|
|
|
|
|
|
|
|
|
setLine(entre, "id3", "line" + lineId);
|
|
|
|
|
end.let--;
|
|
|
|
|
break;
|
|
|
|
@ -147,7 +175,6 @@ function createLink(entre, sortie) {
|
|
|
|
|
default:
|
|
|
|
|
console.log("error");
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|