diff --git a/code/vitraux.js b/code/vitraux.js index 740f64e..a38521f 100644 --- a/code/vitraux.js +++ b/code/vitraux.js @@ -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"+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);