generateur + croisement

master
pisouvigne 5 years ago
parent 091cfa7ea4
commit 9977890deb

@ -28,8 +28,11 @@ function createEnd() {
} }
function createCircle(x, y) { function createCircle(x, y, name) {
name.forEach(function (idLine) {
var circle = new Konva.Circle({ var circle = new Konva.Circle({
id: "circle" + idLine,
x: x, x: x,
y: y, y: y,
radius: 10, radius: 10,
@ -37,7 +40,10 @@ function createCircle(x, y) {
stroke: 'black', stroke: 'black',
strokeWidth: 4, strokeWidth: 4,
}); });
circles.push("circle" + idLine);
layer.add(circle); layer.add(circle);
});
} }
function createSwitch(id, x, y) { function createSwitch(id, x, y) {

@ -228,10 +228,23 @@ function changeLineColorBlack(idLine) {
setLineStateFalse(idLine); setLineStateFalse(idLine);
let line = stage.findOne("#" + idLine); let line = stage.findOne("#" + idLine);
line.stroke(colorLineInnactive); line.stroke(colorLineInnactive);
console.log(idLine);
circles.forEach(function (circle) {
if (circle === "circle" + idLine) {
stage.findOne("#circle" + idLine).stroke(colorLineInnactive);
stage.findOne("#circle" + idLine).fill(colorLineInnactive);
}
});
} }
function changeLineColorYellow(idLine) { function changeLineColorYellow(idLine) {
setLineStateTrue(idLine); setLineStateTrue(idLine);
circles.forEach(function (circle) {
if (circle === "circle" + idLine) {
stage.findOne("#circle" + idLine).stroke(colorLineActive);
stage.findOne("#circle" + idLine).fill(colorLineActive);
}
});
let line = stage.findOne("#" + idLine); let line = stage.findOne("#" + idLine);
line.stroke(colorLineActive); line.stroke(colorLineActive);
} }
@ -923,3 +936,9 @@ function flip() {
}); });
rotated = !rotated; rotated = !rotated;
} }
function setCanvasScale(x, y) {
console.log(document.getElementsByTagName("canvas"));
var ctx = document.getElementsByTagName("canvas").getContext("2d");
console.log(ctx);
}

@ -542,12 +542,11 @@ function generate2(col, matchs, fork) {
loEntre = findLogique(logiqueEntre[i].id); loEntre = findLogique(logiqueEntre[i].id);
} }
logiques.forEach(function (logique) { logiques.forEach(function (logique) {
if (logique.name === logiqueFork.id) createCircle(logique.x + imageWidth + ((loEntre.x - findLogique(logiqueFork.id).x) / 100 * pourcentageBreak), findLogique(logiqueFork.id).y + imageHeight / 2); if (logique.name === logiqueFork.id) createCircle(logique.x + imageWidth + ((loEntre.x - findLogique(logiqueFork.id).x) / 100 * pourcentageBreak), findLogique(logiqueFork.id).y + imageHeight / 2, logique.id3);
}); });
fork.splice(fork.indexOf(element), 1); fork.splice(fork.indexOf(element), 1);
} }
}); });
} }
} }
@ -583,6 +582,7 @@ function generate2(col, matchs, fork) {
initEndGame(); initEndGame();
invertLine(); invertLine();
checkAllSortieLogique(); checkAllSortieLogique();
console.log(circles);
} }
function getNumberFork(arr, col) { function getNumberFork(arr, col) {

@ -8,6 +8,7 @@ function initAllSwitch(mode) {
layer.draw(); layer.draw();
lineUpdate(element); lineUpdate(element);
checkEnd(mode); checkEnd(mode);
setCanvasScale();
}); });
switche.on('mouseover', function () { switche.on('mouseover', function () {
document.body.style.cursor = "pointer"; document.body.style.cursor = "pointer";

@ -13,6 +13,7 @@ var switchs = [],
endLines = [], endLines = [],
end, switchsInfo = [], end, switchsInfo = [],
switchsInfoCopy = [], switchsInfoCopy = [],
circles = [],
lineRemove = []; lineRemove = [];
var width = window.innerWidth - window.innerWidth / 100 * 30; var width = window.innerWidth - window.innerWidth / 100 * 30;
var height = window.innerHeight / 2.5; var height = window.innerHeight / 2.5;
@ -57,6 +58,7 @@ height = window.innerHeight / 1.5;
function resetAllTabs(save) { function resetAllTabs(save) {
if (!save) { if (!save) {
circles = [];
logiques = []; logiques = [];
numberPerColonne = []; numberPerColonne = [];

Loading…
Cancel
Save