if ((remainderCoordinates[0] >= canvasSize[0] / 2) && (remainderCoordinates[0] <= backgroundSize - canvasSize[0] / 2) &&
          (remainderCoordinates[1] >= canvasSize[1] / 2) && (remainderCoordinates[1] <= backgroundSize - canvasSize[1] / 2)) {
                try {
                        let img = await getBackground(divisionCoordinates[0], divisionCoordinates[1]);
                        let sx = remainderInPixels[0] - canvas.width / 2;
                        let sy = backgroundSize * coordinateInPixels - remainderInPixels[1] - canvas.height / 2;
                        let width = canvas.width;
                        let height = canvas.height;
                        let dx = 0;
                        let dy = 0;
                        context.drawImage(img, sx, sy, width, height, dx, dy, width, height);
                } catch {};
        } else if ((remainderCoordinates[1] >= canvasSize[1] / 2) &&
          (remainderCoordinates[1] <= backgroundSize - canvasSize[1] / 2)) {
                let sx1 = (remainderInPixels[0] - canvas.width / 2) % (backgroundSize * coordinateInPixels);
                let sy1 = backgroundSize * coordinateInPixels - remainderInPixels[1] - canvas.height / 2;
                let width1 = backgroundSize * coordinateInPixels - sx1;
                let height1 = canvas.height;
                let dy1 = 0;
                try {
                        let image1 = await getBackground(divisionCoordinates[0] - (remainderCoordinates[0] <= canvasSize[0] / 2),
                      divisionCoordinates[1]);
                        let dx1 = 0;
                        context.drawImage(image1, sx1, sy1, width1, height1, dx1, dy1, width1, height1);
                } catch {};
                try {
                        let image2 = await getBackground(divisionCoordinates[0] + (remainderCoordinates[0] >= canvasSize[0] / 2),
                          divisionCoordinates[1]);
                        let sx2 = 0;
                        let sy2 = sy1;
                        let width2 = canvas.width - width1;
                        let height2 = height1;
                        let dx2 = width1;
                        let dy2 = dy1;
                        context.drawImage(image2, sx2, sy2, width2, height2, dx2, dy2, width2, height2);
                } catch {};
        } else if ((remainderCoordinates[0] >= canvasSize[0] / 2) &&
          (remainderCoordinates[0] <= backgroundSize - canvasSize[0] / 2)) {
                let sx1 = remainderInPixels[0] - canvas.width / 2;
                let sy1 = (-canvas.height / 2 - remainderInPixels[1] * (remainderCoordinates[1] <= canvasSize[1] / 2 ? 1 : -1)) %
                  (backgroundSize * coordinateInPixels);
                let width1 = canvas.width;
                let height1 = backgroundSize * coordinateInPixels - sy1;
                let dx1 = 0;
                try {
                        let image1 = await getBackground(divisionCoordinates[0], divisionCoordinates[1] +
                          (remainderCoordinates[1] >= backgroundSize - canvasSize[1] / 2));
                        let dy1 = 0;
                        context.drawImage(image1, sx1, sy1, width1, height1, dx1, dy1, width1, height1);
                } catch {};
                try {
                        let image2 = await getBackground(divisionCoordinates[0], divisionCoordinates[1] -
                          (remainderCoordinates[1] <= canvasSize[1] / 2));
                        let sx2 = sx1;
                        let sy2 = 0;
                        let width2 = width1;
                        let height2 = canvas.height - height1;
                        let dx2 = dx1;
                        let dy2 = height1;
                        context.drawImage(image2, sx2, sy2, width2, height2, dx2, dy2, width2, height2);
                } catch {};
      } перебор остальных вариантов