mirror of
https://github.com/AMNatty/Mastodon-Circles.git
synced 2024-11-23 19:47:26 -07:00
Fixed an off-by-one error (two of them actually)
This commit is contained in:
parent
14e469c139
commit
ab7cbc7390
1 changed files with 8 additions and 4 deletions
10
image.js
10
image.js
|
@ -23,6 +23,8 @@ function render(users, selfUser) {
|
|||
|
||||
const tasks = [];
|
||||
|
||||
totalImg += 1;
|
||||
remainingImg += 1;
|
||||
loadImage(ctx,
|
||||
selfUser.avatar,
|
||||
(width / 2) - 110,
|
||||
|
@ -37,9 +39,12 @@ tasks);
|
|||
|
||||
// loop over each circle of the layer
|
||||
for (let i = 0; i < numb[layerIndex]; i++) {
|
||||
remainingImg += 1;
|
||||
// if we are trying to render a circle, but we ran out of users, just exit the loop. We are done.
|
||||
if (userNum >= users.length) break;
|
||||
|
||||
totalImg += 1;
|
||||
remainingImg += 1;
|
||||
|
||||
// We need an offset or the first circle will always on the same line, and it looks weird
|
||||
// Try removing this to see what happens
|
||||
const offset = layerIndex * 30;
|
||||
|
@ -65,8 +70,6 @@ tasks);
|
|||
}
|
||||
}
|
||||
|
||||
totalImg = remainingImg;
|
||||
|
||||
ctx.font = "12px sans-serif";
|
||||
ctx.fillStyle = "silver";
|
||||
ctx.fillText("Be gay do crime uwu", 10, 15);
|
||||
|
@ -129,6 +132,7 @@ function loadImage(ctx, url, x, y, r, name, tasks) {
|
|||
};
|
||||
|
||||
img.onerror = function() {
|
||||
console.error(`Error loading image: ${url}}`);
|
||||
decrementRemaining();
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue