diff --git a/src/functions.js b/src/functions.js index c24ae51..d5e9f88 100644 --- a/src/functions.js +++ b/src/functions.js @@ -226,14 +226,16 @@ function enforceMinMax(el) { } function drawBGCanvas() { + let loadArray = [] for(let i=0; i<20; i++) { for(let j=0; j<20; j++) { const image = new Image(60, 45); // Using optional size for image image.src = countriesFlags[Math.floor(Math.random() * (countriesFlags.length - 1))].normal; image.crossOrigin = "anonymous" image.onload = () => { - ctx.drawImage(image, i * (canvas.width / 20), j * (( canvas.width / 20 ) / 1.5), canvas.width / 20, ( canvas.width / 20 ) / 1.5 ); - if(i == 19 && j == 19) { + ctx.drawImage(image, i * (canvas.width / 20), j * (( canvas.width / 20 ) / 1.5), canvas.width / 20, ( canvas.width / 20 ) / 1.5 ); + loadArray.push(i,j) + if(loadArray.length == 361) { // This is a programming sin if I've ever seen one var imageDataURL = canvas.toDataURL(); //set the dynamic image as the background document.body.style.background = @@ -244,4 +246,4 @@ function drawBGCanvas() { } } drawBGCanvas() -generate() \ No newline at end of file +generate()