Le nombre de dots des vitraux dépend des paramètres de l'accueil

upgrade-menu
adplantade 5 years ago
parent a1fd9aef0b
commit 83d430ff3a

@ -88,6 +88,47 @@ function drawImg(x,y,color,lectx)
}
function genVitraux()
{
var mat = matrix(6,6);
var x;
var y;
var baseVitrail=[true];
var tries;
for(var cpt=0;cpt<dotsAmount;cpt++)
{
x=getRandomInt(6)-1;
y=getRandomInt(6)-1;
console.log("mat :"+mat[x][y]);
while(mat[x][y]!=0 && tries!=20)
{
x=getRandomInt(6)-1;
y=getRandomInt(6)-1;
console.log("["+x+","+y+"] ->"+cpt);
tries++;
}
if(tries==20) console.log("trop long");
mat[x][y]=1;
x-=2;
y-=2;
baseVitrail.push([(x>0 ? x : x-1),(y>0 ? y : y-1),colors[cpt]]);
console.log("mat = "+mat);
tries=0;
}
//console.log("final : "+baseVitrail+" et :"+Array.isArray(baseVitrail));
for(var i=1;i<5;i++)
{
eval("tab"+i+"=copyMDArray(baseVitrail)");
}
}
function tourneG(letab,lecanvas,lectx)
{
letab.forEach(element => {
@ -534,6 +575,14 @@ function toggleVisible(where,reserve=false)
}
}
function matrix(m, n) {
var result = []
for(var i = 0; i < n; i++) {
result.push(new Array(m).fill(0))
}
return result
}
function events() {
for(var i=1;i<5;i++)
{
@ -567,11 +616,13 @@ function mlManager(e) {
document.getElementById(e.currentTarget.id).classList.remove('vitrail-hover');
}
genVitraux();
/*
tab1.push(true,[-3,-3,colors[0]],[-3,2,colors[1]],[1,2,colors[2]],[3,-3,colors[3]]);
tab2.push(true,[-3,-3,colors[0]],[-3,2,colors[1]],[1,2,colors[2]],[3,-3,colors[3]]);
tab3.push(true,[-3,-3,colors[0]],[-3,2,colors[1]],[1,2,colors[2]],[3,-3,colors[3]]);
tab4.push(true,[-3,-3,colors[0]],[-3,2,colors[1]],[1,2,colors[2]],[3,-3,colors[3]]);
*/
toutDessiner(tab1,canvas1,ctx1);
toutDessiner(tab2,canvas2,ctx2);

Loading…
Cancel
Save