Skip to content

Commit

Permalink
makeDetailsMask() numDots uint (p26b)
Browse files Browse the repository at this point in the history
  • Loading branch information
Explorer09 committed Feb 20, 2024
1 parent 475cc73 commit 0865099
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Meter.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ static uint16_t GraphMeterMode_makeDetailsMask(const GraphColorComputeState* pre
assert(rem >= 0.0);
assert(rem < 1.0);

double numDots = ceil(rem * 8.0);
unsigned int numDots = (unsigned int)(int) ceil(rem * 8.0);

uint8_t blanksAtEnd;
bool roundsUpInAscii = false;
Expand All @@ -513,7 +513,7 @@ static uint16_t GraphMeterMode_makeDetailsMask(const GraphColorComputeState* pre
blanksAtEnd = (uint8_t)blanksAtTopCell;
roundsUpInAscii = true;
} else if (prev->nCellsPainted == 0 || prev->topPoint <= (double)(int)prev->nCellsPainted) {
blanksAtEnd = (uint8_t)(8 - (uint8_t)numDots) % 8;
blanksAtEnd = (8 - numDots) % 8;
} else if ((double)(int)new->nCellsPainted > new->topPoint) {
assert(new->nCellsPainted - new->topPoint < 1.0);
assert(rem > 0.0);
Expand All @@ -530,14 +530,14 @@ static uint16_t GraphMeterMode_makeDetailsMask(const GraphColorComputeState* pre
roundsDownInAscii = distance < 0.5;

distance *= 8.0;
if ((uint8_t)numDots % 2 == 0) {
if (numDots % 2 == 0) {
distance -= 0.5;
}
distance = ceil(distance);
assert(distance >= 0.0);
assert(distance < INT_MAX);

unsigned int maxBlanks2 = 8 - (unsigned int)(int)numDots / 2;
unsigned int maxBlanks2 = 8 - numDots / 2;
assert(maxBlanks2 >= distance);
maxBlanks2 -= (unsigned int)(int)distance;
blanksAtEnd = (uint8_t)maxBlanks2;
Expand All @@ -548,7 +548,7 @@ static uint16_t GraphMeterMode_makeDetailsMask(const GraphColorComputeState* pre

uint8_t blanksAtStart;
if (prev->nCellsPainted > 0) {
blanksAtStart = (uint8_t)(8 - (uint8_t)numDots - blanksAtEnd) % 8;
blanksAtStart = (8 - numDots - blanksAtEnd) % 8;
} else {
// Always zero blanks for the first cell.
// When an item would be painted with all cells (from the first cell to
Expand Down

0 comments on commit 0865099

Please sign in to comment.