Skip to content

Commit

Permalink
Update functions.js
Browse files Browse the repository at this point in the history
  • Loading branch information
flippont authored Oct 19, 2024
1 parent 8f4177a commit c31b228
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -244,4 +246,4 @@ function drawBGCanvas() {
}
}
drawBGCanvas()
generate()
generate()

0 comments on commit c31b228

Please sign in to comment.