mirror of
https://github.com/AMNatty/Mastodon-Circles.git
synced 2024-11-09 12:51: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
12
image.js
12
image.js
|
@ -23,13 +23,15 @@ function render(users, selfUser) {
|
|||
|
||||
const tasks = [];
|
||||
|
||||
totalImg += 1;
|
||||
remainingImg += 1;
|
||||
loadImage(ctx,
|
||||
selfUser.avatar,
|
||||
(width / 2) - 110,
|
||||
(height / 2) - 110,
|
||||
110,
|
||||
"@" + selfUser.handle,
|
||||
tasks);
|
||||
tasks);
|
||||
|
||||
// loop over the layers
|
||||
for (let layerIndex= 0; layerIndex < 3; layerIndex++) {
|
||||
|
@ -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