|
|
@ -9,11 +9,17 @@ function createEnd(x, y) {
|
|
|
|
height: 50,
|
|
|
|
height: 50,
|
|
|
|
id: "end",
|
|
|
|
id: "end",
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
layer.add(end);
|
|
|
|
layer.add(end);
|
|
|
|
layer.batchDraw();
|
|
|
|
layer.batchDraw();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
end = {
|
|
|
|
|
|
|
|
name: "end",
|
|
|
|
|
|
|
|
x: x,
|
|
|
|
|
|
|
|
y: y,
|
|
|
|
|
|
|
|
type: "end",
|
|
|
|
|
|
|
|
position: 1,
|
|
|
|
|
|
|
|
let:1,
|
|
|
|
|
|
|
|
}
|
|
|
|
imageObj2.src = pathImg + imageEnd;
|
|
|
|
imageObj2.src = pathImg + imageEnd;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -36,8 +42,11 @@ function createSwitch(id, x, y) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function createLine(points, id) {
|
|
|
|
function createLine(points, id) {
|
|
|
|
|
|
|
|
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];
|
|
|
|
let line = new Konva.Line({
|
|
|
|
let line = new Konva.Line({
|
|
|
|
points: points,
|
|
|
|
points: newPoints,
|
|
|
|
stroke: colorLineInnactive,
|
|
|
|
stroke: colorLineInnactive,
|
|
|
|
strokeWidth: lineStroke,
|
|
|
|
strokeWidth: lineStroke,
|
|
|
|
id: id,
|
|
|
|
id: id,
|
|
|
@ -46,8 +55,10 @@ function createLine(points, id) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function createLink(entre, sortie, lineId) {
|
|
|
|
function createLink(entre, sortie) {
|
|
|
|
//entre est une porte logique
|
|
|
|
//entre est une porte logique
|
|
|
|
|
|
|
|
lineId = lineCount.length;
|
|
|
|
|
|
|
|
lineCount.push(1);
|
|
|
|
switch (whatIsElement(entre)) {
|
|
|
|
switch (whatIsElement(entre)) {
|
|
|
|
case "switch":
|
|
|
|
case "switch":
|
|
|
|
switch (whatIsElement(sortie)) {
|
|
|
|
switch (whatIsElement(sortie)) {
|
|
|
@ -91,14 +102,19 @@ function createLink(entre, sortie, lineId) {
|
|
|
|
setLine(entre, "id3", "line" + lineId);
|
|
|
|
setLine(entre, "id3", "line" + lineId);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
endLines.push(lineId);
|
|
|
|
|
|
|
|
createLine([entre.x + imageWidth, entre.y + imageHeight / 2, sortie.x, sortie.y + (imageHeight / end.position+1)*end.let], "line" + lineId);
|
|
|
|
|
|
|
|
setLine(entre, "id3", "line" + lineId);
|
|
|
|
|
|
|
|
end.let--;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function createLogique(x, y, id, type) {
|
|
|
|
function createLogique(x, y, id, type) {
|
|
|
|
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
|
|
|
|
case "et":
|
|
|
|
|
|
|
|
var imageObj = new Image();
|
|
|
|
var imageObj = new Image();
|
|
|
|
imageObj.onload = function () {
|
|
|
|
imageObj.onload = function () {
|
|
|
|
var et = new Konva.Image({
|
|
|
|
var et = new Konva.Image({
|
|
|
@ -109,35 +125,24 @@ function createLogique(x, y, id, type) {
|
|
|
|
height: imageHeight,
|
|
|
|
height: imageHeight,
|
|
|
|
id: id,
|
|
|
|
id: id,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
if (imageRotation != 0) {
|
|
|
|
|
|
|
|
et.rotation(imageRotation);
|
|
|
|
|
|
|
|
et.x(et.getX() + imageHeight);
|
|
|
|
|
|
|
|
}
|
|
|
|
layer.add(et);
|
|
|
|
layer.add(et);
|
|
|
|
layer.batchDraw();
|
|
|
|
layer.batchDraw();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
switch(type){
|
|
|
|
|
|
|
|
case "et" :
|
|
|
|
imageObj.src = pathImg + imageLogiqueEt;
|
|
|
|
imageObj.src = pathImg + imageLogiqueEt;
|
|
|
|
imageObj.id = id;
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case "ou":
|
|
|
|
case "ou":
|
|
|
|
var imageObj = new Image();
|
|
|
|
|
|
|
|
imageObj.onload = function () {
|
|
|
|
|
|
|
|
var et = new Konva.Image({
|
|
|
|
|
|
|
|
x: x,
|
|
|
|
|
|
|
|
y: y,
|
|
|
|
|
|
|
|
image: imageObj,
|
|
|
|
|
|
|
|
width: imageWidth,
|
|
|
|
|
|
|
|
height: imageHeight,
|
|
|
|
|
|
|
|
id: id,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
layer.add(et);
|
|
|
|
|
|
|
|
layer.batchDraw();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
imageObj.src = pathImg + imageLogiqueOu;
|
|
|
|
imageObj.src = pathImg + imageLogiqueOu;
|
|
|
|
imageObj.id = id;
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
imageObj.id = id;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var logique = {
|
|
|
|
var logique = {
|
|
|
|