|
|
@ -3,7 +3,6 @@ function createEnd() {
|
|
|
|
//find X and Y
|
|
|
|
//find X and Y
|
|
|
|
|
|
|
|
|
|
|
|
var X = stage.width() - stage.width() /100 * 10;
|
|
|
|
var X = stage.width() - stage.width() /100 * 10;
|
|
|
|
console.log(X);
|
|
|
|
|
|
|
|
var Y = stage.height() / 3;
|
|
|
|
var Y = stage.height() / 3;
|
|
|
|
|
|
|
|
|
|
|
|
var imageObj2 = new Image();
|
|
|
|
var imageObj2 = new Image();
|
|
|
@ -31,6 +30,13 @@ function createEnd() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function createSwitch(id, x, y) {
|
|
|
|
function createSwitch(id, x, y) {
|
|
|
|
|
|
|
|
var switche = {
|
|
|
|
|
|
|
|
id : id,
|
|
|
|
|
|
|
|
x : x,
|
|
|
|
|
|
|
|
y : y,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
switchsInfo.push(switche);
|
|
|
|
|
|
|
|
switchsInfoCopy.push(switche);
|
|
|
|
switchs.push(id);
|
|
|
|
switchs.push(id);
|
|
|
|
var num = lineCount.length;
|
|
|
|
var num = lineCount.length;
|
|
|
|
lineCount.push(1);
|
|
|
|
lineCount.push(1);
|
|
|
@ -70,7 +76,8 @@ function createLink(entre, sortie) {
|
|
|
|
case "switch":
|
|
|
|
case "switch":
|
|
|
|
switch (whatIsElement(sortie)) {
|
|
|
|
switch (whatIsElement(sortie)) {
|
|
|
|
case "logique":
|
|
|
|
case "logique":
|
|
|
|
switch (giveLineId(sortie.name)) {
|
|
|
|
switch (giveLineId(sortie.name,entre)) {
|
|
|
|
|
|
|
|
|
|
|
|
case "id1":
|
|
|
|
case "id1":
|
|
|
|
let switchMidX = entre.getX() + entre.getWidth();
|
|
|
|
let switchMidX = entre.getX() + entre.getWidth();
|
|
|
|
let switchMidY = entre.getY() + entre.getHeight() / 2;
|
|
|
|
let switchMidY = entre.getY() + entre.getHeight() / 2;
|
|
|
@ -96,7 +103,7 @@ function createLink(entre, sortie) {
|
|
|
|
case "logique":
|
|
|
|
case "logique":
|
|
|
|
switch (whatIsElement(sortie)) {
|
|
|
|
switch (whatIsElement(sortie)) {
|
|
|
|
case "logique":
|
|
|
|
case "logique":
|
|
|
|
switch (giveLineId(sortie.name)) {
|
|
|
|
switch (giveLineId(sortie.name,entre)) {
|
|
|
|
case "id1":
|
|
|
|
case "id1":
|
|
|
|
let switchMidX = entre.x + imageWidth;
|
|
|
|
let switchMidX = entre.x + imageWidth;
|
|
|
|
let switchMidY = entre.y + imageHeight / 2;
|
|
|
|
let switchMidY = entre.y + imageHeight / 2;
|
|
|
@ -120,7 +127,7 @@ function createLink(entre, sortie) {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
endLines.push(lineId);
|
|
|
|
endLines.push(lineId);
|
|
|
|
createLine([entre.x + imageWidth, entre.y + imageHeight / 2, sortie.x, sortie.y + (imageHeight / end.position+1)*end.let], "line" + lineId);
|
|
|
|
createLine([entre.x + imageWidth, entre.y + imageHeight / 2, sortie.x, sortie.y + (imageHeight / end.position)*end.let], "line" + lineId);
|
|
|
|
setLine(entre, "id3", "line" + lineId);
|
|
|
|
setLine(entre, "id3", "line" + lineId);
|
|
|
|
end.let--;
|
|
|
|
end.let--;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -182,6 +189,7 @@ function createLogique(x, y, id, type) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function switchCreator(number){
|
|
|
|
function switchCreator(number){
|
|
|
|
|
|
|
|
numberOfSwitch = number;
|
|
|
|
let split = number + 1;
|
|
|
|
let split = number + 1;
|
|
|
|
let space = (stage.height() - stage.height()/100*25) / split;
|
|
|
|
let space = (stage.height() - stage.height()/100*25) / split;
|
|
|
|
for(let i = 1; i < number+1 ; i++){
|
|
|
|
for(let i = 1; i < number+1 ; i++){
|
|
|
@ -202,3 +210,33 @@ function insertLogiqueColonne(nomLogique, TypeLogique, colonne){
|
|
|
|
createLogique(X, Y, nomLogique,TypeLogique);
|
|
|
|
createLogique(X, Y, nomLogique,TypeLogique);
|
|
|
|
liveColonneNumber[colonne].push(1);
|
|
|
|
liveColonneNumber[colonne].push(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function createLinkSwitch(){
|
|
|
|
|
|
|
|
var logique = null;
|
|
|
|
|
|
|
|
var distance = stage.width();
|
|
|
|
|
|
|
|
//Trouver la porte logique la plus proche des switchs
|
|
|
|
|
|
|
|
logiques.forEach(function(element){
|
|
|
|
|
|
|
|
if(element.id1 == null || element.id2 == null){
|
|
|
|
|
|
|
|
if(element.x < distance){
|
|
|
|
|
|
|
|
logique = element;
|
|
|
|
|
|
|
|
distance = element.x;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
var distanceSwitch = stage.height();
|
|
|
|
|
|
|
|
var switchs = null;
|
|
|
|
|
|
|
|
switchsInfo.forEach(function(element){
|
|
|
|
|
|
|
|
if(Math.abs(logique.y - element.y) < distanceSwitch){
|
|
|
|
|
|
|
|
distanceSwitch = Math.abs(logique.y - element.y);
|
|
|
|
|
|
|
|
switchs = element;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
switchsInfo.splice( switchsInfo.indexOf(switchs), 1 );
|
|
|
|
|
|
|
|
createLink(stage.findOne("#"+switchs.id), findLogique(logique.name));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function createAllLinkSwitch(){
|
|
|
|
|
|
|
|
for(let i = 0;i < numberOfSwitch; i++){
|
|
|
|
|
|
|
|
createLinkSwitch();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|